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

Auto generate zodios client from openapi spec #2

Merged
merged 5 commits into from
May 29, 2024

Conversation

vucinatim
Copy link
Member

PR description 🔨

Added script and commands for generating a zodios client from open api spec.
See:

  • ./scripts/zodios-client-template.hbs for adjusting the template
  • package.json for the "gen-api" command
  • src/env.ts for validating the NEXT_PUBLIC_API_URL var when added to the project.

Author checklist ✅

  • 🎫 PR has been linked to Jira ticket
  • ⌛ Time has been tracked in Jira

Copy link

vercel bot commented May 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextjs-template ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2024 0:56am

@@ -13,7 +13,8 @@
"format:fix": "prettier --write --ignore-path .prettierignore .",
"test": "jest",
"test:watch": "jest --watch",
"i18n": "tsx ./scripts/validate-translations.ts"
"i18n": "tsx ./scripts/validate-translations.ts",
"gen-api": "infisical run --command 'openapi-zod-client \"$NEXT_PUBLIC_API_URL/docs/bundle.yml\" -o './src/zodios/inedx.ts' -t ./scripts/zodios-client-template.hbs' && prettier --write ./src/zodios/inedx.ts"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"gen-api": "infisical run --command 'openapi-zod-client \"$NEXT_PUBLIC_API_URL/docs/bundle.yml\" -o './src/zodios/inedx.ts' -t ./scripts/zodios-client-template.hbs' && prettier --write ./src/zodios/inedx.ts"
"gen-api": "infisical run --command 'openapi-zod-client \"$NEXT_PUBLIC_API_URL/docs/bundle.yml\" -o './src/zodios/index.ts' -t ./scripts/zodios-client-template.hbs' && prettier --write ./src/zodios/index.ts"

@@ -69,6 +69,8 @@ Getting started with this Next.js template is straightforward. Follow these step
- [zod](https://zod.dev/) for form validation
- [Zodios](https://www.zodios.org/docs/client) for external API calls with validation
- Github Actions for lint, typecheck, localizations checks and tests.
- [openapi-zod-client](https://www.npmjs.com/package/openapi-zod-client) for generating API clients
- We include a handlebars template for generating the zodios client from the openapi spec. It can be used with `pnpm gen-api` command.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- We include a handlebars template for generating the zodios client from the openapi spec. It can be used with `pnpm gen-api` command.
- We include a handlebars template for generating the zodios client from the openapi spec. It can be used with `pnpm gen-api` command.
- Adjust the `gen-api` command in [package.json](package.json) to fetch the OpenAPI `yaml` file from the correct URL.

@vucinatim vucinatim merged commit 40ec3fb into master May 29, 2024
10 checks passed
@vucinatim vucinatim deleted the feat-zodios-from-openapi branch May 29, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants