My check engine light was on.  After my car set over the weekend it wouldn't start.  I took the battery down to a shop to be checked and charged.  When I picked it up they said I needed to replace it.  When I put the new battery in the car, the check light was off.  How long before the check light could go back on if it was something else causing a problem.


Question: How to define enum in swagger.io?
Answer: "enum" works just like this:

      {
        "in": "query",
        "name": "sample",
        "description": "a sample parameter with an enum value",
        "type": "string",
        "enum": [ "1", "2"],
        "required": true
      }


As you can see, there's a query parameter called sample of type string, and has an enum stating two possible values. In this case, the sample states the parameter is required, so the UI will not show an empty value as an option.

For a minimal working sample, try this:

{
  "swagger": "2.0",
  "info": {
    "title": "title",
    "description": "descriptor",
    "version": "0.1"
  },
  "paths": {
    "/sample": {
      "post": {
        "description": "sample",
        "parameters": [
          {
            "in": "query",
            "name": "sample",
            "description": "a sample parameter with an enum value",
            "type": "string",
            "enum": [
              "1",
              "2"
            ],
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful request."
          }
        }
      }
    }
  }
}


To test it locally, you can declare a variable (for example spec) in your javascript, and pass it into the SwaggerUi object.

  var spec = { ... };

  window.swaggerUi = new SwaggerUi({
    url: url,
    spec: spec,
    dom_id: "swagger-ui-container",
    supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
    onComplete: function(swaggerApi, swaggerUi){
    ...


The url parameter will be ignored in this case.

Eventually, the output looks like this:



I was able to do it this way alright, but as you can see on image attached below for each params it created dropdown:


What I want to achieve is nice Model/Model Schema tabs as on on image below with available enums listed for parameter. Is this possible in latest version of Swagger: