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

Ability to generate client from openapi specification for build #631

Closed
dcdh opened this issue Jan 30, 2024 · 5 comments · Fixed by #633
Closed

Ability to generate client from openapi specification for build #631

dcdh opened this issue Jan 30, 2024 · 5 comments · Fixed by #633
Assignees
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@dcdh
Copy link
Member

dcdh commented Jan 30, 2024

Feature idea

Following this project https://github.com/dcdh/formula-interpreter/blob/master/pom.xml
the openapi-generator-maven-plugin is used to generate client in typescript based on openapi yaml file produce by the quarkus-smallrye-openapi dependency.

The build is done this way:

  1. build openapi yaml
  2. generate typescipt client using openapi-generator-maven-plugin at prepare-package phase
  3. Just after build the project using frontend-maven-plugin also at prepare-package phase

Regarding quinoa, building the openapi.yaml and the project is done in only one phase at build one. So I am not able generate my typescript client after openapi.yaml generation and before building the project.

So it will be nice if it was possible split the build into two: build for backend services and prepare-package for frontend one with the ability to do something between them (like code generation).

Regards,
Damien

Additional information

@dcdh dcdh added the feature label Jan 30, 2024
@dcdh dcdh changed the title Change the build goal of script to be able to generate code using openapi Be able to generate client from openapi specification for build Jan 30, 2024
@melloware
Copy link
Contributor

melloware commented Jan 30, 2024

I understand what you are saying. I use Orval to generate my TypeScript for React Query from OpenApi right now I have to do it as 2 steps. Generate the OpenApi JSON then I copy that to my webui and run npm run codegen

@dcdh
Copy link
Member Author

dcdh commented Feb 1, 2024

I am using it using this kind of configuration:

application.properties:

quarkus.smallrye-openapi.store-schema-directory=src/main/webui/
mp.openapi.extensions.smallrye.operationIdStrategy=METHOD

package.json

{
// ...
  "scripts": {
    "dev": "orval --config ./orval.config.ts && react-scripts start",
    "build": "orval --config ./orval.config.ts && react-scripts build",
    "test": "react-scripts test --env=jsdom"
  },
// ...
}

This way endpoints are generated add dev starting and build stages. No need to generate next copy to webui

@melloware
Copy link
Contributor

Wow this is awesome! Going to try it tomorrow!

@melloware
Copy link
Contributor

melloware commented Feb 2, 2024

@dcdh this is the life changing need i was looking for! I use Vite and Orval and do this and it works like a charm to autogenerate the TypeScript.

"scripts": {
	"format": "prettier --write \"{src,__tests__}/**/*.{ts,tsx}\"",
	"codegen": "orval && npm run format",
	"dev": "npm run codegen && vite",
	"build": "tsc && vite build",
},

@melloware melloware added documentation Improvements or additions to documentation and removed feature labels Feb 2, 2024
melloware added a commit to melloware/quarkus-quinoa that referenced this issue Feb 2, 2024
melloware added a commit to melloware/quarkus-quinoa that referenced this issue Feb 2, 2024
@melloware melloware added this to the 2.3.4 milestone Feb 2, 2024
@melloware melloware self-assigned this Feb 2, 2024
@melloware
Copy link
Contributor

@dcdh ok i am adding this to the docs for other people in the future.

@melloware melloware changed the title Be able to generate client from openapi specification for build Ability to generate client from openapi specification for build Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants