Ask Your Question
0

How can I conceal parameters in the request body according to the schema in Swagger?

asked 2023-05-03 17:08:31 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-03 17:28:02 +0000

pufferfish gravatar image

You can use the "x-ms-examples" extension in your Swagger schema to provide examples of requests and responses that would be accepted by your API. This will help to clarify which parameters are required, optional, and which may be concealed.

For example, you could specify that a certain parameter should be concealed by providing an example that shows a request body with the parameter value replaced by a placeholder, such as "*". This would indicate to clients that the value of this parameter should not be visible in the request body.

Here's an example of how this could be done:

paths:
  /example:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                parameter1:
                  type: string
                parameter2:
                  type: string
                  example: "*****"
                  x-ms-examples:
                    mask:
                      value:
                        parameter1: "value1"
                        parameter2: "value2"
                    unmask:
                      value:
                        parameter1: "value1"
                        parameter2: "value2"

In this example, the "parameter2" property is specified to be concealed, as indicated by the "example" and "x-ms-examples" properties. This would allow clients to make requests without revealing sensitive parameter values in the request body.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-03 17:08:31 +0000

Seen: 11 times

Last updated: May 03 '23