You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using @rtk-query/codegen-openapi, we would like to automatically set providesTags and invalidatesTags for endpoints based on a custom OpenAPI extension we've added to our spec on operations.
I know of the existing tag option, but our existing OpenAPI spec uses tags to define much broader set of operations, so instead we would like to define an additional property for tags.
For example, if we have the following spec:
"/pets":
get:
operationId: getPets
responses: ...
summary: Get a list of all adopted pets
tags:
- unrelated-broader-tag
+ x-rtk-provides-tags: pet
post:
operationId: adoptPet
requestBody:
content: ...
required: true
x-originalParamName: body
responses: ...
summary: Adopts a new pet
tags:
- unrelated-broader-tag
+ x-rtk-invalidates-tags: pet
And I would like to configure @rtk-query/codegen-openapi with something like
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using
@rtk-query/codegen-openapi, we would like to automatically setprovidesTagsandinvalidatesTagsfor endpoints based on a custom OpenAPI extension we've added to our spec on operations.I know of the existing
tagoption, but our existing OpenAPI spec uses tags to define much broader set of operations, so instead we would like to define an additional property for tags.For example, if we have the following spec:
"/pets": get: operationId: getPets responses: ... summary: Get a list of all adopted pets tags: - unrelated-broader-tag + x-rtk-provides-tags: pet post: operationId: adoptPet requestBody: content: ... required: true x-originalParamName: body responses: ... summary: Adopts a new pet tags: - unrelated-broader-tag + x-rtk-invalidates-tags: petAnd I would like to configure
@rtk-query/codegen-openapiwith something likeconst config: ConfigFile = { schemaFile: './openapi3.json', apiFile: './baseAPI.ts', apiImport: 'baseAPI', hooks: true, + tag: { + provides: 'x-rtk-provides-tags', + invalidates: 'x-rtk-invalidates-tags', + } };to generate something like
import { baseAPI as api } from './baseAPI'; const injectedRtkApi = api.injectEndpoints({ endpoints: (build) => ({ getPets: build.query<GetPetsApiResponse, GetPetsApiArg>({ query: () => ({ url: `/pets` }), + providesTags: ['pet'], }), adoptPet: build.mutation<AdoptPetApiResponse, AdoptPetApiArg>({ query: (queryArg) => ({ url: `/pets`, method: 'POST', body: queryArg }), + invalidatesTags: ['pet'], }),If it would be accepted, I would be happy to contribute this in a PR.
Beta Was this translation helpful? Give feedback.
All reactions