@penkov/swagger-code-gen 1.6.7 → 1.6.8
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/property.js +18 -3
- package/package.json +2 -2
package/dist/property.js
CHANGED
|
@@ -30,9 +30,23 @@ export class Property {
|
|
|
30
30
|
.map(x => x.flatMapOption(oneOfItem => option(oneOfItem.$ref)
|
|
31
31
|
.map(ref => ref.substring(SCHEMA_PREFIX.length))
|
|
32
32
|
.orElseValue(option(oneOfItem.type))).mkString(' & ')))
|
|
33
|
+
.orElse(() => option(definition.anyOf)
|
|
34
|
+
.map(x => Collection.from(x))
|
|
35
|
+
.filter(x => x.nonEmpty)
|
|
36
|
+
.map(x => {
|
|
37
|
+
return x
|
|
38
|
+
.filter(t => t.type !== 'null')
|
|
39
|
+
.flatMapOption(oneOfItem => option(oneOfItem.$ref)
|
|
40
|
+
.map(ref => ref.substring(SCHEMA_PREFIX.length))
|
|
41
|
+
.orElseValue(option(oneOfItem.type))).mkString(' | ');
|
|
42
|
+
}))
|
|
33
43
|
.getOrElseValue(definition.type);
|
|
34
44
|
const nullable = option(definition.nullable).contains(true) ||
|
|
35
|
-
(referencesObject && options.referencedObjectsNullableByDefault && !option(definition.nullable).contains(false))
|
|
45
|
+
(referencesObject && options.referencedObjectsNullableByDefault && !option(definition.nullable).contains(false)) ||
|
|
46
|
+
option(definition.anyOf)
|
|
47
|
+
.map(x => Collection.from(x))
|
|
48
|
+
.filter(x => x.nonEmpty)
|
|
49
|
+
.exists(anyOf => anyOf.exists(t => t.type === 'null'));
|
|
36
50
|
const description = option(definition.description);
|
|
37
51
|
const required = option(definition.required).contains(true);
|
|
38
52
|
const items = option(definition.items?.$ref)
|
|
@@ -50,7 +64,7 @@ export class Property {
|
|
|
50
64
|
get jsType() {
|
|
51
65
|
let res = Property.toJsType(this.type, this.items);
|
|
52
66
|
if (this.nullable) {
|
|
53
|
-
res = res + '| null';
|
|
67
|
+
res = res + ' | null';
|
|
54
68
|
}
|
|
55
69
|
return res;
|
|
56
70
|
}
|
|
@@ -90,7 +104,8 @@ export class Property {
|
|
|
90
104
|
}
|
|
91
105
|
}
|
|
92
106
|
else {
|
|
93
|
-
|
|
107
|
+
const jsType = Property.toJsType(this.type, this.items);
|
|
108
|
+
return !this.nullable && this.required ? this.jsType : `Option<${jsType}>`;
|
|
94
109
|
}
|
|
95
110
|
}
|
|
96
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@penkov/swagger-code-gen",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"generate-client": "./dist/cli.mjs"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/papirosko/swagger-code-gen#readme",
|
|
24
24
|
"scripts": {
|
|
25
|
-
"test:petstore": "node --loader ts-node/esm ./src/cli.mjs --enableScats --targetNode --url
|
|
25
|
+
"test:petstore": "node --loader ts-node/esm ./src/cli.mjs --enableScats --targetNode --url https://petstore3.swagger.io/api/v3/openapi.json tmp/petstore.ts",
|
|
26
26
|
"clean": "rimraf dist",
|
|
27
27
|
"lint": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
28
28
|
"prebuild": "npm run lint && npm run clean",
|