Skip to content

Commit

Permalink
Fix openapi cli
Browse files Browse the repository at this point in the history
  • Loading branch information
spinillos committed Oct 3, 2023
1 parent 9007b2f commit a30ad5d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/cli/generate/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func Command() *cobra.Command {
cmd.Flags().StringArrayVar(&opts.KindsysComposableEntrypoints, "kindsys-composable", nil, "Kindys composable kinds input schema.") // TODO: better usage text
cmd.Flags().StringArrayVar(&opts.KindsysCustomEntrypoints, "kindsys-custom", nil, "Kindys custom kinds input schema.") // TODO: better usage text
cmd.Flags().StringArrayVar(&opts.JSONSchemaEntrypoints, "jsonschema", nil, "Jsonschema input schema.") // TODO: better usage text
cmd.Flags().StringArrayVar(&opts.OpenApiEntrypoints, "openapi", nil, "Openapi input schema.") // TODO: better usage text

cmd.Flags().StringArrayVarP(&opts.CueImports, "include-cue-import", "I", nil, "Specify an additional library import directory. Format: [path]:[import]. Example: '../grafana/common-library:github.com/grafana/grafana/packages/grafana-schema/src/common")

Expand All @@ -44,6 +45,7 @@ func Command() *cobra.Command {
_ = cmd.MarkFlagDirname("kindsys-custom")
_ = cmd.MarkFlagDirname("jsonschema")
_ = cmd.MarkFlagDirname("output")
_ = cmd.MarkFlagDirname("openapi")

return cmd
}
Expand Down
1 change: 1 addition & 0 deletions cmd/cli/inspect/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func Command() *cobra.Command {
cmd.Flags().StringArrayVar(&opts.LoaderOptions.KindsysComposableEntrypoints, "kindsys-composable", nil, "Kindys composable kinds input schema.") // TODO: better usage text
cmd.Flags().StringArrayVar(&opts.LoaderOptions.KindsysCustomEntrypoints, "kindsys-custom", nil, "Kindys custom kinds input schema.") // TODO: better usage text
cmd.Flags().StringArrayVar(&opts.LoaderOptions.JSONSchemaEntrypoints, "jsonschema", nil, "Jsonschema input schema.") // TODO: better usage text
cmd.Flags().StringArrayVar(&opts.LoaderOptions.OpenApiEntrypoints, "openapi", nil, "Openapi input schema.") // TODO: better usage text

cmd.Flags().StringArrayVarP(&opts.LoaderOptions.CueImports, "include-cue-import", "I", nil, "Specify an additional library import directory. Format: [path]:[import]. Example: '../grafana/common-library:github.com/grafana/grafana/packages/grafana-schema/src/common")

Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/loaders/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

func openapiLoader(opts Options) ([]*ast.File, error) {
allSchemas := make([]*ast.File, 0, len(opts.Entrypoints))
for _, entrypoint := range opts.Entrypoints {
allSchemas := make([]*ast.File, 0, len(opts.OpenApiEntrypoints))
for _, entrypoint := range opts.OpenApiEntrypoints {
pkg := filepath.Base(filepath.Dir(entrypoint))
schemaAst, err := openapi.GenerateAST(entrypoint, openapi.Config{
Package: pkg,
Expand Down
3 changes: 3 additions & 0 deletions cmd/cli/loaders/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
KindsysComposable LoaderRef = "kindsys-composable"
KindsysCustom LoaderRef = "kindsys-custom"
JSONSchema LoaderRef = "jsonschema"
OpenAPI LoaderRef = "openapi"
)

func loadersMap() map[LoaderRef]Loader {
Expand All @@ -24,6 +25,7 @@ func loadersMap() map[LoaderRef]Loader {
KindsysComposable: kindsysCompopsableLoader,
KindsysCustom: kindsysCustomLoader,
JSONSchema: jsonschemaLoader,
OpenAPI: openapiLoader,
}
}

Expand All @@ -40,6 +42,7 @@ type Options struct {
KindsysComposableEntrypoints []string
KindsysCustomEntrypoints []string
JSONSchemaEntrypoints []string
OpenApiEntrypoints []string

Check failure on line 45 in cmd/cli/loaders/options.go

View workflow job for this annotation

GitHub Actions / Linters

var-naming: struct field OpenApiEntrypoints should be OpenAPIEntrypoints (revive)

// Cue-specific options
CueImports []string
Expand Down

0 comments on commit a30ad5d

Please sign in to comment.