Repository navigation
Open
Description
Created from quarkiverse/quarkus-openapi-generator#876 (reply in thread) discussion.
Having the followin OpenAPI:
issue.json
{
"openapi": "3.0.3",
"info": {
"title": "Example API",
"version": "1.0.0"
},
"paths": {
"/v1/inventory": {
"get": {
"tags": ["InventoriesResource"],
"summary": "Retrieve inventories",
"responses": {
"200": {
"description": "A list of inventories",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "inv-123"
},
"name": {
"type": "string",
"example": "Main warehouse"
},
"quantity": {
"type": "integer",
"example": 100
}
}
}
}
}
}
}
}
}
},
"/v1/permissions/inventories": {
"get": {
"tags": ["PermissionsResource"],
"summary": "Retrieve permissions",
"responses": {
"200": {
"description": "A list of inventory permissions",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"userId": {
"type": "string",
"example": "user-456"
},
"inventoryId": {
"type": "string",
"example": "inv-123"
},
"permission": {
"type": "string",
"example": "READ"
}
}
}
}
}
}
}
}
}
}
}
}The apicurio-codegen looks the first part of the path /v1 and create a resource called V1Resource instead creating V1PermissionsInventories.
I think it would be great if the apicurio-codegen generates per path and not per path prefix.
cc: @EricWittmann
Metadata
Metadata
Assignees
Labels
No labels
Activity
mathecruz commentedon May 21, 2025
Investigation notes:
/widget-namesis generatingWidgetResource, should not be/WidgetNamesResource?aservedio-swi commentedon May 21, 2025
Cross posting quarkiverse/quarkus-openapi-generator#876 (reply in thread) a bit... To summarize, when faced with this same issue,
org.openapitools:openapi-generator-maven-pluginwould generate a class that matches the name of the tag - but does not prefix it with V1. I believe that the thinking around that is to allow people to gather together like API's into a single implementation with a name that makes sense to them (since they could technically have /v1 and /v2 paths in the same implementation if that is what worked for them).So it is the presence of tags AND the generator being told to use tags that alters this behavior. Without both of those things, it just makes a V1Api.java interface and puts everything under that (which, frankly, is probably not what most people would want).
EricWittmann commentedon May 21, 2025
I agree that V1Resource is not desired. We probably need a lot of work in this area to handle all the different ways that endpoints could be defined and resulting JAX-RS interfaces should be structured.
In this case, one thing you can do right now is this:
https://github.com/Apicurio/apicurio-registry/blob/main/common/src/main/resources/META-INF/openapi.json#L3510
If you add that vendor extension to the
paths, then you can remove the/v1from all of the endpoints and the generator will createPermissionsInventoriesResource(in this example).Of course, if you have a mix of endpoints (some
/v1and others/v2for example) then this does not help.Having that would seem weird to me (better to have two OpenAPI definitions, one for each API version) but I'm sure it happens.