diff --git a/field_parser_v3_test.go b/field_parser_v3_test.go index 593238c79..85176ec92 100644 --- a/field_parser_v3_test.go +++ b/field_parser_v3_test.go @@ -184,7 +184,7 @@ func TestDefaultFieldParserV3(t *testing.T) { t.Parallel() schema := spec.NewSchemaSpec() - schema.Spec.Type = []string{"string"} + schema.Spec.Type = &spec.SingleOrArray[string]{"string"} parser := &Parser{} fieldParser := newTagBaseFieldParserV3( parser, diff --git a/parserv3.go b/parserv3.go index 256153da9..19e9b6c50 100644 --- a/parserv3.go +++ b/parserv3.go @@ -349,7 +349,7 @@ func parseSecAttributesV3(context string, lines []string, index *int) (string, * case secImplicitAttr: search = []string{authorizationURL, in} case secAccessCodeAttr: - search = []string{tokenURL, authorizationURL, in} + search = []string{tokenURL, authorizationURL} case secBearerAuthAttr: scheme := spec.SecurityScheme{ Type: "http", @@ -461,11 +461,15 @@ func parseSecAttributesV3(context string, lines []string, index *int) (string, * case secAccessCodeAttr: scheme.Type = "oauth2" - scheme.In = attrMap[in] scheme.Flows = spec.NewOAuthFlows() scheme.Flows.Spec.AuthorizationCode = spec.NewOAuthFlow() scheme.Flows.Spec.AuthorizationCode.Spec.AuthorizationURL = attrMap[authorizationURL] scheme.Flows.Spec.AuthorizationCode.Spec.TokenURL = attrMap[tokenURL] + + scheme.Flows.Spec.AuthorizationCode.Spec.Scopes = make(map[string]string) + for k, v := range scopes { + scheme.Flows.Spec.AuthorizationCode.Spec.Scopes[k] = v + } } scheme.Description = description diff --git a/parserv3_test.go b/parserv3_test.go index f6c1a8771..427d6c4e2 100644 --- a/parserv3_test.go +++ b/parserv3_test.go @@ -163,8 +163,9 @@ func TestParserParseGeneralApiInfoV3(t *testing.T) { assert.Equal(t, "https://example.com/oauth/token", security["OAuth2Password"].Spec.Spec.Flows.Spec.Password.Spec.TokenURL) assert.Equal(t, "oauth2", security["OAuth2AccessCode"].Spec.Spec.Type) - assert.Equal(t, "header", security["OAuth2AccessCode"].Spec.Spec.In) assert.Equal(t, "https://example.com/oauth/token", security["OAuth2AccessCode"].Spec.Spec.Flows.Spec.AuthorizationCode.Spec.TokenURL) + assert.Equal(t, "https://example.com/oauth/authorize", security["OAuth2AccessCode"].Spec.Spec.Flows.Spec.AuthorizationCode.Spec.AuthorizationURL) + assert.Equal(t, 1, len(security["OAuth2AccessCode"].Spec.Spec.Flows.Spec.AuthorizationCode.Spec.Scopes)) assert.Equal(t, "bearer", security["bearerauth"].Spec.Spec.Scheme) assert.Equal(t, "http", security["bearerauth"].Spec.Spec.Type)