@penkov/swagger-code-gen 1.8.8 → 1.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/method.js CHANGED
@@ -69,11 +69,13 @@ export class Method {
69
69
  .minByOption(identity);
70
70
  const respDef = successCode.map(_ => def.responses[_])
71
71
  .orElse(() => option(def.responses['default']))
72
- .getOrElseValue(def.responses[statusCodes.head]);
72
+ .orElse(() => statusCodes.headOption.flatMap(code => option(def.responses[code])))
73
+ .getOrElseValue({});
73
74
  const mimeTypes = option(respDef.content)
74
75
  .map(content => Collection.from(Object.keys(content)).toMap(mimeType => [mimeType, content[mimeType]])).getOrElseValue(HashMap.empty);
75
76
  this.response = mimeTypes.get('application/json')
76
77
  .orElseValue(mimeTypes.values.headOption)
78
+ .filter(p => option(p.schema).isDefined)
77
79
  .map(p => Property.fromDefinition('', p.schema, schemasTypes, options).copy({
78
80
  nullable: false,
79
81
  required: true
package/dist/property.js CHANGED
@@ -21,7 +21,12 @@ export class Property {
21
21
  }
22
22
  static fromDefinition(name, definition, schemaTypes, options) {
23
23
  const referencesObject = option(definition.$ref)
24
- .exists(ref => schemaTypes.get(ref.substring(SCHEMA_PREFIX.length)).contains('object'));
24
+ .exists(ref => schemaTypes.get(ref.substring(SCHEMA_PREFIX.length)).contains('object')) ||
25
+ option(definition.allOf)
26
+ .filter(allOf => allOf.length === 1)
27
+ .flatMap(allOf => option(allOf[0]))
28
+ .flatMap(schema => option(schema.$ref))
29
+ .exists(ref => schemaTypes.get(ref.substring(SCHEMA_PREFIX.length)).contains('object'));
25
30
  const itemReferencesObject = option(definition.items)
26
31
  .flatMap(i => option(i.$ref))
27
32
  .exists(ref => schemaTypes.get(ref.substring(SCHEMA_PREFIX.length)).contains('object'));
package/dist/schemas.js CHANGED
@@ -82,7 +82,10 @@ export class SchemaObject {
82
82
  static fromDefinition(name, def, schemasTypes, options) {
83
83
  const explicitlyRequired = option(def.required)
84
84
  .map(arr => typeof arr === 'boolean' ? Nil : Collection.from(arr));
85
- const properties = Collection.from(Object.keys(def.properties)).map(propName => {
85
+ const properties = option(def.properties)
86
+ .map(props => Collection.from(Object.keys(props)))
87
+ .getOrElseValue(Nil)
88
+ .map(propName => {
86
89
  const property = Property.fromDefinition(propName, def.properties[propName], schemasTypes, options);
87
90
  return property.copy({
88
91
  required: explicitlyRequired.exists(c => c.contains(propName)) ? true : property.required
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@penkov/swagger-code-gen",
3
- "version": "1.8.8",
3
+ "version": "1.8.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "generate-client": "./dist/cli.mjs"