Documentation
¶
Overview ¶
Command specprep prepares the vendored OpenAPI document for oapi-codegen.
oapi-codegen v2.8 reads OpenAPI 3.1 natively, so no 3.1 -> 3.0 downgrade is needed. Two deterministic rewrites keep its output correct and idiomatic; they change neither the operations nor the wire format:
- Validation-only unions are dropped. FastAPI emits object-level constraints such as `anyOf: [{required: [city]}, {required: [lat, lng]}]` ("a city or coordinates"). Every member only adds constraints, so the union describes validation, not shape (the other SDKs ignore it for typing too). oapi-codegen would otherwise turn the request into a union type whose MarshalJSON sends "field": null for every unset untyped field, which the API rejects.
- `const` schemas without a `type` get the type of their value, so a field such as `renderer: {const: "default"}` becomes an optional string enum rather than interface{}.
- In an `additionalProperties` union of two or more types plus `null`, the `null` member is dropped. oapi-codegen v2.8 would otherwise declare the map values as pointers but generate accessors for plain values, which does not compile. The union still decodes a JSON null (it keeps the raw value).
Usage: specprep IN OUT