-
Notifications
You must be signed in to change notification settings - Fork 802
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
feat(cmd/oapi-codegen): add flag to generate subset of code #7
Conversation
Does server or client imply types? For example, if I want only the server code, I would need both the types and the server, for the client, I would need the types and the client code. Maybe -generate can take a list, like --generate=types,client? This way, you can default it to types,server,client instead of "all"? |
@deepmap-marcinr Good call... I like the list. I'll make that change. Are you ok with client/server and types being split out? Should server and client imply types? |
Hmm, that's an interesting question. Certainly, the Client and Server interfaces should be split out, and any helper functions. So, if there's a RequestParams object for an operation, it will be needed in both the client and server. You know, as a first attempt, just to make the code simpler, just generate all types together, independent of the client/server functions. They might be useful in code that operates on those types, so better to err on the side of too much than too little. |
@deepmap-marcinr right on, ok |
@deepmap-marcinr agreed... current code gets my go spidey-sense tingling... too complicated. I'll switch it to a straight up split for sure. |
@deepmap-marcinr I've updated the CLI handling and did a small refactor of the server/client generation to use the options. The CLI parameter is now a comma delimited set of choices. Here is the error message with an unknown option: ./oapi-codegen -generate howdy swagger.yml
unknown generate option howdy
-generate string
Comma-separated list of code to generate; valid options: "client", "server" (default client,server) (default "client,server")
-package string
The package name for generated code |
Thank you. |
Hey @deepmap-marcinr , I wanted to get your feedback on how I did flags first before having the Generate code use them.
What do you think?
This adds a
-generate
option. It accepts,all
,server
,client
, andtypes
.By default it uses
all
.This is the output when an unknown option is passed: