Incorrect information about JsonNullable in swagger

68 Views Asked by At

I use JsonNullable in a project and the following dependencies.

<swagger-parser.version>2.1.13</swagger-parser.version>
<jackson-databind-nullable.version>0.2.6</jackson-databind-nullable.version>
<openapi-generator-maven-plugin.version>7.0.0</openapi-generator-maven-plugin.version>

But the generated docs available at http://localhost:8080/v3/api-docs seem to miss some information about JsonNullable

Below is an excerpt from it:

...
"JsonNullableString": {
    "type": "object",
    "properties": {
        "present": {
            "type": "boolean"
        }
    },
    "description": "Some description",
    "example": 252534342
},
"OrganizationUpdateData": {
    "type": "object",
    "properties": {
        "inn": {
            "$ref": "#/components/schemas/JsonNullableString"
        },
        "kpp": {
            "$ref": "#/components/schemas/JsonNullableString"
        },
...

it can be seen that JsonNullable doesn't have a value, but only a flag that indicates whether it has one or not.

I noticed that backend part works fine and can differentiate between received null or absent value. So if I start the service and use in some request to it:

{
inn: null
}

it is deserialized as JsonNullable.of(null)

if inn isn't contained in request json at all it will be deserialized as JsonNullable.undefined()

But frontend developers have difficulties with generation of code that would allow them to build requests.

Not sure what needs to be done to solve their problem. And I don't even understand how the "right" contents of http://localhost:8080/v3/api-docs should look like...

I define the structure using OpenApi 3.0.3 in organization.yml

openapi: 3.0.3

info:
  title: Organization API
  description: Organization operations
  version: '1.0.0'

...

    OrganizationUpdateData:
      type: object
      description: Organization update data
      properties:
        inn:
          type: string
          nullable: true
          description: inn
          example: 2395318535
          pattern: "^(\\d{10}|\\d{12})$"

...
0

There are 0 best solutions below