Skip to content

Query Parameters of type integer in format int64 seem to create a broken spring API #1226

@jbumueller

Description

@jbumueller
Description

Created a API Spec with a query parameter of type integer, with format int64 which results to Long in Java. Leads to a broken spring Api with thr following signature:

    default ResponseEntity<NotificationSummary> notifications(@ApiParam(value = "The maximum number of Records in the Result", defaultValue = "10l") @Valid @RequestParam(value = "maxResults", required = false, defaultValue="10l") Long maxResults) {

10l should be 10 instead, otherwise a numberFormatException occurs.

openapi-generator version

On the Master (3.3.0)

OpenAPI declaration file content or url
Command line used for generation
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \ 
-i .../basicspec.yml  \
-l spring --library spring-mvc \ 
o .../
Steps to reproduce
  • create a spec with the postet yaml
  • run the posted command
  • take a look to the generated code in org/openapitools/api/NotificationsApi.java
Suggest a fix/enhancement

Generate

    default ResponseEntity<NotificationSummary> notifications(@ApiParam(value = "The maximum number of Records in the Result", defaultValue = "10") @Valid @RequestParam(value = "maxResults", required = false, defaultValue="10") Long maxResults) {

instead of

    default ResponseEntity<NotificationSummary> notifications(@ApiParam(value = "The maximum number of Records in the Result", defaultValue = "10l") @Valid @RequestParam(value = "maxResults", required = false, defaultValue="10l") Long maxResults) {

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