[Bug]: Cannot target java LocalDateTime via type mappings
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Reproduce el problema con la especificación OpenAPI 3.1 proporcionada y los typeMappings e importMappings mostrados mediante el plugin de Maven. Empieza rastreando el manejo de palabras reservadas del generador de Java para los tipos asignados; se considera terminado cuando el código generado usa java.time.LocalDateTime en lugar de ModelLocalDateTime y compila.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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 https://github.com/OpenAPITools/openapi-generator/pull/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.
- Lenguaje dominante
- Mustache
- Estrellas
- 17.8k
- Forks
- 6k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de swagger-api/swagger-codegen
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
swagger-api/swagger-codegen#12755 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
swagger-api/swagger-codegen#12445 ·
-
security vulnerability
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
swagger-api/swagger-codegen#11942 ·
-
[JAVA] Non compilable enums generated with property errorOnUnknownEnum=truePosiblemente ocupada @HiagoW la tomó hace 1457 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
swagger-api/swagger-codegen#11812 · 1 reacción ·
-
security vulnerability
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
swagger-api/swagger-codegen#11594 ·
Todos los issues de swagger-api/swagger-codegen
Issues similares
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 82/100
SublimeText/LaTeXTools#1717 ·
-
A helper package that registers two plugins (LSP-R) is not applied to the window after a live installPosiblemente ocupada @rchl la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
sublimelsp/LSP#3074 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Do not throw `WordPress.Security.EscapeOutput.OutputNotEscaped` on `apply_shortcodes()`Posiblemente ocupada @tbradsha la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
fsprojects/Paket#4455 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
nuxt-modules/better-auth#578 · 2 comentarios ·
Los mantenedores suelen responder en 1 día