Skip to content
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

Open API Specification #90

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.gen.ts
generated/
27 changes: 27 additions & 0 deletions frontend/generated/$api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Methods as Methods_1lgtes2 } from './ping';
import type { AspidaClient, BasicHeaders } from 'aspida';

const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
const prefix = (baseURL === undefined ? 'https://localhost:3000/api' : baseURL).replace(/\/$/, '');
const PATH0 = '/ping';
const GET = 'GET';

return {
ping: {
/**
* @returns success
*/
get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods_1lgtes2['get']['resBody'], BasicHeaders, Methods_1lgtes2['get']['status']>(prefix, PATH0, GET, option).json(),
/**
* @returns success
*/
$get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods_1lgtes2['get']['resBody'], BasicHeaders, Methods_1lgtes2['get']['status']>(prefix, PATH0, GET, option).json().then(r => r.body),
$path: () => `${prefix}${PATH0}`,
},
};
};

export type ApiInstance = ReturnType<typeof api>;
export default api;
4 changes: 4 additions & 0 deletions frontend/generated/@types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable */
export type Ping = {
text?: string | undefined
}
10 changes: 10 additions & 0 deletions frontend/generated/ping/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */
import type * as Types from '../@types'

export type Methods = {
get: {
status: 200
/** success */
resBody: Types.Ping
}
}
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"packageManager": "[email protected]+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a",
"type": "module",
"scripts": {
"generate-apis": "rm -rf generated/ && pnpx openapi2aspida -i ../openapi/api.yaml -o ./generated/ && pnpm eslint generated/** --fix --ext ts",
"generate-routes": "tsr generate",
"generate-html-template": "pnpm exec tsx --tsconfig tsconfig.app.json --import=./scripts/ignore-assets-loader/register.js scripts/generate-template-html.js",
"watch-routes": "tsr watch",
Expand All @@ -20,6 +21,7 @@
"@phosphor-icons/react": "^2.1.7",
"@tanstack/react-router": "^1.43.3",
"@tanstack/router-devtools": "^1.43.3",
"aspida": "^1.14.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand Down
62 changes: 62 additions & 0 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions openapi/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
openapi: 3.1.0
info:
version: 0.0.1
title: Frost API Definition - OpenAPI 3.1
description: |-
Frost API Definition

- [Frost repository](https://github.com/frost-community/frost)
servers:
- url: https://localhost:3000/api
tags:
- name: status
description: status
paths:
/ping:
get:
tags:
- status
summary: ping
description: ""
operationId: ping
parameters:
- name: text
description: "そのまま返す(optional)"
schema:
type: string
responses:
"200":
description: success
content:
application/json:
schema:
$ref: "#/components/schemas/Ping"
components:
schemas:
Ping:
type: object
properties:
text:
type: string
examples: ["hello mrhc!", "hello!"]