Grouping endpoints by api versioning and then for their tags
- Dominant language
- No language data
- Stars
- 68
- Forks
- 8
- Avg merge
- 11h 2m
- Merged PRs (30d)
- 2
Description
## 💬 How to achieve endpoint grouping by version and then their tags?
I'd like my routes to be shown in swagger like this:
`/v1/routeA`
`/v1/routeB`
```
-- v1
|--- routeA
|--- routeB
```
`/v2/routeA`
`/v2/routeB`
```
-- v2
|--- routeA
|--- routeB
|--- routeC
```
This has somewhat been answered with this [PR](https://github.com/fastify/fastify-swagger/issues/732).
I tried the following code:
``` javascript
fastify.register(fastifySwagger, {
openapi: {
//some configs
},
transform: ({ schema, url, route, openapiObject }) => {
schema.tags = [route.prefix];
return schema;
},
});
```
The best I could achieve with this code was an auto-mapping of the endpoints based on their routes, it ended up like this:
```
--- /v1/routeA
--- /v1/routeB
--- /v2/routeA
--- /v2/routeB
--- /v2/routeC
```
But that's not exactly what I wanted. I need to group them by api version spec like this:
```
-- v1
|--- routeA
|--- routeB
-- v2
|--- routeA
|--- routeB
|--- routeC
```
Anyone has any idea on how to achieve this?
## My Environment
- *node version*: 18.11.0
- *fastify version*: 4.23.2
- *os*: Windows
- *fastify/swagger version*: 8.8.0
- *fastify/swagger-ui version*: 1.9.2
Contributor guide
Assessment
This issue has not been assessed yet.