Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion field_parser_v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions parserv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion parserv3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down