swaggest / openapi-go

OpenAPI structures for Go
https://pkg.go.dev/github.com/swaggest/openapi-go/openapi3
MIT License
259 stars 23 forks source link

How to use custom x- tags in a schema #58

Closed tpl996 closed 4 months ago

tpl996 commented 1 year ago

If a schema like

components: schemas: CreateSomethingRequest: type: object required:

was required, how can this x-oapi-codegen-extra-tags field be specified?

vearutop commented 1 year ago

Types that allow custom extensions (x-), usually have a WithMapOfAnythingItem method available (like this).

tpl996 commented 1 year ago

perfect - thank you for the prompt response

RPGillespie6 commented 5 months ago

For openapi31 operations you would do:

oc, err := reflector.NewOperationContext(http.MethodGet, "/api/v4/endpoint/{id}")
oc.(openapi31.OperationExposer).Operation().WithMapOfAnythingItem("x-api-name", "getEndpointByID")