@specbook/codegen 0.5.1 → 0.6.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/schema.ts +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@specbook/codegen",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "description": "Turns an OpenAPI or Swagger document into types, examples, schemas and metadata, in Node or in a browser.",
5
5
  "keywords": [
6
6
  "specbook",
@@ -40,7 +40,7 @@
40
40
  "swagger2openapi": "7.0.8"
41
41
  },
42
42
  "devDependencies": {
43
- "@specbook/core": "0.5.1",
43
+ "@specbook/core": "0.6.1",
44
44
  "@types/node": "24.19.2",
45
45
  "@types/swagger2openapi": "7.0.4",
46
46
  "typescript": "7.0.2"
package/src/schema.ts CHANGED
@@ -514,6 +514,9 @@ function convertSchema(schema: Schema | undefined, refPrefix: string): Schema {
514
514
  }
515
515
  case 'array':
516
516
  return { ...meta, type: t('array'), items: rec(schema.items ?? {}) }
517
+ case 'null':
518
+ // OpenAPI 3.1 writes an optional field as `anyOf: [{ type: integer }, { type: 'null' }]`: the branch must stay a null
519
+ return { ...meta, type: 'null' }
517
520
  default: {
518
521
  if (!schema.properties && schema.additionalProperties === undefined && type !== 'object')
519
522
  return meta