-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
Using typeMappings I cannot specify a class with in-built support due to reserved word checking.
The OpenAPI specification defined "date-time" as a format value for strings, but that allows anything in ISO-8601. I want to declare in my spec whether it should be local date-time (no suffix), Zulu (Z suffix), or offer (+-nnnn suffix)
I am trying to do this with the following type mappings
typeMappings:
string+date-time-local: LocalDateTime
string+date: LocalDate
string+time: LocalTime
string+date-time-duration: Duration
string+date-period: Period
string+date-time-zoned: ZonedDateTime
string+date-time-offset: OffsetDateTime
string+timestamp: Instant
importMappings:
LocalDateTime: 'java.time.LocalDateTime'
LocalDate: 'java.time.LocalDate'
LocalTime: 'java.time.LocalTime'
ZonedDateTime: 'java.time.ZonedDateTime'
OffsetDateTime: 'java.time.OffsetDateTime'
Instant: 'java.time.Instant'
Duration: 'java.time.Duration'
Period: 'java.time.Period'
"LocalDate" is treated as a reserved word to avoid conflict between a spec declaring a model of that name and the java.time classes. I do not want to declare anything new but instead actually use the standard java.time classes.
When doing this, I receive this warning [WARNING] LocalDate (reserved word) cannot be used as model name. Renamed to ModelLocalDate, and it generates code using ModelLocalDate. I cannot see any obvious way of achieving what I need to do,.
Swagger Codegen Version
7.13.0 (via maven plugin)
Language / Generator
Java
OpenAPI/Swagger Spec
openapi: 3.1.0
info:
title: Example
version: 1.0.0
paths:
/example:
post:
summary: example
operationId: example
parameters:
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Example"
components:
schemas:
Example:
type: object
properties:
localDate:
type: string
format: date-time-local
Steps to Reproduce
Attempt to generate the above OpenAPI specification using the type mappings above.
Expected Behaviour
Code is generated which utilised java.time.LocalDateTime
Actual Behavior
Code is generated using ModelLocalDateTime, which does not compile
Related
This would appear to be related to the changes in OpenAPITools/openapi-generator#16276
Checklist
- I have searched the existing issues to make sure this is not a duplicate.
- I have included a minimal and reproducible spec example.
- I have explained how to reproduce the issue.
- I have specified which generator/language is affected.