swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Add "required" text after asterisk on response elements

Open trimble opened this issue 2 years ago • 1 comments

Content & configuration

Swagger/OpenAPI definition:

  '/pet/{petId}':
   get:
     tags:
       - pet
     summary: Find pet by ID
     description: Returns a single pet
     operationId: getPetById
     parameters:
       - name: petId
         in: path
         description: ID of pet to return
         required: true
         schema:
           type: integer
           format: int64
     responses:
       '200':
         description: successful operation
         content:
           application/xml:
             schema:
               $ref: '#/components/schemas/Pet'
           application/json:
             schema:
               $ref: '#/components/schemas/Pet'
...
   Pet:
     x-swagger-router-model: io.swagger.petstore.model.Pet
     required:
       - name
       - photoUrls
     properties:
       id:
         type: integer
         format: int64
         example: 10
       name:
         type: string
         example: doggie
       category:
         $ref: '#/components/schemas/Category'
       photoUrls:
         type: array
         xml:
           wrapped: true
         items:
           type: string
           xml:
             name: photoUrl
       tags:
         type: array
         xml:
           wrapped: true
         items:
           $ref: '#/components/schemas/Tag'
           xml:
             name: tag
       status:
         type: string
         description: pet status in the store
         enum:
           - available
           - pending
           - sold
     xml:
       name: pet
     type: object

image

Is your feature request related to a problem?

It is not clear that the red asterisk on response body elements indicates a required element. The asterisk in the parameter section also includes the word "required" to make this more explicit.

Describe the solution you'd like

Add the following to swagger-ui.css: .swagger-ui table.model tr.property-row.required td:first-child:after { font-size: 10px; position: relative; top: -3px; padding: 2px; content: "required"; color: rgba(255,0,0,.6) }

image

Describe alternatives you've considered

Additional context

trimble avatar Dec 21 '23 17:12 trimble

Hi @trimble I was going through the petstore sample server and tested the GET method and got the JSON response:

image

I am not sure if you want a "required" keyword in a JSON response body. Can you tell about the problem a bit more? Thanks!

Rebooting-Me avatar Feb 08 '24 20:02 Rebooting-Me