Skip to content

Commit 9e79156

Browse files
committed
Fix yaml parsing from URL test
1 parent aca2705 commit 9e79156

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

packages/rtk-query-codegen-openapi/test/__snapshots__/generateEndpoints.test.ts.snap

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,6 @@ exports[`yaml parsing should parse a yaml schema from a URL 1`] = `
772772
import { api } from './tmp/emptyApi';
773773
const injectedRtkApi = api.injectEndpoints({
774774
endpoints: (build) => ({
775-
getHealthcheck: build.query<GetHealthcheckApiResponse, GetHealthcheckApiArg>({
776-
query: () => ({ url: \`/healthcheck\` }),
777-
}),
778775
updatePet: build.mutation<UpdatePetApiResponse, UpdatePetApiArg>({
779776
query: (queryArg) => ({ url: \`/pet\`, method: 'PUT', body: queryArg.pet }),
780777
}),
@@ -883,11 +880,7 @@ const injectedRtkApi = api.injectEndpoints({
883880
}),
884881
overrideExisting: false,
885882
});
886-
export { injectedRtkApi as api };
887-
export type GetHealthcheckApiResponse = /** status 200 OK */ {
888-
message: string;
889-
};
890-
export type GetHealthcheckApiArg = void;
883+
export { injectedRtkApi as enhancedApi };
891884
export type UpdatePetApiResponse = /** status 200 Successful operation */ Pet;
892885
export type UpdatePetApiArg = {
893886
/** Update an existent pet in the store */
@@ -1029,7 +1022,6 @@ export type User = {
10291022
userStatus?: number;
10301023
};
10311024
export const {
1032-
useGetHealthcheckQuery,
10331025
useUpdatePetMutation,
10341026
useAddPetMutation,
10351027
useFindPetsByStatusQuery,
@@ -1049,6 +1041,6 @@ export const {
10491041
useGetUserByNameQuery,
10501042
useUpdateUserMutation,
10511043
useDeleteUserMutation,
1052-
} = enhancedApi;
1044+
} = injectedRtkApi;
10531045

10541046
`;

packages/rtk-query-codegen-openapi/test/fixtures/petstore.yaml.mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default `/
1+
export default `
22
openapi: 3.0.2
33
info:
44
title: Swagger Petstore - OpenAPI 3.0

packages/rtk-query-codegen-openapi/test/generateEndpoints.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ describe('import paths', () => {
150150
});
151151

152152
describe('yaml parsing', () => {
153-
it.skip('should parse a yaml schema from a URL', async () => {
154-
// TODO
153+
it('should parse a yaml schema from a URL', async () => {
155154
const result = await generateEndpoints({
156155
apiFile: './tmp/emptyApi.ts',
157156
schemaFile: `https://petstore3.swagger.io/api/v3/openapi.yaml`,

packages/rtk-query-codegen-openapi/test/mocks/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ export const server = setupServer(
1515
),
1616

1717
rest.get('https://petstore3.swagger.io/api/v3/openapi.json', (req, res, ctx) => res(ctx.json(petstoreJSON))),
18-
rest.get('https://petstore3.swagger.io/api/v3/openapi.yaml', (req, res, ctx) => res(ctx.json(petstoreYAML)))
18+
rest.get('https://petstore3.swagger.io/api/v3/openapi.yaml', (req, res, ctx) =>
19+
res(ctx.text(petstoreYAML), ctx.set('Content-Type', 'application/yaml'))
20+
)
1921
);

0 commit comments

Comments
 (0)