-
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-1765] Add client generation & Plugin system (#16)
* [IDP-1765] Add client generation & Plugin system * Add changeset * update ts * Update TypeScript everywhere * update lockfile * make test less flaky * Remove prompts * Modify changeset * Remove packageManager field * Add string constants * update lockfile * PR changes
- Loading branch information
Showing
40 changed files
with
1,641 additions
and
1,011 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 | ||
--- | ||
|
||
[BREAKING] `outfile` option is now `outdir` |
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,6 @@ | ||
--- | ||
"@workleap/create-schemas": minor | ||
--- | ||
|
||
Add `openapiFetchPlugin` plugin for client generation (requires `openapi-fetch` | ||
package) |
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 a new plugin system |
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 |
---|---|---|
|
@@ -38,4 +38,4 @@ yarn-error.log* | |
.idea | ||
|
||
# project | ||
dist | ||
dist |
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,8 @@ | ||
import { defineConfig } from "@workleap/create-schemas"; | ||
import { openapiFetchPlugin } from "@workleap/create-schemas/plugins"; | ||
|
||
export default defineConfig({ | ||
input: "v1.yaml", | ||
outdir: "src/codegen/v1", | ||
plugins: [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,16 +1,12 @@ | ||
{ | ||
"name": "debug", | ||
"type": "module", | ||
"private": true, | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"run": "create-schemas args1 args2" | ||
"dev": "create-schemas" | ||
}, | ||
"devDependencies": { | ||
"@workleap/create-schemas": "workspace:*" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
"dependencies": { | ||
"@workleap/create-schemas": "workspace:*", | ||
"openapi-fetch": "^0.10.2" | ||
} | ||
} |
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,14 @@ | ||
import { createClient } from "./codegen/v1/client.ts"; | ||
|
||
const client = createClient({ baseUrl: "https://api.example.com" }); | ||
|
||
const { data, error } = await client.GET("/good-vibes-points/{userId}", { params: { path: { userId: "123" } } }); | ||
|
||
if (error) { | ||
console.error(error.title); | ||
console.error(error.detail); | ||
} | ||
|
||
if (data?.point) { | ||
console.log(`You have ${data.point} good vibes points!`); | ||
} |
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 @@ | ||
/** Do not modify. This file has been generated by @workleap/create-schemas */ | ||
import type { paths } from "./types.ts"; | ||
import _createClient from "openapi-fetch"; | ||
|
||
export const createClient = _createClient as typeof _createClient<paths, "application/json">; |
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,62 +1,62 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: OfficeVice.GoodVibe.WebApi | ||
version: '1.0' | ||
title: OfficeVice.GoodVibe.WebApi | ||
version: "1.0" | ||
paths: | ||
/good-vibes-points/{userId}: | ||
get: | ||
tags: | ||
- GoodVibesBank | ||
summary: Get the current number of good vibe for a user | ||
operationId: GetGoodVibesPoint | ||
parameters: | ||
- name: userId | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
responses: | ||
'200': | ||
description: Success | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/GetGoodVibePointsResult' | ||
'400': | ||
description: Bad Request | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ProblemDetails' | ||
/good-vibes-points/{userId}: | ||
get: | ||
tags: | ||
- GoodVibesBank | ||
summary: Get the current number of good vibe for a user | ||
operationId: GetGoodVibesPoint | ||
parameters: | ||
- name: userId | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
responses: | ||
"200": | ||
description: Success | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/GetGoodVibePointsResult" | ||
"400": | ||
description: Bad Request | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/ProblemDetails" | ||
components: | ||
schemas: | ||
GetGoodVibePointsResult: | ||
required: | ||
- point | ||
type: object | ||
properties: | ||
point: | ||
type: integer | ||
format: int32 | ||
additionalProperties: false | ||
ProblemDetails: | ||
type: object | ||
properties: | ||
type: | ||
type: string | ||
nullable: true | ||
title: | ||
type: string | ||
nullable: true | ||
status: | ||
type: integer | ||
format: int32 | ||
nullable: true | ||
detail: | ||
type: string | ||
nullable: true | ||
instance: | ||
type: string | ||
nullable: true | ||
additionalProperties: { } | ||
schemas: | ||
GetGoodVibePointsResult: | ||
required: | ||
- point | ||
type: object | ||
properties: | ||
point: | ||
type: integer | ||
format: int32 | ||
additionalProperties: false | ||
ProblemDetails: | ||
type: object | ||
properties: | ||
type: | ||
type: string | ||
nullable: true | ||
title: | ||
type: string | ||
nullable: true | ||
status: | ||
type: integer | ||
format: int32 | ||
nullable: true | ||
detail: | ||
type: string | ||
nullable: true | ||
instance: | ||
type: string | ||
nullable: true | ||
additionalProperties: {} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.