Skip to content

@ServerVariable without allowed values not well rendered #3071

@blackat

Description

@blackat

Hello,
I have this description

@OpenAPIDefinition(
        info = @Info(
                title = "My Rest API",
                version = "1.0.0",
                description = "My RESTful API implementation"
        ),
        servers = {
                @Server(
                        description = "My REST API",
                        url = "/{context-path}/{rest-api}",
                        variables = {
                                @ServerVariable(name = "context-path", defaultValue = "my-war"),
                                @ServerVariable(name = "rest-api", defaultValue = "api", allowableValues = {"api", "rest", "batchapi"})
                        }
                )
        }
)

I use the swagger-maven-plugin version 2.0.6 to generate the JSON in open api 3.0 format.
I obtain this JSON

"servers" : [ {
    "url" : "/{context-path}/{rest-api}",
    "description" : "My REST API",
    "variables" : {
      "context-path" : {
        "default" : "my-war",
        "enum" : [ "" ]
      },
      "rest-api" : {
        "default" : "api",
        "enum" : [ "api", "rest", "batchapi" ]
      }
    }
  } ],

The problem is the empty "enum" : [ "" ] that in the swagger-ui is rendered as an empty dropdown. Without the empty enum there is an input field with the default value so it is possible to set a different context path.

Is there please a workaround?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions