OpenAPITools / OpenAPITools/openapi-generator
[BUG] Possible generation problem when using path parameters and useBeanValidation = true
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I am trying to generate java classes with Hibernate validations and the resulting code does not compile
openapi-generator version
5.4.0 - Maven
OpenAPI declaration file content or url
---
openapi: 3.0.0
info:
title: API
version: 1.0.0-SNAPSHOT
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
paths:
'/v1/categories/id/{id}':
delete:
tags:
- Category
summary: Delete category
description: Delete a single category by ID
operationId: deleteV1
parameters:
- $ref: '#/components/parameters/IdPathParam'
responses:
'200':
description: Deleted
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/Response'
'500':
description: Server problem wrapped in the Response object
content:
application/json:
schema:
$ref: '#/components/schemas/Response'
components:
parameters:
IdPathParam:
name: id
in: path
description: Category ID
required: true
schema:
type: integer
format: int64
schemas:
Response:
required:
- httpStatusCode
- sqmStatusCode
- message
type: object
properties:
httpStatusCode:
type: integer
format: int32
sqmStatusCode:
type: integer
format: int32
message:
type: string
Generation Details
<generatorName>java</generatorName>
<configOptions>
<dateLibrary>java8</dateLibrary>
<useBeanValidation>true</useBeanValidation>
</configOptions>
Steps to reproduce
Just have a simple configuration (use the options from above) and try to generate the code for the provided yaml.
For me, in the resulting CategoryApi, I get a method signature like so:
public ApiResponse deleteV1WithHttpInfo(@NotNullLong id) throws ApiException
Note the lack of space between the annotation and the variable type.
IF there is a workaround to remove those annotations from methods (but not model), that would work for me. I integrate this api with a Quarkus service and would like to use the hibernate validations for the model.
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 generating the Java client with the supplied YAML and Maven options, then inspect the generated CategoryApi method signature and the Java generator's parameter rendering entry point. Done means the generated method compiles with a space between @NotNull and Long, while model Bean Validation annotations remain enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100