Uh oh!
There was an error while loading. Please reload this page.
Properties with custom types inheritance fix - #18052
Conversation
wing328
commented
Mar 9, 2024
thanks for the PR cc @martin-mfg |
wing328
commented
Mar 21, 2024
@martin-mfg can you please review when you've time? thank you. |
Hi, just some additional results from my experiments, in case this PR is referenced again in the future:
|
dreambrother
commented
Apr 8, 2024
dreambrother
commented
Apr 23, 2024
Any updates? |
| // in openapi-generator, we also store type in `type` for 3.1 schema | ||
| // to make it backward compatible with the rest of the code base. | ||
| if (schema.getType() != null) { | ||
| clone.setType(schema.getType()); |
There was a problem hiding this comment.
looks like this logic is completely removed, right?
There was a problem hiding this comment.
SchemaUtils.cloneSchema must not lose a type info after clone (instead of AnnotationUtils), so yep, I've removed it :)
There was a problem hiding this comment.
👍
FYI. we've refactored the code a bit and no longer using type to store the actual type in 3.1 spec: #18577
| return schema; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
personally i prefer not having another class SchemaUtils just for cloneSchema?
can we merge this (or add this back) into model utils instead?
dreambrother
commented
May 14, 2024
Hi! Please notify me before merge, I'll resolve merge conflicts. |
wing328
commented
May 14, 2024
Can you please do so and PM me via Slack when done? |
dreambrother
commented
May 14, 2024
@wing328 sorry, I don't use slack. I've resolved merge conflicts. Had to add jackson-annotations dependency explicitly, because openapi-generator right now has different minor versions of jackson in dependencies (lower for jackson-datatype-threetenbp). |
| #' @param ... Other optional arguments. | ||
| #' @export | ||
| initialize = function(`id` = NULL, `outcomes` = [SUCCESS, FAILURE], `suffix` = NULL, `text` = NULL, `date` = NULL, ...) { | ||
| initialize = function(`id` = NULL, `outcomes` = ["SUCCESS","FAILURE"], `suffix` = NULL, `text` = NULL, `date` = NULL, ...) { |
There was a problem hiding this comment.
one more minor request if you don't mind. can you please add a test for the following schema:
outcomes:
type: array
items:
type: string
enum:
- SUCCESS
- FAILURE
- SKIPPED
default:
- SUCCESS
- FAILURE
to ensure the default values are clone correctly for string enum?
There was a problem hiding this comment.
sure! I've added ModelUtilsTest.testCloneArrayOfEnumsSchema
wing328
commented
May 15, 2024
fyi @OpenAPITools/generator-core-team |
wing328
commented
May 15, 2024
PR merged. Thanks again for the PR. |
wing328
commented
Jun 5, 2024
@dreambrother can you please take a look at the above exception when you've time? To repeat it, please run |
Approach to deep clone Schema's introduced in #16992 breaks support for properties with custom types (added using schemaMappings or type/importMappings) when such properties are inherited using allOf. AnnotationsUtils#clone returns null for them. I've replaced AnnotationsUtils#clone with ObjectMapper's typed serialization/deserialization.
@OpenAPITools/generator-core-team
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)