K997
K997

Reputation: 479

Create hidden or unchangeable parameter to my API in Swagger-UI?

I need to either:

A) Create a hidden parameter that is passed with every call generated from my Swagger-UI interface to my API (i.e. ?test=true)

OR

B) Expose the 'test' parameter in the UI but set it to true by default and NOT allow a change to this.

How can either of these be accomplished from within Swagger-UI ?

Upvotes: 1

Views: 1837

Answers (1)

user6683818
user6683818

Reputation:

Forced UI to have "test" as true using enum and required true; Only forced if type integer or string. Boolean will auto-list true and false to the dropdown

YAML :

  parameters:
    - name: test
      description: Test environment
      required: true
      type: string
      in: query
      enum:
        - True

Json:

 "name":"test",
 "description": "Test environment",
 "required": true,
 "type":"string",
 "in":"query",
 "enum":["true"]

Upvotes: 3

Related Questions