Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5436
Closed
Open
Issue created Feb 25, 2020 by Administrator@rootContributor

[BUG] [JAVA | Spring] Dates are not annotated on param model

Created by: zalito12

Description

Date and datetime are correctly annotated in query params but when you use a model as query param the model date and datetime properties are not correctly annotated so it cannot recognize format.

openapi-generator version

openapi-generator-maven-plugin 4.2.2

OpenAPI declaration file content or url
openapi: 3.0.0
servers:
  - url: 'localhost:8080'
info:
  version: 1.0.0
  title: OpenAPI Zoo
  license:
    name: Apache-2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
paths:
  /zebras:
    get:
      operationId: getZebras
      parameters:
        - in: query
          name: limit
          schema:
            type: number
        - $ref: '#/components/parameters/SearchParams'
components:
  parameters:
    SearchParams:
      name: animalParams
      description: Search animal grouped parameters
      in: query
      style: form
      explode: true
      schema:
        $ref: '#/components/schemas/AnimalParams'
  schemas:
    AnimalParams:
      type: object
      properties:
        born:
          type: string
          format: date
          example: '2019-12-01'
        lastSeen:
          type: string
          format: date-time
          example: '2020-02-22T10:30:00.000'
        status:
          type: integer
          enum: [0,1]
          default: 0
        name:
          type: string
          example: 'Marty'
        age:
          type: integer
          example: 15
Command line used for generation
<configOptions>
  <dateLibrary>java8-localdatetime</dateLibrary>
</configOptions>
Steps to reproduce

Use maven plugin to generate the api, will create a model file AnimalParams.java, that file will have all parameters, included date and date-time ones, but this two parameters won't be annotated with @DateTimeFormat so it will crash when reading query parameters.

Related issues/PRs

#2053 (closed) #5389

Suggest a fix

Working on a fix to add annotations on pojo template for Spring.

Assignee
Assign to
Time tracking