mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
Low-level docs for v3 model are now in place
5/6 of the way there!
This commit is contained in:
@@ -9,13 +9,8 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const (
|
||||
ImplicitLabel = "implicit"
|
||||
PasswordLabel = "password"
|
||||
ClientCredentialsLabel = "clientCredentials"
|
||||
AuthorizationCodeLabel = "authorizationCode"
|
||||
)
|
||||
|
||||
// OAuthFlows represents a low-level OpenAPI 3+ OAuthFlows object.
|
||||
// - https://spec.openapis.org/oas/v3.1.0#oauth-flows-object
|
||||
type OAuthFlows struct {
|
||||
Implicit low.NodeReference[*OAuthFlow]
|
||||
Password low.NodeReference[*OAuthFlow]
|
||||
@@ -24,10 +19,12 @@ type OAuthFlows struct {
|
||||
Extensions map[low.KeyReference[string]]low.ValueReference[any]
|
||||
}
|
||||
|
||||
// FindExtension will attempt to locate an extension with the supplied name.
|
||||
func (o *OAuthFlows) FindExtension(ext string) *low.ValueReference[any] {
|
||||
return low.FindItemInMap[any](ext, o.Extensions)
|
||||
}
|
||||
|
||||
// Build will extract extensions and all OAuthFlow types from the supplied node.
|
||||
func (o *OAuthFlows) Build(root *yaml.Node, idx *index.SpecIndex) error {
|
||||
o.Extensions = low.ExtractExtensions(root)
|
||||
|
||||
@@ -58,6 +55,8 @@ func (o *OAuthFlows) Build(root *yaml.Node, idx *index.SpecIndex) error {
|
||||
|
||||
}
|
||||
|
||||
// OAuthFlow represents a low-level OpenAPI 3+ OAuthFlow object.
|
||||
// - https://spec.openapis.org/oas/v3.1.0#oauth-flow-object
|
||||
type OAuthFlow struct {
|
||||
AuthorizationUrl low.NodeReference[string]
|
||||
TokenUrl low.NodeReference[string]
|
||||
@@ -66,14 +65,17 @@ type OAuthFlow struct {
|
||||
Extensions map[low.KeyReference[string]]low.ValueReference[any]
|
||||
}
|
||||
|
||||
// FindScope attempts to locate a scope using a specified name.
|
||||
func (o *OAuthFlow) FindScope(scope string) *low.ValueReference[string] {
|
||||
return low.FindItemInMap[string](scope, o.Scopes.Value)
|
||||
}
|
||||
|
||||
// FindExtension attempts to locate an extension with a specified key
|
||||
func (o *OAuthFlow) FindExtension(ext string) *low.ValueReference[any] {
|
||||
return low.FindItemInMap[any](ext, o.Extensions)
|
||||
}
|
||||
|
||||
// Build will extract extensions from the node.
|
||||
func (o *OAuthFlow) Build(root *yaml.Node, idx *index.SpecIndex) error {
|
||||
o.Extensions = low.ExtractExtensions(root)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user