Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-2098

OpenAPI doesn't respect @JsonIgnore

    Details

      Description

      I'm using microprofile-openapi (knowing it is experimental). It mostly works like a charm for me. However, I just noticed a bug.

      Having a model class annotated with @Schema on class and field level (other fields omitted for simplicity).

      @Schema(description="description")
      class Foo {
        @JsonIgnore
        private Long id;
      }
      

      This results in the following OpenAPI documentation:

      components:
        schemas:
          Foo:
            description: description
            properties:
              id:
                format: int32
                type: integer
      

      Adding @Schema(hidden=true) to the field yields this:

      components:
        schemas:
          Foo:
            description: description
            properties:
              id: {}
      

      I suppose the latter is expected to really just hide the schema definition of the id field but not the field itself. But using @JsonIgnore to say, this field is not used anywhere in the JSON representation should also hide the field from the OpenAPI documentation.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  msavy Marc Savy
                  Reporter:
                  aklemp Andreas Klemp
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: