Wie ändere ich den Typ für nur ein Feld mit dem OpenAPI-Generator-Maven-Plugin?Java

Java-Forum
Anonymous
 Wie ändere ich den Typ für nur ein Feld mit dem OpenAPI-Generator-Maven-Plugin?

Post by Anonymous »

Ich habe ein Schema, das die Daten beschreibt, die ich aus dem REST -Service bekomme. Ich kann dieses Schema nicht ändern. Es gibt zwei Datumszeit-Felder in dem Schema mit einem anderen Format:

Code: Select all

"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
Felder eingeben:

Code: Select all

    @JsonProperty("date1")
private OffsetDateTime date1;

@JsonProperty("date2")
private OffsetDateTime date2;
< /code>
With typeMappings
und importMappings Ich kann OffsetDatetime durch localDatetime ersetzen:

Code: Select all

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
nur?
Das möchte ich in der generierten Klasse sehen:
@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.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post