Skip to content

[BUG][jaxrs-reasteasy-eap] Generated Bean Validation annotations for Longs are invalid #5658

@dommaes

Description

@dommaes

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • What's the version of OpenAPI Generator used?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • Bounty to sponsor the fix
Description

jaxrs-resteasy-eap generates invalid Bean Validation annotations for properties of the following type:

type: integer
format: int64
maximum: 9999999999

which are represented as Longs in generated Java code.

The generated Bean Validation annotation is @Max(9999999999) and the project doesn't compile, because 9999999999 is greater than Integer.MAX_VALUE.
The generated annotation should be @Max(9999999999L).

openapi-generator version

4.2.3, 4.3.0-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  version: 1.0.0
  title: OpenAPI Petstore
paths:
  /pet/{petId}:
    get:
      operationId: getPetById
      parameters:
        - name: petId
          in: path
          required: true
          schema:
            type: integer
            format: int64
            maximum: 9999999999
      responses:
        200:
          description: success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pet"
components:
  schemas:
    Pet:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
Command line used for generation

java -jar openapi-generator-cli.jar generate -g jaxrs-resteasy-eap -i sample.yaml -o sample

Steps to reproduce
  1. run command
  2. try to build the project with Maven
Related issues/PRs

No

Suggest a fix

Use files

  • beanValidation.mustache
  • beanValidationCore.mustache
  • beanValidationHeaderParams.mustache
  • beanValidationPathParams.mustache
  • beanValidationQueryParams.mustache

from jaxrs-resteasy

I will open a PR with the suggested fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions