OpenAPITools / OpenAPITools/openapi-generator
[JAVA] schema type named "Date" uses wrong date class
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
If a data type in the OpenAPI specification is called Date, the code generator doesn't generate the type correctly.
openapi-generator version
5.0.0 (worked fine in 4.2.3, but not in 4.3.1)
OpenAPI declaration file content or url
This document:
openapi: 3.0.2
info:
title: ''
version: 1.0
paths:
/foo:
get:
responses:
200:
$ref: '#/components/responses/get'
components:
responses:
get:
description: ''
content:
application/json:
schema:
type: object
properties:
myDate:
$ref: '#/components/schemas/Date'
schemas:
Date:
description: ''
type: string
format: date
generates the following code, using generator=jaxrs-cxf and dateLibrary=java8:
@ApiModelProperty(value = "")
@Valid
private java.util.Date myDate;
What it should output instead is:
@ApiModelProperty(value = "")
@Valid
private java.time.LocalDate myDate;
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
No source file or test is named in the issue. Start by reproducing the supplied OpenAPI 3.0.2 document with the jaxrs-cxf generator and dateLibrary=java8, then trace how the Date schema and date format are mapped. Done means the generated myDate field uses java.time.LocalDate rather than java.util.Date, with a regression test if the relevant test area is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100