OpenAPITools / OpenAPITools/openapi-generator
[BUG] Seeing a string assigned to an object type.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I'm seeing the following error:
/Users/kevin.regan/src/kmsOpenAPIJavaClient/kmsOpenAPIBaseJavaClient/src/main/java/com/salesforce/sds/kms/client/kmsOpenAPIJavaClient/model/ExternalKeySpecDetails.java:61: error: incompatible types: String cannot be converted to EkmType
this.ekmType = this.getClass().getSimpleName();
The ExternalKeySpecDetails class:
@ApiModel(description = "Ekm Type")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ExternalKeySpecDetails {
public static final String SERIALIZED_NAME_EKM_TYPE = "ekmType";
@SerializedName(SERIALIZED_NAME_EKM_TYPE)
protected EkmType ekmType;
public ExternalKeySpecDetails() {
this.ekmType = this.getClass().getSimpleName();
}
public ExternalKeySpecDetails ekmType(EkmType ekmType) {
this.ekmType = ekmType;
return this;
}
...
The EkmType class:
@JsonAdapter(EkmType.Adapter.class)
public enum EkmType {
AWS_KMS("AWS_KMS");
private String value;
EkmType(String value) {
this.value = value;
}
...
openapi-generator version
6.2.1
OpenAPI declaration file content or url
ExternalKeySpecDetails:
type: object
properties:
ekmType:
$ref: '#/components/schemas/EkmType'
description: Ekm Type
discriminator:
propertyName: ekmType
mapping:
AWS_KMS: '#/components/schemas/AwsKmsExternalKeySpec
EkmType:
type: string
description: "Ekm type [Beta, Not generally available]"
enum:
- AWS_KMS
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing Java client generation from the supplied ExternalKeySpecDetails and EkmType OpenAPI schemas, then inspect the generated ExternalKeySpecDetails.java constructor and discriminator handling. Done means the generated Java client compiles without assigning the class name String to the EkmType field; add a focused regression test if the generator test location is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100