OpenAPITools / OpenAPITools/openapi-generator
[REQ] JAXRS Jersey - should generate namespaces as folders
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
JaxRs Jersey code generation should support namespaces, and should generate the classes in folders.
Describe the solution you'd like
It is possible to define schema names in a dot-notation to specify a namespace.
/service/do/something:
post:
operationId: doSomething
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/my.namespace.or.package.Request'
...
schemas:
my.namespace.or.package.Request:
type: object
properties: ...
In this example the request body is defined as a request object with fully qualified name: my.namespace.or.package.Request. To respect this name and to handle it as a package, the code should generate a Request.java file which is stored in directory tree my/namespace/or/package.
Additionally, if a model package is specified during generation, it should be used as a prefix. e.g.
openapicodegen generate -i input.yml -g jaxrs-jersey -o dir --additional-properties=modelPackage=my.company.my.service.bo
In that case, the fully qualified name should be:
my.company.my.service.bo.my.namespace.or.package.Request
Describe alternatives you've considered
There are no alternatives as far as I know.
An alternative solution could be :
If there is another notation to specify packages, that could also work:
e.g. perhaps a new property, e.g. x-codegen-package
/service/do/something:
post:
operationId: doSomething
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Request'
...
schemas:
Request:
type: object
x-codegen-package: my.namespace.or.package
properties: ...
Additional context
Right now, the codegeneration just strips the dots from the fully qualified name.
i.e. creating class names like MyNamespaceOrPackageRequest . It dumps all class files within the same directory, which is of course not workable for big projects.
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 locating the JAX-RS Jersey generator entry point and its model-package handling. Reproduce the request with the shown schema names and modelPackage property, then trace how dotted schema names become Java class names and output paths. Done means generated models use namespace components as folders and preserve the configured package prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100