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

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

Closed
tpl996 opened this issue Feb 20, 2023 · 3 comments
Closed

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

tpl996 opened this issue Feb 20, 2023 · 3 comments

Comments

@tpl996
Copy link

tpl996 commented Feb 20, 2023

If a schema like

components:
schemas:
CreateSomethingRequest:
type: object
required:
- something
properties:
something:
type: number
example: 1
x-oapi-codegen-extra-tags:
validate: gte=0

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

@vearutop
Copy link
Member

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

@tpl996
Copy link
Author

tpl996 commented Feb 20, 2023

perfect - thank you for the prompt response

@RPGillespie6
Copy link

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")

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

3 participants