GREsau / okapi

OpenAPI (AKA Swagger) document generation for Rust projects
MIT License
631 stars 112 forks source link

Reference object and nullable #145

Closed kontsaki closed 6 months ago

kontsaki commented 8 months ago

Hello,

according to https://github.com/OAI/OpenAPI-Specification/issues/1368 the following schema generated by okapi

            "schema": {
              "$ref": "#/components/schemas/SomeType",
              "nullable": true
            }

should instead be

            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/SomeType"
                }
              ],
              "nullable": true
            }

with OpenAPI v3.1.0 completely dropping nullable in favor of the following

            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/SomeType"
                },
                {
                  "type": "null"
                }
              ]
            }

How does okapi want to handle this, if at all?

ralpha commented 6 months ago

Looking over the discussion you linked it looks like there is not a bit agreement over the issue. As Okapi is currently following the 3.0.0 spec I don't think this would be worth a fix at this point. When we are looking at implementing 3.1.0 (or later) this would automatically be fixed. As it currently stand it looks like all the tools that use the OpenAPI spec already handle the current way of doing this correctly.

Unless you can show me an exact use-case where this is creating issue I'm not intending to spend time fixing this. If you provide me with more info I'm willing to have a closer look at this. But please provide me with concise information. (Will close issue, can always reopen if more info is provided)