Skip to content

Definition builder fails reference on generic struct #109

Description

@tlyons-cs

Given a struct created with generics the swagger doc compiles correctly but will fail to reference the definition correctly.

Example:

type Response[T any] struct{
  MetaData MetaData `json:"meta"`
  Objects []T `json:"objects"
}

type MyObject struct{
  Foo string `json:"foo"`
  Bar int `json:"bar"`
}

Passing in a variable of type module.Response[module.MyObject]{} will yield a definition for module.Response[module.MyObject] as well as module.MyObject. But the reference to this definition will use the key #/definitions/module.Response%5Bmodule.MyObject%5D.

The proposed change would be to sanitize the definition keys to be [->%5B and ] ->%5D

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions