You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
I have a problem trying to generate the code for an api that have "oneOf" property. The generated code give me the following exception when I try to call one endpoint.
To Reproduce:
1 - Generate the code for the following api: Rarible api
2 - Try to make a call to xxx.api.ItemControllerApi.getAllItems(List.of(CustomEnum.ETHEREUM), null, 2, false, null, null);
Expected behavior:
Throw the following exception: org.springframework.web.client.RestClientException: Error while extracting response for type [class xxx.model.Items] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Could not resolve subtype of [simple type, class xxx.model.MetaContent]: missing type id property 'type' (for POJO property 'content'); nested exception is com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class xxx.model.MetaContent]: missing type id property 'type' (for POJO property 'content')
Conclusion:
I am almost shure that the problem is related with the @JsonTypeInfo annotation because when I change the property value from type to another thing like "@type" the exception change and says ...missing type id property '@type'
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
**property = "type"**)
@JsonSubTypes({
@JsonSubTypes.Type(value = RaribleMcImageContent.class, name = "RaribleMcImageContent"),
@JsonSubTypes.Type(value = RaribleMcVideoContent.class, name = "RaribleMcVideoContent"),
@JsonSubTypes.Type(value = RaribleMcAudioContent.class, name = "RaribleMcAudioContent"),
@JsonSubTypes.Type(value = RaribleMcModel3dContent.class, name = "RaribleMcModel3dContent")
})
public interface RaribleMcOneOfMetaContent {
}
jgarciasm
changed the title
Problem generating Java code with json properties containing "@" in name
Problem generating Java code with schema property "oneOf"
Apr 11, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have a problem trying to generate the code for an api that have "oneOf" property. The generated code give me the following exception when I try to call one endpoint.
To Reproduce:
1 - Generate the code for the following api: Rarible api
2 - Try to make a call to
xxx.api.ItemControllerApi.getAllItems(List.of(CustomEnum.ETHEREUM), null, 2, false, null, null);
Expected behavior:
Throw the following exception:
org.springframework.web.client.RestClientException: Error while extracting response for type [class xxx.model.Items] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Could not resolve subtype of [simple type, class xxx.model.MetaContent]: missing type id property 'type' (for POJO property 'content'); nested exception is com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class xxx.model.MetaContent]: missing type id property 'type' (for POJO property 'content')
Conclusion:
I am almost shure that the problem is related with the @JsonTypeInfo annotation because when I change the property value from type to another thing like "@type" the exception change and says ...missing type id property '@type'
Environment
Plugin version: 2.19.2
Swagger Codegen version: io.swagger.codegen.v3:swagger-codegen-cli:3.0.33
Gradle version: 7.4.1
Java version: Correto-17.0.2.8.1
OS: macOS Monterrey 12.3
The text was updated successfully, but these errors were encountered: