-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IDP-1768] Add experimental MSW plugin (#23)
* [IDP-1768] Add unstable MSW plugin * Add docs * Update docs, rename to experimental * update debug * PR comments * fix broken test
- Loading branch information
Showing
16 changed files
with
846 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@workleap/create-schemas": minor | ||
--- | ||
|
||
Add `experimental_openapiMSWPlugin` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@workleap/create-schemas": minor | ||
--- | ||
|
||
[BREAKING] Rename `openapiFetchPlugin` to `experimental_openapiFetchPlugin` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { defineConfig } from "@workleap/create-schemas"; | ||
import { openapiFetchPlugin } from "@workleap/create-schemas/plugins"; | ||
import { experimental_openapiFetchPlugin, experimental_openapiMSWPlugin } from "@workleap/create-schemas/plugins"; | ||
|
||
export default defineConfig({ | ||
input: "v1.yaml", | ||
outdir: "src/codegen/v1", | ||
plugins: [openapiFetchPlugin()] | ||
plugins: [experimental_openapiFetchPlugin(), experimental_openapiMSWPlugin()] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** This file has been generated by @workleap/create-schemas (https://github.com/gsoft-inc/wl-openapi-typescript). Do not modify manually. */ | ||
import type { paths } from "./types.ts"; | ||
import { createOpenApiHttp } from "openapi-msw"; | ||
|
||
export const http = createOpenApiHttp<paths>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export type { Plugin } from "./plugin.ts"; | ||
export { openapiFetchPlugin } from "./openapi-fetch-plugin.ts"; | ||
export { experimental_openapiFetchPlugin } from "./openapi-fetch-plugin.ts"; | ||
export { experimental_openapiMSWPlugin } from "./openapi-msw-plugin.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getRelativeModuleResolutionExtension } from "../utils.ts"; | ||
import { openapiTypeScriptId } from "./openapi-typescript-plugin.ts"; | ||
import type { Plugin } from "./plugin.ts"; | ||
|
||
export function experimental_openapiMSWPlugin(): Plugin { | ||
return { | ||
name: "openapi-msw-plugin", | ||
async transform({ id, emitFile }) { | ||
if (id !== openapiTypeScriptId) { | ||
return; | ||
} | ||
|
||
const importsFileExtension = getRelativeModuleResolutionExtension(); | ||
|
||
emitFile({ | ||
filename: "openapi-msw.ts", | ||
code: [ | ||
`import type { paths } from "./types${importsFileExtension}";`, | ||
"import { createOpenApiHttp } from \"openapi-msw\";\n", | ||
"export const http = createOpenApiHttp<paths>();" | ||
].join("\n") | ||
}); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.