Adding new low level models for OAS

This commit is contained in:
Dave Shanley
2022-07-28 08:49:57 -04:00
parent 0665855605
commit a5f4c7f607
14 changed files with 206 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
package v3
import "gopkg.in/yaml.v3"
type Components struct {
Node *yaml.Node
Schemas map[string]Schema
Responses map[string]Response
}

View File

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

View File

@@ -0,0 +1,8 @@
package v3
type Document struct {
Version string
Info Info
Servers []Server
Components Components
}

View File

@@ -0,0 +1,15 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Encoding struct {
Node *yaml.Node
ContentType low.NodeReference[string]
Headers map[string]Parameter
Style low.NodeReference[string]
Explode low.NodeReference[bool]
AllowReserved low.NodeReference[bool]
}

View File

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

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

@@ -0,0 +1,16 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Info struct {
Node *yaml.Node
Title low.NodeReference[string]
Description low.NodeReference[string]
TermsOfService low.NodeReference[string]
Contact Contact
License License
Version low.NodeReference[string]
}

View File

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

View File

@@ -0,0 +1,14 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type MediaType struct {
Node *yaml.Node
Schema Schema
Example low.ObjectReference
Examples map[string]Example
Encoding map[string]Encoding
}

View File

@@ -0,0 +1,16 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Parameter struct {
Node *yaml.Node
Name low.NodeReference[string]
In low.NodeReference[string]
Description low.NodeReference[string]
Required low.NodeReference[bool]
Deprecated low.NodeReference[bool]
AllowEmptyValue low.NodeReference[bool]
}

View File

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

View File

@@ -0,0 +1,36 @@
package v3
import (
"github.com/pb33f/libopenapi/datamodel/low"
"gopkg.in/yaml.v3"
)
type Schema struct {
Node *yaml.Node
Title low.NodeReference[string]
MultipleOf low.NodeReference[int]
Maximum low.NodeReference[int]
ExclusiveMaximum low.NodeReference[int]
Minimum low.NodeReference[int]
ExclusiveMinimum low.NodeReference[int]
MaxLength low.NodeReference[int]
MinLength low.NodeReference[int]
Pattern low.NodeReference[string]
MaxItems low.NodeReference[int]
MinItems low.NodeReference[int]
UniqueItems low.NodeReference[int]
MaxProperties low.NodeReference[int]
MinProperties low.NodeReference[int]
Required []low.NodeReference[string]
Enum []low.NodeReference[string]
Type low.NodeReference[string]
AllOf *Schema
OneOf *Schema
AnyOf *Schema
Not *Schema
Items *Schema
Properties map[string]*Schema
AdditionalProperties low.ObjectReference
Description low.NodeReference[string]
Default low.ObjectReference
}

View File

@@ -0,0 +1,9 @@
package v3
import "github.com/pb33f/libopenapi/datamodel/low"
type Server struct {
URL low.NodeReference[string]
Description low.NodeReference[string]
Variables map[string]ServerVariable
}

View File

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

View File

@@ -0,0 +1,17 @@
package low
import "gopkg.in/yaml.v3"
type HasNode interface {
GetNode() *yaml.Node
}
type NodeReference[T comparable] interface {
GetValue() T
GetNode() *yaml.Node
}
type ObjectReference interface {
GetValue() interface{}
GetNode() *yaml.Node
}