I have problem with /api-catalog-public/v1/apis/marketing/v3/forms .
I used Swagger Codegen to generate Java classes (OpenAPI Generator does not work, problem with StackOverflowError, circular dependencies).
I’m trying to call Accounts Dashboard | HubSpot “GET form definition” https://api.hubapi.com/marketing/v3/forms/{{formId}}
and deserialize it and there is a problem with Jackson (Spring Boot app):
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Could not resolve subtype of [simple type, class com.hubapi.api.model.forms.HubSpotFormDefinition]: missing type id property 'type'; nested exception is com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class com.hubapi.api.model.forms.HubSpotFormDefinition]: missing type id property 'type'
at [Source: (PushbackInputStream); line: 1, column: 4185]
And there is no property type in response from API. Why?
I think something wrong could be with generated class:
package com.hubapi.api.model.forms;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
/**
* OneOfFormDefinitionBase
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = HubSpotFormDefinition.class, name = "HubSpotFormDefinition")
})
public interface OneOfFormDefinitionBase {
}
BTW: What is this? It’s part of HubSpotFormDefinition definition in API.
"x-hubspot-java-type-name" : "com.hubspot.forms.external.core.models.forms.HubSpotFormDefinition",
"x-hubspot-external-project-origin" : false,
"x-hubspot-sub-type-impl" : true
The same problem is with:
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = EmailField.class, name = "EmailField"),
@JsonSubTypes.Type(value = PhoneField.class, name = "PhoneField"),
@JsonSubTypes.Type(value = MobilePhoneField.class, name = "MobilePhoneField"),
@JsonSubTypes.Type(value = SingleLineTextField.class, name = "SingleLineTextField"),
@JsonSubTypes.Type(value = MultiLineTextField.class, name = "MultiLineTextField"),
@JsonSubTypes.Type(value = NumberField.class, name = "NumberField"),
@JsonSubTypes.Type(value = SingleCheckboxField.class, name = "SingleCheckboxField"),
@JsonSubTypes.Type(value = MultipleCheckboxesField.class, name = "MultipleCheckboxesField"),
@JsonSubTypes.Type(value = DropdownField.class, name = "DropdownField"),
@JsonSubTypes.Type(value = RadioField.class, name = "RadioField"),
@JsonSubTypes.Type(value = DatepickerField.class, name = "DatepickerField"),
@JsonSubTypes.Type(value = FileField.class, name = "FileField")
})
public interface OneOfFieldGroupFieldsItems {
}
"fields" : {
"type" : "array",
"description" : "The form fields included in the group",
"items" : {
"oneOf" : [ {
"$ref" : "#/components/schemas/EmailField"
}, {
"$ref" : "#/components/schemas/PhoneField"
}, {
"$ref" : "#/components/schemas/MobilePhoneField"
}, {
"$ref" : "#/components/schemas/SingleLineTextField"
}, {
"$ref" : "#/components/schemas/MultiLineTextField"
}, {
"$ref" : "#/components/schemas/NumberField"
}, {
"$ref" : "#/components/schemas/SingleCheckboxField"
}, {
"$ref" : "#/components/schemas/MultipleCheckboxesField"
}, {
"$ref" : "#/components/schemas/DropdownField"
}, {
"$ref" : "#/components/schemas/RadioField"
}, {
"$ref" : "#/components/schemas/DatepickerField"
}, {
"$ref" : "#/components/schemas/FileField"
} ]
}
}
How does the deserializer can be aware of what type of field is receiving?
I would like to try the same with stable v2 FORMS API but I couldn’t fine OpenAPI link to contract and generate classes from it ![]()