Как изменить тип только для одного поля, используя OpenAPI-Generator-Maven-Plugin?JAVA

Программисты JAVA общаются здесь
Anonymous
Как изменить тип только для одного поля, используя OpenAPI-Generator-Maven-Plugin?

Сообщение Anonymous »

У меня есть схема, которая описывает данные, которые я получаю от службы отдыха. Я не могу изменить эту схему. В схеме есть два поля даты типа, которые имеют другой формат:

Код: Выделить всё

"date1": {
"type": "string",
"description": "Date 1",
"format": "date-time"
},
"date2": {
"type": "string",
"description": "Date 2",
"format": "date-time"
}
< /code>
{
"date1": "2021-07-29T03:00:00",
"date2": "2021-04-22T08:25:30.264Z"
}
< /code>
By default, the open api-generator-maven-plugin creates the OffsetDateTime type for date-time
Поля Type:

Код: Выделить всё

    @JsonProperty("date1")
private OffsetDateTime date1;

@JsonProperty("date2")
private OffsetDateTime date2;
< /code>
With typeMappings
и importmappings Я могу заменить offsetDateTime на LocalDateTime:

Код: Выделить всё

OffsetDateTime=LocalDateTime


java.time.OffsetDateTime=java.time.LocalDateTime

< /code>
But this replacement will happen for all fields:
    @JsonProperty("date1")
private LocalDateTime date1;

@JsonProperty("date2")
private LocalDateTime date2;
< /code>
Is there a way to replace OffsetDateTime with LocalDateTime for date1
только? @JsonProperty("date1")
private LocalDateTime date1;

@JsonProperty("date2")
private OffsetDateTime date2;
< /code>
I understand that I can fix the generated class and replace OffsetDateTime with LocalDateTime, but I don't want to change the generated class every time after generation.
Thanks in advance.

Подробнее здесь: https://stackoverflow.com/questions/698 ... maven-plug

Вернуться в «JAVA»