Search code examples
swaggeropenapiswagger-editor

exclusiveMinimum in Swagger OAS 3.0 not applied


Swagger Editor is giving me this example response:

[
  {
    "simulation_run_id": 0
  }
]

for defintion:

  /v1/simulation-run-submissions:
    post:
      summary: 'Post a simulation run creation TODO: Will need to update API with parameters weather file, glmfile, name, start,end,interval, etc.. check wireframe.  Submit model file and get back validation and ID.  We will use the same API above and just return validation error.'
      #description:
      responses:
        '201':
          description: The metadata for a simulation run
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SimulationRunSubmissionResponse'
...
components:
  schemas:
    SimulationRunId:
      type : integer
      format: int64
      minimum: 1
      exclusiveMinimum: true

The exclusiveMinimum option does not seem to be applied to the schema as the example is showing 0.


Solution

  • Currently Swagger UI and Swagger Editor do not use the minimum and exclusiveMinimum values when generating request and response examples. Feel free to submit an enhancement request.

    The easiest solution is to specify the example manually:

    components:
      schemas:
        SimulationRunId:
          type : integer
          format: int64
          minimum: 1
          exclusiveMinimum: true
          example: 2  # <-------