Completed adding v3 models (I think)

Going to start logic for building things out. attempting generic builder pattern first.
This commit is contained in:
Dave Shanley
2022-07-29 06:52:07 -04:00
parent a5f4c7f607
commit a906d46227
16 changed files with 246 additions and 14 deletions

View File

@@ -0,0 +1,12 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Callback struct {
Node *yaml.Node
Expression map[string]Path
Extensions map[string]low.ObjectReference
}

View File

@@ -1,9 +1,19 @@
package v3 package v3
import "gopkg.in/yaml.v3" import (
"gopkg.in/yaml.v3"
"net/http"
)
type Components struct { type Components struct {
Node *yaml.Node Node *yaml.Node
Schemas map[string]Schema Schemas map[string]Schema
Responses map[string]Response Responses map[string]Response
Parameters map[string]Parameter
Examples map[string]Example
RequestBodies map[string]RequestBody
Headers map[string]http.Header
SecuritySchemes map[string]SecurityScheme
Links map[string]Link
Callbacks map[string]Callback
} }

View File

@@ -0,0 +1,12 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Discriminator struct {
Node *yaml.Node
PropertyName low.NodeReference[string]
Mapping map[string]string
}

View File

@@ -1,8 +1,15 @@
package v3 package v3
import "github.com/pb33f/libopenapi/datamodel/low"
type Document struct { type Document struct {
Version string Version string
Info Info Info Info
Servers []Server Servers []Server
Components Components Paths Paths
Components Components
Security []SecurityRequirement
Tags []Tag
ExternalDocs ExternalDoc
Extensions map[string]low.ObjectReference
} }

View File

@@ -0,0 +1,13 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type ExternalDoc struct {
Node *yaml.Node
Description low.NodeReference[string]
URL low.NodeReference[string]
Extensions map[string]low.ObjectReference
}

17
datamodel/low/3.0/link.go Normal file
View File

@@ -0,0 +1,17 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Link struct {
Node *yaml.Node
OperationRef low.NodeReference[string]
OperationId low.NodeReference[string]
Parameters map[string]low.NodeReference[string]
RequestBody low.NodeReference[string]
Description low.NodeReference[string]
Server Server
Extensions map[string]low.ObjectReference
}

View File

@@ -0,0 +1,24 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type OAuthFlows struct {
Node *yaml.Node
Implicit OAuthFlow
Password OAuthFlow
ClientCredentials OAuthFlow
AuthorizationCode OAuthFlow
Extensions map[string]low.ObjectReference
}
type OAuthFlow struct {
Node *yaml.Node
AuthorizationUrl low.NodeReference[string]
TokenURL low.NodeReference[string]
RefreshURL low.NodeReference[string]
Scopes map[string]string
Extensions map[string]low.ObjectReference
}

View File

@@ -0,0 +1,23 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Operation struct {
Node *yaml.Node
Tags []low.NodeReference[string]
Summary low.NodeReference[string]
Description low.NodeReference[string]
ExternalDocs ExternalDoc
OperationId low.NodeReference[string]
Parameters []Parameter
RequestBody RequestBody
Responses Responses
Callbacks map[string]Callback
Deprecated low.NodeReference[bool]
Security []SecurityRequirement
Servers []Server
Extensions map[string]low.ObjectReference
}

30
datamodel/low/3.0/path.go Normal file
View File

@@ -0,0 +1,30 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Paths struct {
Node *yaml.Node
Paths map[string]Path
Extensions map[string]low.ObjectReference
}
type Path struct {
Node *yaml.Node
Value low.NodeReference[string]
Summary low.NodeReference[string]
Description low.NodeReference[string]
Get Operation
Put Operation
Post Operation
Delete Operation
Options Operation
Head Operation
Patch Operation
Trace Operation
Servers []Server
Parameters []Parameter
Extensions map[string]low.ObjectReference
}

View File

@@ -0,0 +1,14 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type RequestBody struct {
Node *yaml.Node
Description low.NodeReference[string]
Content map[string]MediaType
Required low.NodeReference[bool]
Extensions map[string]low.ObjectReference
}

View File

@@ -5,9 +5,16 @@ import (
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
type Responses struct {
Node *yaml.Node
Codes map[string]Response
Default Response
}
type Response struct { type Response struct {
Node *yaml.Node Node *yaml.Node
Description low.NodeReference[string] Description low.NodeReference[string]
Headers map[string]Parameter Headers map[string]Parameter
Content map[string]MediaType Content map[string]MediaType
Extensions map[string]low.ObjectReference
} }

View File

@@ -33,4 +33,13 @@ type Schema struct {
AdditionalProperties low.ObjectReference AdditionalProperties low.ObjectReference
Description low.NodeReference[string] Description low.NodeReference[string]
Default low.ObjectReference Default low.ObjectReference
Nullable low.NodeReference[bool]
Discriminator Discriminator
ReadOnly low.NodeReference[bool]
WriteOnly low.NodeReference[bool]
XML XML
ExternalDocs ExternalDoc
Example low.ObjectReference
Deprecated low.NodeReference[bool]
Extensions map[string]low.ObjectReference
} }

View File

@@ -0,0 +1,24 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type SecurityScheme struct {
Node *yaml.Node
Type low.NodeReference[string]
Description low.NodeReference[string]
Name low.NodeReference[string]
In low.NodeReference[string]
Scheme low.NodeReference[string]
BearerFormat low.NodeReference[string]
Flows OAuthFlows
OpenIdConnectURL low.NodeReference[string]
Extensions map[string]low.ObjectReference
}
type SecurityRequirement struct {
Node *yaml.Node
Value []low.NodeReference[string]
}

14
datamodel/low/3.0/tag.go Normal file
View File

@@ -0,0 +1,14 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Tag struct {
Node *yaml.Node
Name low.NodeReference[string]
Description low.NodeReference[string]
ExternalDocs ExternalDoc
Extensions map[string]low.ObjectReference
}

16
datamodel/low/3.0/xml.go Normal file
View File

@@ -0,0 +1,16 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type XML struct {
Node *yaml.Node
Name low.NodeReference[string]
Namespace low.NodeReference[string]
Prefix low.NodeReference[string]
Attribute low.NodeReference[string]
Wrapped low.NodeReference[bool]
Extensions map[string]low.ObjectReference
}

View File

@@ -6,12 +6,12 @@ type HasNode interface {
GetNode() *yaml.Node GetNode() *yaml.Node
} }
type NodeReference[T comparable] interface { type NodeReference[T comparable] struct {
GetValue() T Value T
GetNode() *yaml.Node Node *yaml.Node
} }
type ObjectReference interface { type ObjectReference struct {
GetValue() interface{} Value interface{}
GetNode() *yaml.Node Node *yaml.Node
} }