Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we add a component or a section to add buissness or technical error for the API ? #9882

Open
e2rabi opened this issue Apr 26, 2024 · 2 comments

Comments

@e2rabi
Copy link

e2rabi commented Apr 26, 2024

Content & configuration

I use the swagger-ui to document my APIs , I have to add the business error codes that those APIs return in response ,I see that is not part of the openApi specification so I did an alternative solution based on the tag "description" in the yaml file.

OpenAPI definition:

                application/xml:
                 schema:
                   $ref: '#/components/schemas/GetProductDetailsV35Rq'
           responses:  
             200:
               description:
                       <div>
                               Successful
                               <p>Business Error Codes &#58;</p>
                               <table>
                                     <tr>
                                       <th>Error code</th>
                                       <th>Error Description</th>
                                     </tr>
                                     <tr>
                                       <td>31101</td>	
                                       <td>Invalid Catalog Product Id</td>
                                     </tr>
                                     <tr>
                                       <td>31102</td>	
                                       <td>Invalid Catalog Product version</td>
                                     </tr>
                                      <tr>
                                        <td>31103</td>	
                                        <td>Catalog Product Pack Code</td>
                                     </tr>
                               </table>
                       </div> 

### Describe the solution you'd like
I added the table of error codes using the "description" tag in the yaml ,this is rendered as : 
![test](https://github.com/swagger-api/swagger-ui/assets/16072199/0bd7c09c-bdf0-4461-bd0f-8b169ade6b8d)

### Describe alternatives you've considered
 I'm asking if we can add a component that we can use it to display the error codes without use the yaml "description" tag
@e2rabi
Copy link
Author

e2rabi commented Apr 26, 2024

The error code display :
test

@e2rabi e2rabi changed the title Can we add a component of a section to add buissness or technical error for the API ? Can we add a component or a section to add buissness or technical error for the API ? Apr 26, 2024
@DineshDeshal
Copy link

Hello e2rabi , can i take this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants