We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
rtk-query-codegen-openapi
Example OpenAPI schema:
{ "openapi": "3.0.0", "info": { "title": "Example" }, "paths": { "/Foo/{name}": { "delete": { "tags": [ "Foo" ], "operationId": "deleteFoo", "parameters": [], "requestBody": { "content": { "*/*": { "schema": { "$ref": "#/components/schemas/deleteOptions" } } } } }, "parameters": [ { "name": "name", "in": "path", "description": "name of the Foo", "required": true, "schema": { "type": "string", "uniqueItems": true } } ] } }, "components": { "schemas": { "deleteOptions": { "type": "object", "properties": { "apiVersion": { "type": "string" } } } } } }
According to the spec, request bodies are optional by default. But the generated types look like:
import { api } from './factory'; export const addTagTypes = ['Foo'] as const; const injectedRtkApi = api .enhanceEndpoints({ addTagTypes, }) .injectEndpoints({ endpoints: (build) => ({ deleteFoo: build.mutation<DeleteFooApiResponse, DeleteFooApiArg>({ query: (queryArg) => ({ url: `/Foo/${queryArg.name}`, method: 'DELETE', body: queryArg.deleteOptions }), invalidatesTags: ['Foo'], }), }), overrideExisting: false, }); export { injectedRtkApi as generatedApi }; export type DeleteFooApiResponse = unknown; export type DeleteFooApiArg = { name: string; deleteOptions: DeleteOptions; }; export type DeleteOptions = { apiVersion?: string; };
Note how deleteOptions is required instead of optional in the DeleteFooApiArg type.
deleteOptions
DeleteFooApiArg
Apologies in advance if I've misread the spec/misunderstood something here! 🙇
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Example OpenAPI schema:
According to the spec, request bodies are optional by default. But the generated types look like:
Note how
deleteOptions
is required instead of optional in theDeleteFooApiArg
type.Apologies in advance if I've misread the spec/misunderstood something here! 🙇
The text was updated successfully, but these errors were encountered: