Open alansartorio opened 3 months ago
Alias schema for format: date-time causes compilation error in generated java code.
format: date-time
0.31.7
fernapi/fern-java-spring 0.9.0
OpenAPI specification required to reproduce the bug:
openapi: 3.1.0 info: version: 1.0.0 title: Example servers: - url: http://api.example.xyz/v1 paths: components: schemas: Timestamp: type: string format: date-time description: ISO representation of a Timestamp example: 20-10-2020T23:59:59
The buggy SDK that is produced:
/** * This file was auto-generated by Fern from our API Definition. */ package types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import java.lang.Object; import java.lang.String; import java.time.OffsetDateTime; public final class Timestamp { private final OffsetDateTime value; private Timestamp(OffsetDateTime value) { this.value = value; } ... @JsonCreator( mode = JsonCreator.Mode.DELEGATING ) public static Timestamp of(OffsetDateTime value) { return new Timestamp(value); } public static Timestamp valueOf(String value) { return of(value); } }
Notice the method valueOf calling of(...) with a string argument.
valueOf
of(...)
The expected SDK
... public static Timestamp valueOf(String value) { return of(OffsetDateTime.parse(value)); } }
I think this bug comes from here: https://github.com/fern-api/fern/blob/d8575c97610b96e58a2858dc386ad61b8af55d9d/generators/java/generator-utils/src/main/java/com/fern/java/generators/AliasGenerator.java#L168
Describe the Bug
Alias schema for
format: date-time
causes compilation error in generated java code.Information to Reproduce
CLI Version
0.31.7
Generator Version
fernapi/fern-java-spring 0.9.0
API Definition
OpenAPI specification required to reproduce the bug:
Actual SDK
The buggy SDK that is produced:
Notice the method
valueOf
callingof(...)
with a string argument.Expected SDK
The expected SDK
I think this bug comes from here: https://github.com/fern-api/fern/blob/d8575c97610b96e58a2858dc386ad61b8af55d9d/generators/java/generator-utils/src/main/java/com/fern/java/generators/AliasGenerator.java#L168