mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-07 12:37:48 +00:00
Starting work on oAuth Flows.
This commit is contained in:
@@ -16,6 +16,10 @@ type Link struct {
|
|||||||
Extensions map[low.KeyReference[string]]low.ValueReference[any]
|
Extensions map[low.KeyReference[string]]low.ValueReference[any]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Link) FindParameter(pName string) *low.ValueReference[string] {
|
||||||
|
return FindItemInMap[string](pName, l.Parameters.Value)
|
||||||
|
}
|
||||||
|
|
||||||
func (l *Link) Build(root *yaml.Node) error {
|
func (l *Link) Build(root *yaml.Node) error {
|
||||||
extensionMap, err := ExtractExtensions(root)
|
extensionMap, err := ExtractExtensions(root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,24 +1,40 @@
|
|||||||
package v3
|
package v3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pb33f/libopenapi/datamodel/low"
|
"github.com/pb33f/libopenapi/datamodel/low"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OAuthFlows struct {
|
type OAuthFlows struct {
|
||||||
Node *yaml.Node
|
Implicit low.NodeReference[*OAuthFlow]
|
||||||
Implicit OAuthFlow
|
Password low.NodeReference[*OAuthFlow]
|
||||||
Password OAuthFlow
|
ClientCredentials low.NodeReference[*OAuthFlow]
|
||||||
ClientCredentials OAuthFlow
|
AuthorizationCode low.NodeReference[*OAuthFlow]
|
||||||
AuthorizationCode OAuthFlow
|
Extensions map[low.KeyReference[string]]low.ValueReference[any]
|
||||||
Extensions map[string]low.ObjectReference
|
}
|
||||||
|
|
||||||
|
func (o *OAuthFlows) Build(root *yaml.Node) error {
|
||||||
|
extensionMap, err := ExtractExtensions(root)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
o.Extensions = extensionMap
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type OAuthFlow struct {
|
type OAuthFlow struct {
|
||||||
Node *yaml.Node
|
AuthorizationUrl low.NodeReference[string]
|
||||||
AuthorizationUrl low.NodeReference[string]
|
TokenURL low.NodeReference[string]
|
||||||
TokenURL low.NodeReference[string]
|
RefreshURL low.NodeReference[string]
|
||||||
RefreshURL low.NodeReference[string]
|
Scopes map[low.KeyReference[string]]low.ValueReference[string]
|
||||||
Scopes map[string]string
|
Extensions map[low.KeyReference[string]]low.ValueReference[any]
|
||||||
Extensions map[string]low.ObjectReference
|
}
|
||||||
|
|
||||||
|
func (o *OAuthFlow) Build(root *yaml.Node) error {
|
||||||
|
extensionMap, err := ExtractExtensions(root)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
o.Extensions = extensionMap
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,31 @@
|
|||||||
package v3
|
package v3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pb33f/libopenapi/datamodel/low"
|
"github.com/pb33f/libopenapi/datamodel/low"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SecurityScheme struct {
|
type SecurityScheme struct {
|
||||||
Node *yaml.Node
|
Type low.NodeReference[string]
|
||||||
Type low.NodeReference[string]
|
Description low.NodeReference[string]
|
||||||
Description low.NodeReference[string]
|
Name low.NodeReference[string]
|
||||||
Name low.NodeReference[string]
|
In low.NodeReference[string]
|
||||||
In low.NodeReference[string]
|
Scheme low.NodeReference[string]
|
||||||
Scheme low.NodeReference[string]
|
BearerFormat low.NodeReference[string]
|
||||||
BearerFormat low.NodeReference[string]
|
Flows low.NodeReference[*OAuthFlows]
|
||||||
Flows OAuthFlows
|
OpenIdConnectURL low.NodeReference[string]
|
||||||
OpenIdConnectURL low.NodeReference[string]
|
Extensions map[low.KeyReference[string]]low.ValueReference[any]
|
||||||
Extensions map[string]low.ObjectReference
|
}
|
||||||
|
|
||||||
|
func (ss *SecurityScheme) Build(root *yaml.Node) error {
|
||||||
|
extensionMap, err := ExtractExtensions(root)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ss.Extensions = extensionMap
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type SecurityRequirement struct {
|
type SecurityRequirement struct {
|
||||||
Node *yaml.Node
|
Value low.NodeReference[[]low.ValueReference[string]]
|
||||||
Value []low.NodeReference[string]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,4 +214,10 @@ func TestCreateDocument_Paths(t *testing.T) {
|
|||||||
assert.Len(t, links.Value, 2)
|
assert.Len(t, links.Value, 2)
|
||||||
assert.Equal(t, "locateBurger", okCode.Value.FindLink("LocateBurger").Value.OperationId.Value)
|
assert.Equal(t, "locateBurger", okCode.Value.FindLink("LocateBurger").Value.OperationId.Value)
|
||||||
|
|
||||||
|
locateBurger := okCode.Value.FindLink("LocateBurger").Value
|
||||||
|
|
||||||
|
burgerIdParam := locateBurger.FindParameter("burgerId")
|
||||||
|
assert.NotNil(t, burgerIdParam)
|
||||||
|
assert.Equal(t, "$response.body#/id", burgerIdParam.Value)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user