@mittwald/api-code-generator 4.136.2 → 4.214.1

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/bin/cli.js CHANGED
File without changes
@@ -1,6 +1,7 @@
1
1
  import { JSONSchema } from "../global/JSONSchema.js";
2
2
  import { Name } from "../global/Name.js";
3
3
  import { asyncStringJoin } from "../../asyncStringJoin.js";
4
+ import { populateNullableTypes } from "../../populateNullableTypes.js";
4
5
  export class Schemas {
5
6
  static ns = "Schemas";
6
7
  schemas;
@@ -9,7 +10,9 @@ export class Schemas {
9
10
  constructor(components, schemas) {
10
11
  this.components = components;
11
12
  this.name = new Name(Schemas.ns, components.name);
12
- this.schemas = Object.entries(schemas ?? {}).map(([schemaName, schema]) => new JSONSchema(new Name(schemaName, this.name), schema));
13
+ this.schemas = Object.entries(schemas ?? {}).map(([schemaName, schema]) => {
14
+ return new JSONSchema(new Name(schemaName, this.name), populateNullableTypes(schema));
15
+ });
13
16
  }
14
17
  async compileTypes(opts) {
15
18
  const t = {
@@ -0,0 +1,26 @@
1
+ export function populateNullableTypes(schema) {
2
+ if (!schema || "$ref" in schema) {
3
+ return schema;
4
+ }
5
+ if (schema.properties) {
6
+ for (const key in schema.properties) {
7
+ schema.properties[key] = populateNullableTypes(schema.properties[key]);
8
+ }
9
+ }
10
+ if ("items" in schema && schema.items) {
11
+ schema.items = populateNullableTypes(schema.items);
12
+ }
13
+ const compositionKeys = ["allOf", "anyOf", "oneOf"];
14
+ compositionKeys.forEach((key) => {
15
+ const entries = schema[key];
16
+ if (Array.isArray(entries)) {
17
+ schema[key] = entries.map(populateNullableTypes);
18
+ }
19
+ });
20
+ if (schema.nullable) {
21
+ return {
22
+ anyOf: [schema, { type: "null" }],
23
+ };
24
+ }
25
+ return schema;
26
+ }
@@ -0,0 +1,2 @@
1
+ import { OpenAPIV3 } from "openapi-types";
2
+ export declare function populateNullableTypes(schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject): OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/api-code-generator",
3
- "version": "4.136.2",
3
+ "version": "4.214.1",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/mittwald/api-client-js.git",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "@types/prettier": "^3.0.0",
38
38
  "@types/verror": "^1.10.10",
39
39
  "@types/yieldable-json": "^2.0.2",
40
- "axios": "^1.8.2",
40
+ "axios": "^1.11.0",
41
41
  "camelcase": "^8.0.0",
42
42
  "clone-deep": "^4.0.1",
43
43
  "dot-prop": "^8.0.2",
@@ -84,5 +84,5 @@
84
84
  "@oclif/plugin-plugins"
85
85
  ]
86
86
  },
87
- "gitHead": "f45d5d8214395589994156260e493b542c9c8b7f"
87
+ "gitHead": "7803602885d862ea680b1bcad030c61e888653b9"
88
88
  }