Skip to content

Commit

Permalink
chore(deps): fix #149: update for `github.com/getkin/kin-openapi@v0.1…
Browse files Browse the repository at this point in the history
…29.0`
  • Loading branch information
grokify committed Feb 1, 2025
1 parent 711eba5 commit d8d952a
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 67 deletions.
9 changes: 3 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.2
require (
github.com/ake-persson/mapslice-json v0.0.0-20210720081907-22c8edf57807
github.com/buaazp/fasthttprouter v0.1.1
github.com/getkin/kin-openapi v0.123.0
github.com/getkin/kin-openapi v0.129.0
github.com/grokify/gocharts/v2 v2.21.12
github.com/grokify/mogo v0.67.7
github.com/grokify/sogo v0.10.0
Expand All @@ -28,7 +28,6 @@ require (
github.com/grokify/base36 v1.0.5 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/invopop/yaml v0.3.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.11 // indirect
Expand All @@ -39,6 +38,8 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/oasdiff/yaml v0.0.0-20241214135536-5f7845c759c8 // indirect
github.com/oasdiff/yaml3 v0.0.0-20241214160948-977117996672 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -56,7 +57,3 @@ require (
golang.org/x/text v0.21.0 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
)

// replace github.com/grokify/mogo => ../mogo

// replace github.com/grokify/gocharts/v2 => ../gocharts
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E=
github.com/getkin/kin-openapi v0.123.0 h1:zIik0mRwFNLyvtXK274Q6ut+dPh6nlxBp0x7mNrPhs8=
github.com/getkin/kin-openapi v0.123.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM=
github.com/getkin/kin-openapi v0.129.0 h1:QGYTNcmyP5X0AtFQ2Dkou9DGBJsUETeLH9rFrJXZh30=
github.com/getkin/kin-openapi v0.129.0/go.mod h1:gmWI+b/J45xqpyK5wJmRRZse5wefA5H0RDMK46kLUtI=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
Expand All @@ -45,8 +45,6 @@ github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso=
github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA=
github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
Expand Down Expand Up @@ -82,6 +80,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/oasdiff/yaml v0.0.0-20241214135536-5f7845c759c8 h1:9djga8U4+/TQzv5iMlZHZ/qbGQB9V2nlnk2bmiG+uBs=
github.com/oasdiff/yaml v0.0.0-20241214135536-5f7845c759c8/go.mod h1:7tFDb+Y51LcDpn26GccuUgQXUk6t0CXZsivKjyimYX8=
github.com/oasdiff/yaml3 v0.0.0-20241214160948-977117996672 h1:+273wgr7to5QhwOOBE5LwjdNDFAI+8cbJVfB0Zj75aI=
github.com/oasdiff/yaml3 v0.0.0-20241214160948-977117996672/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
Expand Down
12 changes: 6 additions & 6 deletions openapi3/openapi3postman2/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,21 +343,21 @@ func schemaToString(schemaRef *oas3.SchemaRef) string {
}
schema := schemaRef.Value
parts := []string{}
schema.Type = strings.TrimSpace(schema.Type)
schemaType := strings.ToLower(strings.TrimSpace(openapi3.TypesRefString(schema.Type)))
schema.Format = strings.TrimSpace(schema.Format)
if len(schema.Type) > 0 {
parts = append(parts, schema.Type)
if schemaType != "" {
parts = append(parts, schemaType)
}
if len(schema.Format) > 0 {
parts = append(parts, schema.Format)
}
if strings.ToLower(schema.Type) == "array" {
if schemaType == openapi3.TypeArray {
if schema.Items != nil && schema.Items.Value != nil {
parts = append(parts, schema.Items.Value.Type)
parts = append(parts, openapi3.TypesRefString(schema.Items.Value.Type))
}
}
if len(parts) > 0 {
if len(parts) == 2 && parts[0] == "array" && parts[1] == "string" {
if len(parts) == 2 && parts[0] == openapi3.TypeArray && parts[1] == openapi3.TypeString {
parts = append(parts, "csv")
}
return "<" + strings.Join(parts, ".") + ">"
Expand Down
38 changes: 19 additions & 19 deletions openapi3/springopenapi3/spring_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func lineToBoolDef(line string) (string, oas3.Schema) {
propName := m1[0][1]
boolDefaultVal := m1[0][2]
sch := oas3.Schema{
Type: openapi3.TypeBoolean}
Type: openapi3.NewTypesRef(openapi3.TypeBoolean)}
if boolDefaultVal == "true" {
sch.Default = true
} else {
Expand All @@ -92,7 +92,7 @@ func lineToIntOrLongDef(line string) (string, oas3.Schema, error) {
return "", oas3.Schema{}, err
}
sch := oas3.Schema{
Type: openapi3.TypeInteger,
Type: openapi3.NewTypesRef(openapi3.TypeInteger),
Default: defaultVal}
if intOrLong == "long" {
sch.Format = FormatIntegerInt64
Expand All @@ -108,7 +108,7 @@ func lineToStringDef(line string) (string, oas3.Schema) {
if len(m1) > 0 {
propName := m1[0][1]
sch := oas3.Schema{
Type: openapi3.TypeString,
Type: openapi3.NewTypesRef(openapi3.TypeString),
Default: strings.TrimSpace(m1[0][2])}
return propName, sch
}
Expand All @@ -128,18 +128,18 @@ func lineToArrayDef(line string, explicitCustomTypes []string) (string, *oas3.Sc
switch javaTypeLc {
case openapi3.TypeInteger:
sch := oas3.Schema{
Type: openapi3.TypeArray,
Type: openapi3.NewTypesRef(openapi3.TypeArray),
Items: oas3.NewSchemaRef("",
&oas3.Schema{
Type: openapi3.TypeInteger})}
Type: openapi3.NewTypesRef(openapi3.TypeInteger)})}
sr := oas3.NewSchemaRef("", &sch)
return propName, sr
case openapi3.TypeString:
sch := oas3.Schema{
Type: openapi3.TypeArray,
Type: openapi3.NewTypesRef(openapi3.TypeArray),
Items: oas3.NewSchemaRef("",
&oas3.Schema{
Type: openapi3.TypeString})}
Type: openapi3.NewTypesRef(openapi3.TypeString)})}
sr := oas3.NewSchemaRef("", &sch)
return propName, sr
default:
Expand Down Expand Up @@ -215,22 +215,22 @@ func ParseSpringLineToSchemaRef(line string, explicitCustomTypes []string) (stri
schemaRef := &oas3.SchemaRef{}
switch javaTypeLc {
case openapi3.TypeBoolean:
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.TypeBoolean})
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.NewTypesRef(openapi3.TypeBoolean)})
case "date":
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{
Type: openapi3.TypeString, Format: FormatStringDate})
Type: openapi3.NewTypesRef(openapi3.TypeString), Format: FormatStringDate})
case "datetime":
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{
Type: openapi3.TypeString,
Type: openapi3.NewTypesRef(openapi3.TypeString),
Description: "Date-time in Java format. Example: `2019-01-01T01:01:01.000+0000`. Note this is not compatible with RFC-3339 which is used by OpenAPI 3.0 Spec because it doesn't have a `:` between hours and minutes.",
})
case openapi3.TypeInteger:
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.TypeInteger})
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.NewTypesRef(openapi3.TypeInteger)})
case "long":
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{
Type: openapi3.TypeInteger, Format: FormatIntegerInt64})
Type: openapi3.NewTypesRef(openapi3.TypeInteger), Format: FormatIntegerInt64})
case openapi3.TypeString:
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.TypeString})
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.NewTypesRef(openapi3.TypeString)})
default:
found := false
for _, exType := range explicitCustomTypes {
Expand Down Expand Up @@ -287,20 +287,20 @@ func ParseSpringLineToSchema(line string) (string, *oas3.Schema, error) {
javaTypeLc := strings.ToLower(strings.TrimSpace(m2a[1]))
switch javaTypeLc {
case openapi3.TypeBoolean:
sch.Type = openapi3.TypeBoolean
sch.Type = openapi3.NewTypesRef(openapi3.TypeBoolean)
case openapi3.FormatDate:
sch.Type = openapi3.TypeString
sch.Type = openapi3.NewTypesRef(openapi3.TypeString)
sch.Format = FormatStringDate
case "datetime":
sch.Type = openapi3.TypeString
sch.Type = openapi3.NewTypesRef(openapi3.TypeString)
sch.Format = FormatStringDateTime
case openapi3.TypeInteger:
sch.Type = openapi3.TypeInteger
sch.Type = openapi3.NewTypesRef(openapi3.TypeInteger)
case "long":
sch.Type = openapi3.TypeInteger
sch.Type = openapi3.NewTypesRef(openapi3.TypeInteger)
sch.Format = FormatIntegerInt64
case openapi3.TypeString:
sch.Type = openapi3.TypeString
sch.Type = openapi3.NewTypesRef(openapi3.TypeString)
default:
panic(fmt.Sprintf("TYPE [%v] LINE [%v]", javaTypeLc, line))
}
Expand Down
4 changes: 3 additions & 1 deletion openapi3/springopenapi3/spring_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package springopenapi3

import (
"testing"

"github.com/grokify/spectrum/openapi3"
)

var parseLineTests = []struct {
Expand Down Expand Up @@ -32,7 +34,7 @@ func TestParseLine(t *testing.T) {
t.Errorf("fromspring.ParseSpringLineToSchema() [%v]", err)
}
schema := schemaRef.Value
if tt.oasName != name || tt.oasType != schema.Type || tt.oasFormat != schema.Format {
if tt.oasName != name || tt.oasType != openapi3.TypesRefString(schema.Type) || tt.oasFormat != schema.Format {
t.Errorf(`fromspring.ParseSpringLineToSchema("%s") MISMATCH W[%v]G[%v] [%v][%v] [%v][%v]`, tt.v, tt.oasName, name, tt.oasType, schema.Type, tt.oasFormat, schema.Format)
}
//fmtutil.PrintJSON(schema)
Expand Down
40 changes: 24 additions & 16 deletions openapi3/visit.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,30 @@ func VisitTypesFormats(spec *Spec, visitTypeFormat func(jsonPointerRoot, oasType
continue
}
for propName, propRef := range schemaRef.Value.Properties {
if propRef.Value == nil {
if propRef.Value == nil || propRef.Value.Type == nil {
continue
}
visitTypeFormat(
fmt.Sprintf(jPtrSchemaPropertyFormat, schemaName, propName),
propRef.Value.Type,
propRef.Value.Format)
for _, t := range *propRef.Value.Type {
visitTypeFormat(
fmt.Sprintf(jPtrSchemaPropertyFormat, schemaName, propName),
t,
propRef.Value.Format)
}
}
}
for paramName, paramRef := range spec.Components.Parameters {
if paramRef.Value == nil ||
paramRef.Value.Schema == nil ||
paramRef.Value.Schema.Value == nil {
paramRef.Value.Schema.Value == nil ||
paramRef.Value.Schema.Value.Type == nil {
continue
}
visitTypeFormat(
fmt.Sprintf(jPtrParamFormat, paramName),
paramRef.Value.Schema.Value.Type,
paramRef.Value.Schema.Value.Format)
for _, t := range *paramRef.Value.Schema.Value.Type {
visitTypeFormat(
fmt.Sprintf(jPtrParamFormat, paramName),
t,
paramRef.Value.Schema.Value.Format)
}
}
VisitOperations(
spec,
Expand All @@ -50,14 +55,17 @@ func VisitTypesFormats(spec *Spec, visitTypeFormat func(jsonPointerRoot, oasType
for i, paramRef := range op.Parameters {
if paramRef.Value == nil ||
paramRef.Value.Schema == nil ||
paramRef.Value.Schema.Value == nil {
paramRef.Value.Schema.Value == nil ||
paramRef.Value.Schema.Value.Type == nil {
continue
}
visitTypeFormat(
jsonpointer.PointerSubEscapeAll(
"#/paths/%s/%s/parameters/%d/schema", path, strings.ToLower(method), i),
paramRef.Value.Schema.Value.Type,
paramRef.Value.Schema.Value.Format)
for _, t := range *paramRef.Value.Schema.Value.Type {
visitTypeFormat(
jsonpointer.PointerSubEscapeAll(
"#/paths/%s/%s/parameters/%d/schema", path, strings.ToLower(method), i),
t,
paramRef.Value.Schema.Value.Format)
}
}
},
)
Expand Down
4 changes: 2 additions & 2 deletions openapi3edit/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (se *SpecEdit) SchemaSetAdditionalPropertiesTrue(pointerBase string) []stri
return mods
}
for schName, schRef := range se.SpecMore.Spec.Components.Schemas {
if schRef == nil || schRef.Value == nil || schRef.Value.Type != openapi3.TypeObject {
if schRef == nil || schRef.Value == nil || !openapi3.TypesRefIs(schRef.Value.Type, openapi3.TypeObject) {
continue
}
/*
Expand All @@ -215,7 +215,7 @@ func (se *SpecEdit) SchemaSetAdditionalPropertiesTrue(pointerBase string) []stri
mods = append(mods, fmt.Sprintf("%s%s/%s", pointerBase, openapi3.PointerComponentsSchemas, schName))
}
for propName, propRef := range schRef.Value.Properties {
if propRef == nil || propRef.Value == nil || propRef.Value.Type != openapi3.TypeObject {
if propRef == nil || propRef.Value == nil || !openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeObject) {
continue
}
/*
Expand Down
8 changes: 4 additions & 4 deletions openapi3edit/schemas_flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ func (se *SpecEdit) SchemasFlattenSchemaRef(baseName, schName string, schRef *oa
if propRef == nil || propRef.Value == nil {
continue
}
if propRef.Value.Type == openapi3.TypeArray {
if openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeArray) {
itemsRef := propRef.Value.Items
if itemsRef == nil {
continue
}
itemsRef.Ref = strings.TrimSpace(itemsRef.Ref)
if itemsRef.Value != nil &&
(itemsRef.Value.Type == openapi3.TypeArray || itemsRef.Value.Type == openapi3.TypeObject) {
(openapi3.TypesRefIs(itemsRef.Value.Type, openapi3.TypeArray, openapi3.TypeObject)) {
if len(itemsRef.Ref) > 0 {
propRef.Value.Items = oas3.NewSchemaRef(itemsRef.Ref, nil)
} else {
Expand All @@ -61,7 +61,7 @@ func (se *SpecEdit) SchemasFlattenSchemaRef(baseName, schName string, schRef *oa
//itemsRef.Ref = openapi3.PointerComponentsSchemas + "/" + newSchemaName
}
//} else if propRef.Value.Type == openapi3.TypeObject {
} else if propRef.Value.Type == openapi3.TypeObject {
} else if openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeObject) {
if len(propRef.Value.Properties) > 0 {
newSchemaName := basePlusSchName + stringsutil.ToUpperFirst(propName, false)
if _, ok := spec.Components.Schemas[newSchemaName]; ok {
Expand Down Expand Up @@ -95,7 +95,7 @@ func (se *SpecEdit) SchemaRefsFlatten() error {
}
// visitSchemaRefFunc(propSchemaName, propSchemaRef)
if len(propSchemaRef.Ref) == 0 && propSchemaRef.Value != nil {
if propSchemaRef.Value.Type == openapi3.TypeObject || propSchemaRef.Value.Type == openapi3.TypeArray {
if openapi3.TypesRefIs(propSchemaRef.Value.Type, openapi3.TypeObject, openapi3.TypeArray) {
newRootSchemaName := propSchemaName
if _, ok := spec.Components.Schemas[newRootSchemaName]; ok {
newRootSchemaName = schName + stringsutil.ToUpperFirst(newRootSchemaName, false)
Expand Down
6 changes: 3 additions & 3 deletions openapi3edit/validate_and_fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (se *SpecEdit) ValidateFixOperationPathParameters(fix bool) ([]*openapi3.Op
Required: true,
Schema: &oas3.SchemaRef{
Value: &oas3.Schema{
Type: "string",
Type: openapi3.NewTypesRef(openapi3.TypeString),
},
},
},
Expand Down Expand Up @@ -190,7 +190,7 @@ func (se *SpecEdit) ValidateFixOperationResponseTypes(fix bool) ([]*openapi3.Ope
if len(schemaRef.Ref) == 0 {
schema := schemaRef.Value
schemaType := schema.Type
if fix && (schemaType == openapi3.TypeString || schemaType == openapi3.TypeInteger) {
if fix && openapi3.TypesRefIs(schemaType, openapi3.TypeString, openapi3.TypeInteger) {
delete(response.Value.Content, mediaTypeOrig)
if mtRefTry, ok := response.Value.Content[httputilmore.ContentTypeTextPlain]; ok {
if !reflect.DeepEqual(mtRef, mtRefTry) {
Expand All @@ -202,7 +202,7 @@ func (se *SpecEdit) ValidateFixOperationResponseTypes(fix bool) ([]*openapi3.Ope
} else {
response.Value.Content[httputilmore.ContentTypeTextPlain] = mtRef
}
} else if schemaType != openapi3.TypeObject && schemaType != openapi3.TypeArray {
} else if !openapi3.TypesRefIs(schemaType, openapi3.TypeObject, openapi3.TypeArray) {
om := openapi3.OperationToMeta(path, method, op, []string{})
om.MetaNotes = append(om.MetaNotes,
fmt.Sprintf("E_BAD_MIME_TYPE_AND_SCHEMA MT[%s] type[%s]", mediaType, schemaType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (rule RuleSchemaObjectPropsExist) ProcessSpec(spec *openapi3.Spec, pointerB
vios := []lintutil.PolicyViolation{}

for schName, schRef := range spec.Components.Schemas {
if schRef == nil || schRef.Value == nil || schRef.Value.Type != openapi3.TypeObject {
if schRef == nil || schRef.Value == nil || !openapi3.TypesRefIs(schRef.Value.Type, openapi3.TypeObject) {
continue
}
/*
Expand All @@ -56,7 +56,7 @@ func (rule RuleSchemaObjectPropsExist) ProcessSpec(spec *openapi3.Spec, pointerB
pointerBase, schName)})
}
for propName, propRef := range schRef.Value.Properties {
if propRef == nil || propRef.Value == nil || propRef.Value.Type != openapi3.TypeObject {
if propRef == nil || propRef.Value == nil || !openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeObject) {
continue
}
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ func (rule RuleSchemaPropEnumStyle) ProcessSpec(spec *openapi3.Spec, pointerBase
vios := []lintutil.PolicyViolation{}

for schName, schRef := range spec.Components.Schemas {
if schRef == nil || schRef.Value == nil ||
schRef.Value.Type != openapi3.TypeObject {
if schRef == nil || schRef.Value == nil || !openapi3.TypesRefIs(schRef.Value.Type, openapi3.TypeObject) {
continue
}

for propName, propRef := range schRef.Value.Properties {
if propRef.Value == nil ||
propRef.Value.Type != "string" ||
if propRef.Value == nil || !openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeString) ||
len(propRef.Value.Enum) == 0 {
continue
}
Expand Down

0 comments on commit d8d952a

Please sign in to comment.