zalando / intellij-swagger

A plugin to help you easily edit Swagger and OpenAPI specification files inside IntelliJ IDEA
https://plugins.jetbrains.com/plugin/8347
MIT License
1.18k stars 75 forks source link

OpenAPI 3.1 compatibility: "examples" property not allowed / "type" property as an array not allowed #431

Open Tithugues opened 7 months ago

Tithugues commented 7 months ago

Describe the bug From OpenAPI 3.1, the example property is deprecated and examples is preferred and type property can be a string, but also an array of strings.

The examples property and the type as an array seem not to be supported.

To Reproduce

  1. Create a YAML file in a project
  2. Copy the following lines in the file:
    openapi: '3.1.0'
    info:
    version: '0.0.1'
    title: 'My API'
    paths:
    /my/route:
      get:
        operationId: MyRoute
        responses:
          200:
            description: 'Successful response.'
            content:
              application/json:
                schema:
                  type: object
                  properties:
                    a_property:
                      type: ['string', 'null']
                      examples:
                        - null
                        - "Hello world!"
  3. See errors

Expected behavior I would expect examples and type as an array to be allowed in the editor part.

Screenshots Editor complains about those 2 properties: image

On the other hand, the preview seems to "understand" the syntax: image

Stack trace No exception.

Desktop (please complete the following information):

Additional context Swagger editor (https://editor-next.swagger.io) does not complain about this YAML file.


Am I wrong anywhere? Is the OpenAPI 3.1 not supported? If so, is it expected to be supported?

Thank you! :pray:

Tithugues commented 6 months ago

Regarding the examples, it seems it can't be used everywhere! Sorry for this mistake. :pray:

On the other hand, regarding the type type, I'm not sure I made a mistake.

tmack8001 commented 1 month ago

examples should be supported on a number of types.

I have been wanting to add examples to properties of a type: object entity for example for properties that are of type string, number, or similar.