What to check when moving from 3.0 to 3.1
3.1 changes a few expressions from 3.0 and aligns the schema part with JSON Schema 2020-12. A document does not have to be rewritten, but consumers read the two versions differently, so running a linter afterwards is worthwhile.
nullable becomes a type array
nullable: true in 3.0 becomes type: [string, 'null'] in 3.1. A nullable left in a 3.1 document raises schema.nullableIn31; a null type array in a 3.0 document raises schema.nullTypeIn30. Where nullable sat beside $ref, rewrite it with oneOf or a type array.
webhooks and licence
- 3.1 defines incoming events under
webhooks. Putting it in a 3.0 document raiseswebhooks.notSupported. info.license.identifieris a 3.1 field for an SPDX identifier; 3.0 only hasurl.- 3.1 can set a schema dialect with
jsonSchemaDialect; the default applies when it is omitted.
Schema expressions that change
| 3.0 | 3.1 |
|---|---|
exclusiveMinimum: true with minimum | exclusiveMinimum: 0 as a number |
example in a schema | an examples array is preferred |
keys beside $ref ignored | $ref and siblings evaluated together |
type is one string | a type array is allowed |
This tool detects nullable mixing, webhooks, $ref siblings and type arrays automatically. Numeric exclusiveMinimum and examples arrays depend on the document, so they are not converted; check them by reading the result.
An order for checking
- Change
openapito 3.1.x and search for any remainingnullable. - Confirm that no 3.0 document still has
nullin atypearray. - Move incoming events into
webhooksand give each one anoperationIdand responses. - Add an SPDX identifier to the licence and decide whether to keep
urlas well. - Fix the linter until there are no errors, then check the request shape through the snippets and mocks.
If both versions must run at once, keep the 3.0 document and write a separate 3.1 document. The specification does not allow branching on the version inside one file.
Questions
Will existing tools read a 3.1 document?
Some do not support 3.1. Before deploying, check that the generators and viewers you actually use can read it.
What happens if nullable stays?
A 3.1 consumer may ignore the key, so the schema silently stops allowing null. This tool reports it as an error.
Can webhooks be treated like paths?
No. webhooks is a set of event names, not path templates. Each entry has the structure of a path item but is not a URL path.
Change the 3.0 orders preset to 3.1 and watch which diagnostics appear.
Open the toolWritten against the OpenAPI Specification 3.1.0 (2021-02), 3.0.3 and JSON Schema 2020-12. Every example spec and host is synthetic.