-
Notifications
You must be signed in to change notification settings - Fork 1
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: create and generate template from template data for teams #238
feat: create and generate template from template data for teams #238
Conversation
return use | ||
return strcase.ToKebab(op.OperationID) | ||
|
||
// TODO: work with operation ID & response type to stripe out resource name and update post -> create, get -> list, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment in main description - going to bring this back in but for now, to remove duplicate subcommands, using just the OperationId
func jsonString(s string) string { | ||
bs, _ := json.Marshal(s) | ||
return string(bs) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have all kinds of markdown stuff in the descriptions of resources and endpoints that was causing the template to throw errors - marshaling to json and returning that string to help!
@@ -29,6 +29,7 @@ type TemplateData struct { | |||
|
|||
type ResourceData struct { | |||
Name string | |||
DisplayName string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can also pass in functions to the template to handle converting these values from camel/kebab, which I might do in a refactor
"strings" | ||
|
||
"github.com/getkin/kin-openapi/openapi3" | ||
"github.com/iancoleman/strcase" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hoping it's ok to use this (..stripe does 🙃)
cmd/resources/resource_cmds.tmpl
Outdated
) | ||
{{ end }} | ||
|
||
// Operation commands{{ range $resName, $resData := .Resources }}{{ range $opName, $opData := $resData.Operations }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you break these range calls out into separate lines to more easily see the nesting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it'll add an extra line between then comment and the following commands which bothers me only very slightly 🙃
Continuing to work just with the teams data in the OpenAPI spec, generate a template based on the template data to add resource commands to the root command.
Note that the subcommands are based off of the spec's
operationId
(e.g.get-team
andpost-team
vsget
andcreate
) and the flags for each subcommand are based off the param values (e.g.team-key
andproject-key
vsteam
andproject
). I plan to update this is in the next PR where we add the remaining resources from the openapi spec.running
teams --help
running
teams get-team --help
checking that required flags are set: