rapi-doc / RapiDoc

RapiDoc -WebComponent for OpenAPI Spec
https://rapidocweb.com
MIT License
1.71k stars 285 forks source link

Introduce the way to fill example values in the headers #1008

Closed Kieun closed 2 months ago

Kieun commented 7 months ago

Currently, if the OAS has a example properties for the headers, RapiDoc populate such examples in the header input field by default.

It would be better for the way not to fill examples in the header like the feature for the request fields: fill-request-fields-with-example.

mrin9 commented 2 months ago

fill-request-fields-with-example applies to all the request parameters which includes query , path, header, request-body and cookie

If you like to avoid filling some of the parameters with example then on the tag level set fill-request-fields-with-example=true like <rapi-doc id="thedoc" spec-url = "./specs/temp.yaml" fill-request-fields-with-example = "true"></rapi-doc>

and then within your spec use the vendor-extension x-fill-example where for certain request params you can set it to no like below

openapi: 3.0.1
paths:
  /api/login:
    post:
      summary: Login with secret
      parameters:
        - name: name
          in: query
          description: FulName
          example: John Doe
          schema:
            type: string
        - name: age
          in: query
          description: age (in years)
          example: 30
          schema:
            type: integer
        - name: x-api-key
          in: header
          example: my-secret
          x-fill-example:     # <<< vendor-extension
            no
          schema:
            type: string
      responses:
        '201':
          description: A user was successfully authenticated.