haizhou-zhao opened a new issue, #6798: URL: https://github.com/apache/iceberg/issues/6798
### Query engine _No response_ ### Question ## **Summary** I attempted to use open api generator (jaxrs-spec) to generate java api&service code using the provided Iceberg Rest Catalog OpenAPI spec provided [here](https://github.com/apache/iceberg/blob/master/open-api/rest-catalog-open-api.yaml). I spotted some potential misusage of "**oneof**" key word in the API yaml definition that produced undesired result in the generated java code, therefore I want to raise a question to see if there's anything I did incorrectly. ## **Details** ### Background: 1. Tools I'm using: OpenAPI generator cli version: 6.3.0 2. Section concerned in the API definition: [#/components/schemas/Type](https://github.com/apache/iceberg/blob/master/open-api/rest-catalog-open-api.yaml#L1068) 3. Java Model generated by OpenAPI generator: https://github.com/haizhou-zhao/test-iceberg-rest-jaxrs/blob/master/src/gen/java/org/openapitools/model/Type.java ### What went wrong: Java code generated successfully. Yet the generated code is very different from the original Type API in Iceberg: [ref](https://github.com/apache/iceberg/blob/master/api/src/main/java/org/apache/iceberg/types/Type.java). My guess is that the original intention is to generate code using inheritance (polymorphism) like `MapType extends Type` , but OpenAPI generated code is closer to a Uber class (composition) like ``` class Type { MapType mapType; StructType structType; ListType listType; ... } ``` ### Question: Am I correct assuming that that the original intention was to define a polymorphic (instead of composite) relationship between `Type` and `{MapType, StructType, ListType}`? ### Further thoughts If we want polymorphism instead of composition, then instead of this definition (the current version) ``` Type: oneOf: - $ref: '#/components/schemas/PrimitiveType' - $ref: '#/components/schemas/StructType' - $ref: '#/components/schemas/ListType' - $ref: '#/components/schemas/MapType' ``` the following definition might be better ``` Type: discriminator: propertyName: typeId type: object properties: typeId: type: string example: - "string" - "boolean" - "integer" - ... NestedType: allOf: - $ref: '#/components/schemas/Type' MapType: allOf: - $ref: '#/components/schemas/NestedType' - type: object properties: keyField: type: $ref: '#/components/schemas/NestedField' valueField: type: $ref: '#/components/schemas/NestedField' ... ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org