|
198 | 198 | {##
|
199 | 199 | # defines an object property of some prop.type
|
200 | 200 | #}
|
201 |
| -{% macro defineObjectProperty(propName, prop, parentPropName) -%} |
| 201 | +{% macro defineObjectProperty(propName, prop, parentPropName, camelCasedPropNames) -%} |
202 | 202 | {% if propName %}
|
203 |
| - "{{ propName }}": |
| 203 | + {% if camelCasedPropNames %} |
| 204 | + "{{ propName | camelCase }}": |
| 205 | + {% else %} |
| 206 | + "{{ propName }}": |
| 207 | + {% endif %} |
204 | 208 | {% endif %}
|
205 | 209 | {%- if prop.$ref %}
|
206 | 210 | {{ defineRef(prop.$ref, prop, true) }}
|
|
253 | 257 | # define object properties recursively,
|
254 | 258 | # supports additionaProperties, allOf and oneOf.
|
255 | 259 | #}
|
256 |
| -{% macro defineObject(definitionName, definition, strictInterfaces) -%} |
| 260 | +{% macro defineObject(definitionName, definition, strictInterfaces, camelCasedPropNames) -%} |
257 | 261 | {{ importLocalProps(definition) }}
|
258 | 262 | {%- if definition.description %}
|
259 | 263 | {{ definition.description | comment | safe }}
|
|
266 | 270 | {% for propName, prop in definition.properties -%}
|
267 | 271 | {% if prop.type == "object" %}
|
268 | 272 | {% set composedPropName %}{{ definitionName }}{{ propName | capitalizeFirst }}{% endset %}
|
269 |
| - {{ defineObject(composedPropName, prop, strictInterfaces) }} |
| 273 | + {{ defineObject(composedPropName, prop, strictInterfaces, camelCasedPropNames) }} |
270 | 274 | {% endif %}
|
271 | 275 | {% endfor %}
|
272 | 276 |
|
|
276 | 280 | {% set typedef %}t.dictionary(t.string, t.any, "{{ definitionName }}"){% endset %}
|
277 | 281 | {% else %}
|
278 | 282 | {% set typedef %}t.dictionary(t.string,
|
279 |
| - {{ defineObjectProperty(false, definition.additionalProperties) }} "{{ definitionName }}") |
| 283 | + {{ defineObjectProperty(false, definition.additionalProperties, camelCasedPropNames) }} "{{ definitionName }}") |
280 | 284 | {% endset %}
|
281 | 285 | {%- endif %}
|
282 | 286 | {% set defaultValue = definition.default | dump | safe if definition.default else undefined %}
|
|
286 | 290 | const {{ definitionName }}R = t.interface({
|
287 | 291 | {% for propName, prop in definition.properties -%}
|
288 | 292 | {% if definition.required and (definition.required | contains(propName)) %}
|
289 |
| - {{ defineObjectProperty(propName, prop, definitionName) }} |
| 293 | + {{ defineObjectProperty(propName, prop, definitionName, camelCasedPropNames) }} |
290 | 294 | {% endif %}
|
291 | 295 | {% endfor %}
|
292 | 296 | });
|
|
295 | 299 | const {{ definitionName }}O = t.partial({
|
296 | 300 | {% for propName, prop in definition.properties -%}
|
297 | 301 | {% if (not definition.required) or (definition.required and not (definition.required | contains(propName))) %}
|
298 |
| - {{ defineObjectProperty(propName, prop, definitionName) }} |
| 302 | + {{ defineObjectProperty(propName, prop, definitionName, camelCasedPropNames) }} |
299 | 303 | {% endif %}
|
300 | 304 | {% endfor %}
|
301 | 305 | });
|
|
318 | 322 |
|
319 | 323 | {% for schema in definition.allOf -%}
|
320 | 324 | {% if schema.type == "object" %}
|
321 |
| - {{ defineObject(definitionName + loop.index, schema, strictInterfaces) }} |
| 325 | + {{ defineObject(definitionName + loop.index, schema, strictInterfaces, camelCasedPropNames) }} |
322 | 326 | {% elif schema.$ref %}
|
323 | 327 | {%- set realPropName = schema.$ref | replace("#/definitions/", "") -%}
|
324 | 328 | {{ importLocalProp(realPropName) }}
|
|
349 | 353 |
|
350 | 354 | {% for schema in oneOfProps -%}
|
351 | 355 | {% if schema.type == "object" %}
|
352 |
| - {{ defineObject(definitionName + loop.index, schema, strictInterfaces) }} |
| 356 | + {{ defineObject(definitionName + loop.index, schema, strictInterfaces, camelCasedPropNames) }} |
353 | 357 | {% elif schema.$ref %}
|
354 | 358 | {%- set realPropName = schema.$ref | replace("#/definitions/", "") -%}
|
355 | 359 | {{ importLocalProp(realPropName) }}
|
|
0 commit comments