{"id":15091157,"url":"https://github.com/ueno-toshihiro/react-use-openapi","last_synced_at":"2026-01-05T04:48:56.017Z","repository":{"id":250102257,"uuid":"833468048","full_name":"ueno-toshihiro/react-use-openapi","owner":"ueno-toshihiro","description":"OpenAPI仕様のjson schemaからOrvalで型、カスタムフックス、モックAPIを作成しReactで表示する","archived":false,"fork":false,"pushed_at":"2024-07-29T06:58:50.000Z","size":451,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-27T10:29:37.057Z","etag":null,"topics":["material-ui","openapi","orval","react","react-query","swagger","typescript","zustand"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ueno-toshihiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-25T05:51:17.000Z","updated_at":"2024-07-29T06:58:53.000Z","dependencies_parsed_at":"2024-10-14T05:01:49.203Z","dependency_job_id":"79c36979-d7a7-42d0-bd4f-e5952fee7a77","html_url":"https://github.com/ueno-toshihiro/react-use-openapi","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"69bf4fd57d3e7b80a9cfdebfd2ade30656af69c0"},"previous_names":["ueno-toshihiro/react-use-openapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ueno-toshihiro%2Freact-use-openapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ueno-toshihiro%2Freact-use-openapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ueno-toshihiro%2Freact-use-openapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ueno-toshihiro%2Freact-use-openapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ueno-toshihiro","download_url":"https://codeload.github.com/ueno-toshihiro/react-use-openapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244945596,"owners_count":20536295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["material-ui","openapi","orval","react","react-query","swagger","typescript","zustand"],"created_at":"2024-09-25T10:36:01.154Z","updated_at":"2026-01-05T04:48:55.973Z","avatar_url":"https://github.com/ueno-toshihiro.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React-Orval-ReactQuery-Zustand-Example\nReact状態管理ライブラリと、OpenAPIを使ったAPIクライアントの実装例です。\nAPIリクエストにはモックサーバーを使っています。\n\n## 概要\nOrvalで生成されたカスタムフックのReact Queryでサーバーデータの状態を管理し、Zustandでアプリケーションの状態を管理することでシンプルながらも柔軟な状態管理を実現しています。\n利点：\n- React QueryでAPIリクエストをキャッシュすることで、データの再取得を最小限に抑えることができます。\n- Zustandでアプリケーションの状態を管理することで、コンポーネント間の状態共有が容易になります。\n\n## アプリ起動方法\n- node version は v22.0.0 以上を使用してください。\n\n- Orvalをグローバルインストールします。（schema を変更しない場合はすでに型情報、クライアントAPIとカスタムフック、モックを生成しているため不要です）\n```\nnpm i -g orval\n```\n- schemaを変更した場合は、以下のコマンドでクライアントAPI、カスタムフック、モックを生成します。\n```\norval\n```\n\n- 依存ライブラリをインストールします。\n```\nnpm i\n\n```\n\n- アプリケーションを起動します。\n```\nnpm run start\n```\n\n## デモ\nhttps://github.com/user-attachments/assets/52754b2e-0522-495c-994a-497867c66c77\n\n\n## 使い方\n1. Orvalでクライアントコードを生成します。\n2. 生成したコードをReactアプリケーションに組み込みます。\n3. React状態管理ライブラリを使って、APIクライアントを利用します。\n\n## ライブラリ\n- Orval: OpenAPI Generatorのラッパーライブラリ\n  - [orval](https://orval.dev/)\n- APIクライアント:\n  - [axios](https://axios-http.com/)\n- モックサーバー:\n  - [MSW](https://mswjs.io/)\n- React状態管理ライブラリ:\n  - [Zustand](https://zustand-demo.pmnd.rs/)\n  - [React Query](https://tanstack.com/query/v3)\n- UIライブラリ:\n  - [Material UI](https://material-ui.com/)\n\n## アプリケーション詳細\n- OpenAPI仕様のschemaをOrvalによりクライアントコードに生成します。\n- Orvalで生成したコードは、型情報と、APIクライアントの関数、モックサーバーの設定を含みます。\n- APIクライアントの関数は、axiosを使ってAPIリクエストを送信しモックサーバー（MSW）からのレスポンスが返ります。また、APIリクエストは**React-Query**を使ってキャッシュします。\n- ⭐️ Reactコンポーネントでは、Orvalで生成されたカスタムフックを使うことでAPIリクエストとキャッシュを同時に行なっています。\n- ⭐️ **Zustand**でReactコンポーネント間の状態を共有しています。\n\n🚀 MEMO: Gitコミットメッセージで段階的にライブラリを追加、設定しているので、コミットログを参照してください。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fueno-toshihiro%2Freact-use-openapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fueno-toshihiro%2Freact-use-openapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fueno-toshihiro%2Freact-use-openapi/lists"}