openapi-format icon indicating copy to clipboard operation
openapi-format copied to clipboard

Nullable keyword still exists for objects after converting from 3.0.0 schema to 3.1.0

Open LeoWesterberg opened this issue 8 months ago • 2 comments

Hi!

Really useful library for converting specs from 3.0.0 to 3.1.0. Just wanted to highlight that Nullable = true still exists when next to type=object, which makes it an invalid 3.1.0 schema

LeoWesterberg avatar Apr 25 '25 07:04 LeoWesterberg

hi @LeoWesterberg

I was not aware and will have a look into this case.

Do you have an example that you can share so I can reproduce it?

thim81 avatar Apr 25 '25 08:04 thim81

hi @LeoWesterberg

I tried to create a repo case.

When I have this input:

openapi: 3.0.0
components:
  schemas:
    MyObject:
      type: object
      nullable: true
      properties:
        foo:
          type: string

After the conversion to 3.1, openapi-format returns this:

openapi: 3.1.0
components:
  schemas:
    MyObject:
      type:
        - object
        - 'null'
      properties:
        foo:
          type: string

In 3.1 the old nullable: true flag is gone, and OpenAPI expects the schema may be null, by adding "null" to the type array.

Can you share some more info, about what is the result you are experiencing?

thim81 avatar May 02 '25 09:05 thim81