feat: PoC Support OpenAPI 3.1#6781
Conversation
|
(Generated, but looks pretty legit to me) OpenAPI 3.1 Branch — Change Analysis & Coverage ReportWhat the Branch ContainsThe Root Cause FixedThe original generator silently accepted 3.1 documents but parsed them as 3.0, producing broken or
Feature-by-Feature Changes1. Type System — JSON Schema 2020-12 AlignmentNew input type
|
| File | New tests | What it covers |
|---|---|---|
src/parser/schema.spec.ts |
16 | 3.1 feature block (type arrays, null, const, tuples, patternProperties, etc.) |
src/parser/type-mapping.spec.ts |
4 | Type arrays / union mapping |
src/file-serializer/schema.spec.ts |
4 | Const / tuple serialization |
src/schema-util.spec.ts |
1 | 3.1 property documentation |
src/parser/document.spec.ts |
4 | Nullable persisted schemas, paths-less docs, webhooks/pathItems warnings |
src/document-converter.spec.ts |
1 | 3.1 passthrough / version detection |
OpenAPI 3.1 Release History
| Version | Date | Notes |
|---|---|---|
| 3.1.0 RC0 | June 2020 | Introduced webhooks, jsonSchemaDialect, components/pathItems, license.identifier |
| 3.1.0 RC1 | Sept 2020 | Refinements |
| 3.1.0 RC2 | Nov 2020 | Further refinements |
| 3.1.0 final | February 2021 | Full JSON Schema 2020-12 alignment; nullable removed; type arrays; const; prefixItems; numeric exclusiveMin/Max; $ref siblings; paths optional; responses optional |
| 3.1.1 | October 24, 2024 | Patch only — clarifications on enum/default (SHOULD → MUST), OAuth/bearer docs, Security Considerations section. No breaking changes. |
| 3.1.2 | In spec repo | Clarifications only. No breaking changes. |
OpenAPI no longer follows SemVer — future minor increments may introduce breaking changes.
Coverage Matrix
Fully Covered
| Feature | Handler |
|---|---|
type as array |
getSchemaTypes / getType with union join |
nullable removed; null via type array |
isNullableSchema / stripNullability |
Standalone type: "null" |
Explicit branch in parseSchema |
const keyword |
parseConstSchema + serializer |
prefixItems (tuples) |
parseTupleSchema with rest element |
contentEncoding/contentMediaType → Blob |
Schema parsing + property collection |
examples array |
Collected + multi-@example JSDoc |
Numeric exclusiveMin/Max |
Collected with undefined-guard |
patternProperties |
Merged into additionalProperties union |
$ref sibling description |
Preserved in property parsing |
paths optional |
Empty paths: {} injected before validation |
webhooks |
Explicit named warning |
components/pathItems |
Explicit named warning |
swagger2openapi bypass for 3.x docs |
Version string detection in converter |
example + examples mutual exclusivity |
Warning + example dropped |
Not a Generator Concern (by Design)
| Item | Reason |
|---|---|
responses optional under Operation |
parseResponses already handles undefined — no crash |
info.version SemVer dropped |
Generator never validates info.version |
info.license.identifier |
License data not consumed |
| Mutual TLS security scheme | Generator does not produce auth/security code |
Server variable enum/default strictness |
Generator does not validate server variable constraints |
jsonSchemaDialect / $schema |
swagger-parser handles document parsing |
$ref sibling summary |
No TypeScript output for summary on a $ref |
| 3.1.1 / 3.1.2 patch releases | Clarification-only; no code impact |
Known Remaining Gaps
| Gap | Impact | Notes |
|---|---|---|
Advanced JSON Schema 2020-12 applicators: if/then/else, $defs, unevaluatedProperties, unevaluatedItems, dependentSchemas, dependentRequired, propertyNames, contains/minContains/maxContains, $dynamicRef/$dynamicAnchor, $vocabulary, $anchor |
Low–Medium | Silently ignored; schemas using them degrade toward any or Record<string,any>. Would require a full JSON Schema 2020-12 evaluation layer to close. |
patternProperties with distinct per-pattern value types |
Low | All pattern schemas collapsed into a single Record<string, V> union — per-pattern type distinctions are lost when patterns have different value types. |
webhooks code generation |
Design decision | No callable client methods emitted; warning only. Semantically correct for an outbound client SDK, but a gap if webhook handler stubs are ever desired. |
components/pathItems code generation |
Low | Warning only; path items used as $ref targets for webhooks remain unresolved in the generated client. |
Conclusion
The branch is a solid, backward-compatible first implementation of 3.1 support. All breaking changes from OAS 3.0 → 3.1 that are relevant to TypeScript client codegen are addressed. The remaining gaps are either advanced JSON Schema applicator keywords (requiring a full evaluation engine, out of scope) or structural features (webhooks, pathItems) that do not map naturally to an outbound client SDK.
Vibe coded solution to support openapi 3.1
Most changes verified. There might be some generated non-sense though that I missed. But overall this PR shows the possibility and effort to keep maintaining our own generator.
OAI Spec Releases