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

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

Open
christophbrejla opened this issue Jul 25, 2024 · 0 comments

Comments

@christophbrejla
Copy link

christophbrejla commented Jul 25, 2024

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?

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

1 participant