refactor(cmd/api): thread swagger path through sdk spec builder
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
428552e58c
commit
b8fd020bb2
2 changed files with 7 additions and 3 deletions
|
|
@ -57,8 +57,7 @@ func addSDKCommand(parent *cli.Command) {
|
|||
|
||||
// If no spec file provided, generate one to a temp file.
|
||||
if specFile == "" {
|
||||
builder := sdkSpecBuilder(title, description, version, graphqlPath, graphqlPlayground, ssePath, wsPath, pprofEnabled, expvarEnabled, termsURL, contactName, contactURL, contactEmail, licenseName, licenseURL, externalDocsDescription, externalDocsURL, servers)
|
||||
builder.SwaggerPath = swaggerPath
|
||||
builder := sdkSpecBuilder(title, description, version, swaggerPath, graphqlPath, graphqlPlayground, ssePath, wsPath, pprofEnabled, expvarEnabled, termsURL, contactName, contactURL, contactEmail, licenseName, licenseURL, externalDocsDescription, externalDocsURL, servers)
|
||||
groups := sdkSpecGroupsIter()
|
||||
|
||||
tmpFile, err := os.CreateTemp("", "openapi-*.json")
|
||||
|
|
@ -127,11 +126,12 @@ func addSDKCommand(parent *cli.Command) {
|
|||
parent.AddCommand(cmd)
|
||||
}
|
||||
|
||||
func sdkSpecBuilder(title, description, version, graphqlPath string, graphqlPlayground bool, ssePath, wsPath string, pprofEnabled, expvarEnabled bool, termsURL, contactName, contactURL, contactEmail, licenseName, licenseURL, externalDocsDescription, externalDocsURL, servers string) *goapi.SpecBuilder {
|
||||
func sdkSpecBuilder(title, description, version, swaggerPath, graphqlPath string, graphqlPlayground bool, ssePath, wsPath string, pprofEnabled, expvarEnabled bool, termsURL, contactName, contactURL, contactEmail, licenseName, licenseURL, externalDocsDescription, externalDocsURL, servers string) *goapi.SpecBuilder {
|
||||
return &goapi.SpecBuilder{
|
||||
Title: title,
|
||||
Description: description,
|
||||
Version: version,
|
||||
SwaggerPath: swaggerPath,
|
||||
GraphQLPath: graphqlPath,
|
||||
GraphQLPlayground: graphqlPlayground,
|
||||
SSEPath: ssePath,
|
||||
|
|
|
|||
|
|
@ -700,6 +700,7 @@ func TestAPISDKCmd_Good_TempSpecUsesMetadataFlags(t *testing.T) {
|
|||
"Custom SDK API",
|
||||
"Custom SDK description",
|
||||
"9.9.9",
|
||||
"/docs",
|
||||
"/gql",
|
||||
true,
|
||||
"/events",
|
||||
|
|
@ -754,6 +755,9 @@ func TestAPISDKCmd_Good_TempSpecUsesMetadataFlags(t *testing.T) {
|
|||
if _, ok := paths["/gql"]; !ok {
|
||||
t.Fatal("expected GraphQL path to be included in generated spec")
|
||||
}
|
||||
if got := builder.SwaggerPath; got != "/docs" {
|
||||
t.Fatalf("expected swagger path to be preserved in sdk spec builder, got %v", got)
|
||||
}
|
||||
if _, ok := paths["/gql/playground"]; !ok {
|
||||
t.Fatal("expected GraphQL playground path to be included in generated spec")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue