Skip to content

Commit 126043c

Browse files
committed
docs: minor updates to lambdas descriptions, update schema for generator property
1 parent 5d5aa2e commit 126043c

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

docs/README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,28 @@
3636

3737
### Predefined lambdas
3838

39-
Lambdas are special tags which invoke a predefined function named after tag.
40-
The function would receive the template fragement between the tag. More info
41-
about lambdas could be found [here](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md#mustache-lambdas)
39+
Lambdas are special tags which invoke a predefined function named after the tag.
40+
The function receives the template fragment between the tags. More info
41+
about lambdas can be found [here](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md#mustache-lambdas)
4242

43-
We support following lambdas at the moment
43+
We support the following pre-defined lambdas at the moment:
4444

4545
| lambda | example | description |
4646
|------------|----------------------------------------|-----------------------|
4747
| lowercase | {{#lowercase}}{{name}}{{/lowercase}} | Convert to lowercase |
4848
| uppercase | {{#uppercase}}{{name}}{{/uppercase}} | Convert to UPPERCASE |
49-
| snakecase | {{#snakecase}}{{name}}{{/snacecase}} | Convert to snake_case |
49+
| snakecase | {{#snakecase}}{{name}}{{/snakecase}} | Convert to snake_case |
5050
| pascalcase | {{#pascalcase}}{{name}}{{/pascalcase}} | Convert to PascalCase |
5151
| camelcase | {{#camelcase}}{{name}}{{/camelcase}} | Convert to camelCase |
5252
| kebabcase | {{#kebabcase}}{{name}}{{/kebabcase}} | Convert to kebab-case |
5353

5454
### Custom generators
5555

56-
Some languages have various reserved words or weird way of arguments formating.
56+
Some languages have various reserved words or unusual way of formatting arguments.
5757
Sometimes custom lambdas are needed to solve the issues.
58-
This means there should be a way to customize the codegeration. Custom generator
59-
is a javascript module defined as:
58+
A custom generator is simply a javascript module, for example:
6059

61-
```
60+
```js
6261
const Hogan = require('hogan.js');
6362

6463
const RESERVED_WORDS = new Set([
@@ -77,7 +76,7 @@ function hello_lambda() {
7776
return function(text) {
7877
return 'Hello ' + Hogan.compile(text).render(this);
7978
}
80-
};
79+
}
8180

8281
function complex_lambda() {
8382
return function(template) {
@@ -102,11 +101,11 @@ module.exports = {
102101
hello: hello_lambda,
103102
path_template: complex_lambda
104103
}
105-
}
104+
};
106105
```
107106

108-
The module has to be configured in config under `generator` property. Here is an example:
109-
```
107+
The module has to be configured in your config under the `generator` property. Here is an example:
108+
```json
110109
{
111110
"defaults": {
112111
"modelNaming": "snake_case",
@@ -122,5 +121,5 @@ The module has to be configured in config under `generator` property. Here is an
122121
"perModel": [
123122
]
124123
}
124+
```
125125

126-
```

schemas/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"type": "boolean",
1919
"description": "Whether to include the Apache-2.0 license instead of the Unlicense"
2020
},
21+
"generator": {
22+
"type": "string",
23+
"description": "Custom JS function defining additional lambdas"
24+
},
2125
"directories": {
2226
"type": "array",
2327
"description": "list of directories to create in output directory",

0 commit comments

Comments
 (0)