Skip to content

Generates structs with *any fields for "anyOf": [{ "type": "string" }, { "type": "null" }] query params #16

Description

@antifuchs

I'm noticing a few structs in the openapi definition from #15 being generated that are unusable: The fields have *any member types, which I haven't found a way to construct a value for, yet.

One schema in the openapi json from #15 that seems to trigger that is:

            "schema": {
              "anyOf": [{ "type": "string" }, { "type": "null" }],
              "title": "Search"
            }

This results in a struct like:

type GetAllAPIRecipesGetParams struct {
	Categories           *any            `json:"categories,omitempty"`
	Tags                 *any            `json:"tags,omitempty"`
	Tools                *any            `json:"tools,omitempty"`
	Foods                *any            `json:"foods,omitempty"`
	Households           *any            `json:"households,omitempty"`
	OrderBy              *any            `json:"orderBy,omitempty"`
	OrderByNullPosition  *any            `json:"orderByNullPosition,omitempty"`
	OrderDirection       *OrderDirection `json:"orderDirection,omitempty"`
	QueryFilter          *any            `json:"queryFilter,omitempty"`
	PaginationSeed       *any            `json:"paginationSeed,omitempty"`
	Page                 *int64          `json:"page,omitempty"`
	PerPage              *int64          `json:"perPage,omitempty"`
	Cookbook             *any            `json:"cookbook,omitempty"`
	RequireAllCategories *bool           `json:"requireAllCategories,omitempty"`
	RequireAllTags       *bool           `json:"requireAllTags,omitempty"`
	RequireAllTools      *bool           `json:"requireAllTools,omitempty"`
	RequireAllFoods      *bool           `json:"requireAllFoods,omitempty"`
	Search               *any            `json:"search,omitempty"`
	AcceptLanguage       *any            `json:"accept-language,omitempty"`
}

...seems not ideal - I would expect *string here, given the schema.

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