swagger-api / swagger-api/swagger-ui
Can we add a component or a section to add buissness or technical error for the API ?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
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 :</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 :

### 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing how Swagger UI renders OpenAPI response descriptions, especially the HTML table currently embedded in the response description. Determine whether the requested business and technical error-code component belongs in the OpenAPI definition or in Swagger UI, then define the supported input and rendered result before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- documentation, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100