-
Notifications
You must be signed in to change notification settings - Fork 1
[IDP-1765] Add client generation & Plugin system #16
New issue
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b4e48a7
[IDP-1765] Add client generation & Plugin system
tjosepo 39b9855
Add changeset
tjosepo c093757
update ts
tjosepo caf9d0b
Update TypeScript everywhere
tjosepo 44b1fbe
update lockfile
tjosepo 76e5b4a
make test less flaky
tjosepo 4c406b3
Remove prompts
tjosepo 1ca0d65
Modify changeset
tjosepo 21081c8
Remove packageManager field
tjosepo de88d0c
Add string constants
tjosepo abe13b6
update lockfile
tjosepo 2df9bcb
PR changes
tjosepo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.