Skip to content

Optional fields without example and default value should not appear in the example  #4752

Open
@gnvk

Description

@gnvk

... or at least this should be an option.

Content & configuration

The PetStore has dozens of examples, e.g.:

 Category:
   type: "object"
   properties:
     id:
       type: "integer"
       format: "int64"
     name:
       type: "string"

From this the example in the UI is the following:

"category": {
  "id": 0,
  "name": "string"
}

Describe the solution you'd like

I would like to have an option not to display an optional field in the example, if it doesn't have an example and/or a default value, so the above example (since both the "id" and the "name" fields are not required and have no default/example value) should become an empty object:

"category": {
}

Describe alternatives you've considered

As a workaround we can use example='', default='' for a string, even though a missing parameter is not the same as a parameter with an empty string, and check for empty string on the server side.

Additional context

Context: we have an integration test that tests that the schema committed can be "tried out" without any modification. Having "string" values for optional fields that have no default values on purpose makes this impossible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions