Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GENERATOR ISSUE] Parse nullable option in additionalProperites #67

Open
LarsWl opened this issue Jan 30, 2024 · 1 comment
Open

[GENERATOR ISSUE] Parse nullable option in additionalProperites #67

LarsWl opened this issue Jan 30, 2024 · 1 comment

Comments

@LarsWl
Copy link

LarsWl commented Jan 30, 2024

Hi, I'm trying to generate julia client for hubspot api, and there is such a component:

"SimplePublicObjectWithAssociations": {
        "type": "object",
        "properties": {
          ...
          "properties": {
            "example": {
              "amount": "1500.00",
              "closedate": "2019-12-07T16:50:06.678Z",
              "hubspot_owner_id": "910901",
              "dealname": "Custom data integrations",
              "dealstage": "presentationscheduled",
              "pipeline": "default"
            },
            "additionalProperties": {
              "nullable": true,
              "type": "string"
            },
            "type": "object"
          },
      }
      ...
}

So openapi-generator generate such model:

Base.@kwdef mutable struct SimplePublicObjectWithAssociations <: OpenAPI.APIModel
    archivedAt::Union{Nothing, ZonedDateTime} = nothing
    archived::Union{Nothing, Bool} = nothing
    properties::Union{Nothing, Dict{String, String}} = nothing
    id::Union{Nothing, String} = nothing
    updatedAt::Union{Nothing, ZonedDateTime} = nothing
    associations::Union{Nothing, Dict} = nothing # spec type: Union{ Nothing, Dict{String, CollectionResponseAssociatedId} }
    createdAt::Union{Nothing, ZonedDateTime} = nothing
    propertiesWithHistory::Union{Nothing, Dict{String, Vector{ValueWithTimestamp}}} = nothing
#  ...
end

There is a field properties which is of type Dict{String,String}. So it processes the type field in additionalProperties to detect String, but it doesn't process the nullable field. So if I have a property with a null value, it throws an error on parsing. I was able to fix it by changing the type to Dict{String,Union{Nothing, String}}, so maybe there is a way to update generator to process the nullable option

Edit:
Full openapi_specification: https://api.hubspot.com/api-catalog-public/v1/apis/crm/v3/objects/deals

@tanmaykm
Copy link
Member

Okay... so it translates to being able to having a key in dict but with a value of nothing/missing?

Maybe something to be addressed here: https://github.com/OpenAPITools/openapi-generator/blob/2abcb4f7f0aa67c126304e43602ae72a83f2dca7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java#L347-L360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants