opyeb openapilab

openapilab · Migration

What to check when moving from 3.0 to 3.1

nullable, webhooks, license.identifier and the JSON Schema alignment, plus an order for checking the result.

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

Schema expressions that change

3.03.1
exclusiveMinimum: true with minimumexclusiveMinimum: 0 as a number
example in a schemaan examples array is preferred
keys beside $ref ignored$ref and siblings evaluated together
type is one stringa 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

  1. Change openapi to 3.1.x and search for any remaining nullable.
  2. Confirm that no 3.0 document still has null in a type array.
  3. Move incoming events into webhooks and give each one an operationId and responses.
  4. Add an SPDX identifier to the licence and decide whether to keep url as well.
  5. 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 tool

Written against the OpenAPI Specification 3.1.0 (2021-02), 3.0.3 and JSON Schema 2020-12. Every example spec and host is synthetic.