Repository navigation
fix(core) handle mismatching discriminatorType in oneOf interfaces - #24812
Conversation
merge master
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Was able to repeat the issues locally and confirmed this PR addresses the issue |
|
@jpfinne @wing328 this has not been released yet, but appears to break compilation in my project (currently using 7.25.0) when I tried using the …
import io.jenkins.plugins.cursor_origin_branch_source.origin_openapi.model.Enum; // ←
…
/**
* Gets or Sets bypassMode
*/
public enum BypassModeEnum {
RULESET_BYPASS_MODE_UNSPECIFIED(Enum.valueOf("RULESET_BYPASS_MODE_UNSPECIFIED")),
ALWAYS(Enum.valueOf("always")),
PULL_REQUEST_ONLY(Enum.valueOf("pull_request_only"));
private Enum value;
BypassModeEnum(Enum value) {
this.value = value;
}
@JsonValue
public Enum getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static BypassModeEnum fromValue(Enum value) {
for (BypassModeEnum b : BypassModeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
…If I comment out the noted |
|
The change was targeted towards the issue where a The change then attempted to make the parent carry an components:
schemas:
Pet:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
discriminator:
propertyName: type
mapping:
CAT: '#/components/schemas/Cat'
DOG: '#/components/schemas/Dog'
Cat:
description: A representation of a cat
type: object
properties:
type:
type: string
const: CAT
huntingSkill:
type: string
required:
- type
- huntingSkill
Dog:
description: A representation of a dog
type: object
properties:
type:
type: string
const: DOG
packSize:
type: integer
format: int32
required:
- type
- packSizeA reduced specification that would include your broken class and any related schemas (e.g., any |
|
I am afraid I did not really follow any of that, and I did not write the specification, I am just consuming it. All I know is that the project compiles under 7.25.0, and fails to compile as of this PR. |
|
It does not matter whether you have written the specification or not. It is needed since it is helpful for reproducing and verifying the issue. |
|
@jglick No need for the full specification. Try to give evidence with the smallest subset possible |
|
Tried to do so in #24950. I hope that is legible; I really know nothing about OpenAPI. |
fix #24769, fix #19194
Improve resolution of
DefaultCodegen.getDiscriminatorTypeby resolving the best common type in all mapped discriminators.Matching $ref types are used. Otherwise the types
enum,integer,string,objectare used.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.
Summary by cubic
Fixes #24769 and #19194 by inferring Java
oneOfdiscriminator getter types from all mapped schemas instead of defaulting toObject. Constant string discriminators now generateEnumgetters, while Kotlin keeps its existing string behavior.$refandallOfschemas.StringorObjectfallbacks when no common type exists; Java gains anenummapping toEnum.Written for commit 93051c9. Summary will update on new commits.