Skip to content

error with required properties when unmarshalling nullable sub-objects #181

@christophbrejla

Description

@christophbrejla

I am trying to call the endpoint /api/ipam/prefixes/ like

	ctx, cancel := context.WithTimeout(context.Background(), longRequestTimeout)
	defer cancel()
	// we get all prefixes where the CIDR of this server is contained
	prRest, _, err := c.IpamAPI.IpamPrefixesList(ctx).Limit(200).Contains(serverCidr).Execute()
	if err != nil {
		return nil, nil, err
	}

and i am getting the error "no value given for required property prefix_count".

I found out that this comes from the Objects "Role" or "Vrf" in

type Prefix struct {
	Id      int32           `json:"id"`
	Url     string          `json:"url"`
	Display string          `json:"display"`
	Family  AggregateFamily `json:"family"`
	Prefix  string          `json:"prefix"`
	Site    NullableSite    `json:"site,omitempty"`
	Vrf     NullableVRF     `json:"vrf,omitempty"`
	Tenant  NullableTenant  `json:"tenant,omitempty"`
	Vlan    NullableVLAN    `json:"vlan,omitempty"`
	Status  *PrefixStatus   `json:"status,omitempty"`
	Role    NullableRole    `json:"role,omitempty"`
	// All IP addresses within this prefix are considered usable
	IsPool *bool `json:"is_pool,omitempty"`
	// Treat as fully utilized
	MarkUtilized         *bool                  `json:"mark_utilized,omitempty"`
	Description          *string                `json:"description,omitempty"`
	Comments             *string                `json:"comments,omitempty"`
	Tags                 []NestedTag            `json:"tags,omitempty"`
	CustomFields         map[string]interface{} `json:"custom_fields,omitempty"`
	Created              NullableTime           `json:"created,omitempty"`
	LastUpdated          NullableTime           `json:"last_updated,omitempty"`
	Children             int32                  `json:"children"`
	Depth                int32                  `json:"_depth"`
	AdditionalProperties map[string]interface{}
}

In my case, the endpoint delivers "null" for those objects. However the unmarshalling seems to not consider the "null" value and still does the validation for required properties for the "NullableRole" or "NullableVRF".

Can the validation/marshalling be fixed somehow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions