Skip to content

Commit d8d952a

Browse files
committed
chore(deps): fix #149: update for github.com/getkin/[email protected]
1 parent 711eba5 commit d8d952a

File tree

11 files changed

+74
-67
lines changed

11 files changed

+74
-67
lines changed

go.mod

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.2
55
require (
66
github.com/ake-persson/mapslice-json v0.0.0-20210720081907-22c8edf57807
77
github.com/buaazp/fasthttprouter v0.1.1
8-
github.com/getkin/kin-openapi v0.123.0
8+
github.com/getkin/kin-openapi v0.129.0
99
github.com/grokify/gocharts/v2 v2.21.12
1010
github.com/grokify/mogo v0.67.7
1111
github.com/grokify/sogo v0.10.0
@@ -28,7 +28,6 @@ require (
2828
github.com/grokify/base36 v1.0.5 // indirect
2929
github.com/huandu/xstrings v1.5.0 // indirect
3030
github.com/iancoleman/strcase v0.3.0 // indirect
31-
github.com/invopop/yaml v0.3.1 // indirect
3231
github.com/josharian/intern v1.0.0 // indirect
3332
github.com/json-iterator/go v1.1.12 // indirect
3433
github.com/klauspost/compress v1.17.11 // indirect
@@ -39,6 +38,8 @@ require (
3938
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4039
github.com/modern-go/reflect2 v1.0.2 // indirect
4140
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
41+
github.com/oasdiff/yaml v0.0.0-20241214135536-5f7845c759c8 // indirect
42+
github.com/oasdiff/yaml3 v0.0.0-20241214160948-977117996672 // indirect
4243
github.com/olekukonko/tablewriter v0.0.5 // indirect
4344
github.com/perimeterx/marshmallow v1.1.5 // indirect
4445
github.com/pkg/errors v0.9.1 // indirect
@@ -56,7 +57,3 @@ require (
5657
golang.org/x/text v0.21.0 // indirect
5758
gonum.org/v1/gonum v0.15.1 // indirect
5859
)
59-
60-
// replace github.com/grokify/mogo => ../mogo
61-
62-
// replace github.com/grokify/gocharts/v2 => ../gocharts

go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
1717
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1818
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1919
github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E=
20-
github.com/getkin/kin-openapi v0.123.0 h1:zIik0mRwFNLyvtXK274Q6ut+dPh6nlxBp0x7mNrPhs8=
21-
github.com/getkin/kin-openapi v0.123.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM=
20+
github.com/getkin/kin-openapi v0.129.0 h1:QGYTNcmyP5X0AtFQ2Dkou9DGBJsUETeLH9rFrJXZh30=
21+
github.com/getkin/kin-openapi v0.129.0/go.mod h1:gmWI+b/J45xqpyK5wJmRRZse5wefA5H0RDMK46kLUtI=
2222
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
2323
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
2424
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
@@ -45,8 +45,6 @@ github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI
4545
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
4646
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
4747
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
48-
github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso=
49-
github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA=
5048
github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
5149
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
5250
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
@@ -82,6 +80,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
8280
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
8381
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
8482
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
83+
github.com/oasdiff/yaml v0.0.0-20241214135536-5f7845c759c8 h1:9djga8U4+/TQzv5iMlZHZ/qbGQB9V2nlnk2bmiG+uBs=
84+
github.com/oasdiff/yaml v0.0.0-20241214135536-5f7845c759c8/go.mod h1:7tFDb+Y51LcDpn26GccuUgQXUk6t0CXZsivKjyimYX8=
85+
github.com/oasdiff/yaml3 v0.0.0-20241214160948-977117996672 h1:+273wgr7to5QhwOOBE5LwjdNDFAI+8cbJVfB0Zj75aI=
86+
github.com/oasdiff/yaml3 v0.0.0-20241214160948-977117996672/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o=
8587
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
8688
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
8789
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=

openapi3/openapi3postman2/convert.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,21 +343,21 @@ func schemaToString(schemaRef *oas3.SchemaRef) string {
343343
}
344344
schema := schemaRef.Value
345345
parts := []string{}
346-
schema.Type = strings.TrimSpace(schema.Type)
346+
schemaType := strings.ToLower(strings.TrimSpace(openapi3.TypesRefString(schema.Type)))
347347
schema.Format = strings.TrimSpace(schema.Format)
348-
if len(schema.Type) > 0 {
349-
parts = append(parts, schema.Type)
348+
if schemaType != "" {
349+
parts = append(parts, schemaType)
350350
}
351351
if len(schema.Format) > 0 {
352352
parts = append(parts, schema.Format)
353353
}
354-
if strings.ToLower(schema.Type) == "array" {
354+
if schemaType == openapi3.TypeArray {
355355
if schema.Items != nil && schema.Items.Value != nil {
356-
parts = append(parts, schema.Items.Value.Type)
356+
parts = append(parts, openapi3.TypesRefString(schema.Items.Value.Type))
357357
}
358358
}
359359
if len(parts) > 0 {
360-
if len(parts) == 2 && parts[0] == "array" && parts[1] == "string" {
360+
if len(parts) == 2 && parts[0] == openapi3.TypeArray && parts[1] == openapi3.TypeString {
361361
parts = append(parts, "csv")
362362
}
363363
return "<" + strings.Join(parts, ".") + ">"

openapi3/springopenapi3/spring_parser.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func lineToBoolDef(line string) (string, oas3.Schema) {
6969
propName := m1[0][1]
7070
boolDefaultVal := m1[0][2]
7171
sch := oas3.Schema{
72-
Type: openapi3.TypeBoolean}
72+
Type: openapi3.NewTypesRef(openapi3.TypeBoolean)}
7373
if boolDefaultVal == "true" {
7474
sch.Default = true
7575
} else {
@@ -92,7 +92,7 @@ func lineToIntOrLongDef(line string) (string, oas3.Schema, error) {
9292
return "", oas3.Schema{}, err
9393
}
9494
sch := oas3.Schema{
95-
Type: openapi3.TypeInteger,
95+
Type: openapi3.NewTypesRef(openapi3.TypeInteger),
9696
Default: defaultVal}
9797
if intOrLong == "long" {
9898
sch.Format = FormatIntegerInt64
@@ -108,7 +108,7 @@ func lineToStringDef(line string) (string, oas3.Schema) {
108108
if len(m1) > 0 {
109109
propName := m1[0][1]
110110
sch := oas3.Schema{
111-
Type: openapi3.TypeString,
111+
Type: openapi3.NewTypesRef(openapi3.TypeString),
112112
Default: strings.TrimSpace(m1[0][2])}
113113
return propName, sch
114114
}
@@ -128,18 +128,18 @@ func lineToArrayDef(line string, explicitCustomTypes []string) (string, *oas3.Sc
128128
switch javaTypeLc {
129129
case openapi3.TypeInteger:
130130
sch := oas3.Schema{
131-
Type: openapi3.TypeArray,
131+
Type: openapi3.NewTypesRef(openapi3.TypeArray),
132132
Items: oas3.NewSchemaRef("",
133133
&oas3.Schema{
134-
Type: openapi3.TypeInteger})}
134+
Type: openapi3.NewTypesRef(openapi3.TypeInteger)})}
135135
sr := oas3.NewSchemaRef("", &sch)
136136
return propName, sr
137137
case openapi3.TypeString:
138138
sch := oas3.Schema{
139-
Type: openapi3.TypeArray,
139+
Type: openapi3.NewTypesRef(openapi3.TypeArray),
140140
Items: oas3.NewSchemaRef("",
141141
&oas3.Schema{
142-
Type: openapi3.TypeString})}
142+
Type: openapi3.NewTypesRef(openapi3.TypeString)})}
143143
sr := oas3.NewSchemaRef("", &sch)
144144
return propName, sr
145145
default:
@@ -215,22 +215,22 @@ func ParseSpringLineToSchemaRef(line string, explicitCustomTypes []string) (stri
215215
schemaRef := &oas3.SchemaRef{}
216216
switch javaTypeLc {
217217
case openapi3.TypeBoolean:
218-
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.TypeBoolean})
218+
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.NewTypesRef(openapi3.TypeBoolean)})
219219
case "date":
220220
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{
221-
Type: openapi3.TypeString, Format: FormatStringDate})
221+
Type: openapi3.NewTypesRef(openapi3.TypeString), Format: FormatStringDate})
222222
case "datetime":
223223
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{
224-
Type: openapi3.TypeString,
224+
Type: openapi3.NewTypesRef(openapi3.TypeString),
225225
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.",
226226
})
227227
case openapi3.TypeInteger:
228-
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.TypeInteger})
228+
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.NewTypesRef(openapi3.TypeInteger)})
229229
case "long":
230230
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{
231-
Type: openapi3.TypeInteger, Format: FormatIntegerInt64})
231+
Type: openapi3.NewTypesRef(openapi3.TypeInteger), Format: FormatIntegerInt64})
232232
case openapi3.TypeString:
233-
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.TypeString})
233+
schemaRef = oas3.NewSchemaRef("", &oas3.Schema{Type: openapi3.NewTypesRef(openapi3.TypeString)})
234234
default:
235235
found := false
236236
for _, exType := range explicitCustomTypes {
@@ -287,20 +287,20 @@ func ParseSpringLineToSchema(line string) (string, *oas3.Schema, error) {
287287
javaTypeLc := strings.ToLower(strings.TrimSpace(m2a[1]))
288288
switch javaTypeLc {
289289
case openapi3.TypeBoolean:
290-
sch.Type = openapi3.TypeBoolean
290+
sch.Type = openapi3.NewTypesRef(openapi3.TypeBoolean)
291291
case openapi3.FormatDate:
292-
sch.Type = openapi3.TypeString
292+
sch.Type = openapi3.NewTypesRef(openapi3.TypeString)
293293
sch.Format = FormatStringDate
294294
case "datetime":
295-
sch.Type = openapi3.TypeString
295+
sch.Type = openapi3.NewTypesRef(openapi3.TypeString)
296296
sch.Format = FormatStringDateTime
297297
case openapi3.TypeInteger:
298-
sch.Type = openapi3.TypeInteger
298+
sch.Type = openapi3.NewTypesRef(openapi3.TypeInteger)
299299
case "long":
300-
sch.Type = openapi3.TypeInteger
300+
sch.Type = openapi3.NewTypesRef(openapi3.TypeInteger)
301301
sch.Format = FormatIntegerInt64
302302
case openapi3.TypeString:
303-
sch.Type = openapi3.TypeString
303+
sch.Type = openapi3.NewTypesRef(openapi3.TypeString)
304304
default:
305305
panic(fmt.Sprintf("TYPE [%v] LINE [%v]", javaTypeLc, line))
306306
}

openapi3/springopenapi3/spring_parser_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package springopenapi3
22

33
import (
44
"testing"
5+
6+
"github.com/grokify/spectrum/openapi3"
57
)
68

79
var parseLineTests = []struct {
@@ -32,7 +34,7 @@ func TestParseLine(t *testing.T) {
3234
t.Errorf("fromspring.ParseSpringLineToSchema() [%v]", err)
3335
}
3436
schema := schemaRef.Value
35-
if tt.oasName != name || tt.oasType != schema.Type || tt.oasFormat != schema.Format {
37+
if tt.oasName != name || tt.oasType != openapi3.TypesRefString(schema.Type) || tt.oasFormat != schema.Format {
3638
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)
3739
}
3840
//fmtutil.PrintJSON(schema)

openapi3/visit.go

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,30 @@ func VisitTypesFormats(spec *Spec, visitTypeFormat func(jsonPointerRoot, oasType
2121
continue
2222
}
2323
for propName, propRef := range schemaRef.Value.Properties {
24-
if propRef.Value == nil {
24+
if propRef.Value == nil || propRef.Value.Type == nil {
2525
continue
2626
}
27-
visitTypeFormat(
28-
fmt.Sprintf(jPtrSchemaPropertyFormat, schemaName, propName),
29-
propRef.Value.Type,
30-
propRef.Value.Format)
27+
for _, t := range *propRef.Value.Type {
28+
visitTypeFormat(
29+
fmt.Sprintf(jPtrSchemaPropertyFormat, schemaName, propName),
30+
t,
31+
propRef.Value.Format)
32+
}
3133
}
3234
}
3335
for paramName, paramRef := range spec.Components.Parameters {
3436
if paramRef.Value == nil ||
3537
paramRef.Value.Schema == nil ||
36-
paramRef.Value.Schema.Value == nil {
38+
paramRef.Value.Schema.Value == nil ||
39+
paramRef.Value.Schema.Value.Type == nil {
3740
continue
3841
}
39-
visitTypeFormat(
40-
fmt.Sprintf(jPtrParamFormat, paramName),
41-
paramRef.Value.Schema.Value.Type,
42-
paramRef.Value.Schema.Value.Format)
42+
for _, t := range *paramRef.Value.Schema.Value.Type {
43+
visitTypeFormat(
44+
fmt.Sprintf(jPtrParamFormat, paramName),
45+
t,
46+
paramRef.Value.Schema.Value.Format)
47+
}
4348
}
4449
VisitOperations(
4550
spec,
@@ -50,14 +55,17 @@ func VisitTypesFormats(spec *Spec, visitTypeFormat func(jsonPointerRoot, oasType
5055
for i, paramRef := range op.Parameters {
5156
if paramRef.Value == nil ||
5257
paramRef.Value.Schema == nil ||
53-
paramRef.Value.Schema.Value == nil {
58+
paramRef.Value.Schema.Value == nil ||
59+
paramRef.Value.Schema.Value.Type == nil {
5460
continue
5561
}
56-
visitTypeFormat(
57-
jsonpointer.PointerSubEscapeAll(
58-
"#/paths/%s/%s/parameters/%d/schema", path, strings.ToLower(method), i),
59-
paramRef.Value.Schema.Value.Type,
60-
paramRef.Value.Schema.Value.Format)
62+
for _, t := range *paramRef.Value.Schema.Value.Type {
63+
visitTypeFormat(
64+
jsonpointer.PointerSubEscapeAll(
65+
"#/paths/%s/%s/parameters/%d/schema", path, strings.ToLower(method), i),
66+
t,
67+
paramRef.Value.Schema.Value.Format)
68+
}
6169
}
6270
},
6371
)

openapi3edit/schemas.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (se *SpecEdit) SchemaSetAdditionalPropertiesTrue(pointerBase string) []stri
197197
return mods
198198
}
199199
for schName, schRef := range se.SpecMore.Spec.Components.Schemas {
200-
if schRef == nil || schRef.Value == nil || schRef.Value.Type != openapi3.TypeObject {
200+
if schRef == nil || schRef.Value == nil || !openapi3.TypesRefIs(schRef.Value.Type, openapi3.TypeObject) {
201201
continue
202202
}
203203
/*
@@ -215,7 +215,7 @@ func (se *SpecEdit) SchemaSetAdditionalPropertiesTrue(pointerBase string) []stri
215215
mods = append(mods, fmt.Sprintf("%s%s/%s", pointerBase, openapi3.PointerComponentsSchemas, schName))
216216
}
217217
for propName, propRef := range schRef.Value.Properties {
218-
if propRef == nil || propRef.Value == nil || propRef.Value.Type != openapi3.TypeObject {
218+
if propRef == nil || propRef.Value == nil || !openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeObject) {
219219
continue
220220
}
221221
/*

openapi3edit/schemas_flatten.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ func (se *SpecEdit) SchemasFlattenSchemaRef(baseName, schName string, schRef *oa
3737
if propRef == nil || propRef.Value == nil {
3838
continue
3939
}
40-
if propRef.Value.Type == openapi3.TypeArray {
40+
if openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeArray) {
4141
itemsRef := propRef.Value.Items
4242
if itemsRef == nil {
4343
continue
4444
}
4545
itemsRef.Ref = strings.TrimSpace(itemsRef.Ref)
4646
if itemsRef.Value != nil &&
47-
(itemsRef.Value.Type == openapi3.TypeArray || itemsRef.Value.Type == openapi3.TypeObject) {
47+
(openapi3.TypesRefIs(itemsRef.Value.Type, openapi3.TypeArray, openapi3.TypeObject)) {
4848
if len(itemsRef.Ref) > 0 {
4949
propRef.Value.Items = oas3.NewSchemaRef(itemsRef.Ref, nil)
5050
} else {
@@ -61,7 +61,7 @@ func (se *SpecEdit) SchemasFlattenSchemaRef(baseName, schName string, schRef *oa
6161
//itemsRef.Ref = openapi3.PointerComponentsSchemas + "/" + newSchemaName
6262
}
6363
//} else if propRef.Value.Type == openapi3.TypeObject {
64-
} else if propRef.Value.Type == openapi3.TypeObject {
64+
} else if openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeObject) {
6565
if len(propRef.Value.Properties) > 0 {
6666
newSchemaName := basePlusSchName + stringsutil.ToUpperFirst(propName, false)
6767
if _, ok := spec.Components.Schemas[newSchemaName]; ok {
@@ -95,7 +95,7 @@ func (se *SpecEdit) SchemaRefsFlatten() error {
9595
}
9696
// visitSchemaRefFunc(propSchemaName, propSchemaRef)
9797
if len(propSchemaRef.Ref) == 0 && propSchemaRef.Value != nil {
98-
if propSchemaRef.Value.Type == openapi3.TypeObject || propSchemaRef.Value.Type == openapi3.TypeArray {
98+
if openapi3.TypesRefIs(propSchemaRef.Value.Type, openapi3.TypeObject, openapi3.TypeArray) {
9999
newRootSchemaName := propSchemaName
100100
if _, ok := spec.Components.Schemas[newRootSchemaName]; ok {
101101
newRootSchemaName = schName + stringsutil.ToUpperFirst(newRootSchemaName, false)

openapi3edit/validate_and_fix.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (se *SpecEdit) ValidateFixOperationPathParameters(fix bool) ([]*openapi3.Op
9090
Required: true,
9191
Schema: &oas3.SchemaRef{
9292
Value: &oas3.Schema{
93-
Type: "string",
93+
Type: openapi3.NewTypesRef(openapi3.TypeString),
9494
},
9595
},
9696
},
@@ -190,7 +190,7 @@ func (se *SpecEdit) ValidateFixOperationResponseTypes(fix bool) ([]*openapi3.Ope
190190
if len(schemaRef.Ref) == 0 {
191191
schema := schemaRef.Value
192192
schemaType := schema.Type
193-
if fix && (schemaType == openapi3.TypeString || schemaType == openapi3.TypeInteger) {
193+
if fix && openapi3.TypesRefIs(schemaType, openapi3.TypeString, openapi3.TypeInteger) {
194194
delete(response.Value.Content, mediaTypeOrig)
195195
if mtRefTry, ok := response.Value.Content[httputilmore.ContentTypeTextPlain]; ok {
196196
if !reflect.DeepEqual(mtRef, mtRefTry) {
@@ -202,7 +202,7 @@ func (se *SpecEdit) ValidateFixOperationResponseTypes(fix bool) ([]*openapi3.Ope
202202
} else {
203203
response.Value.Content[httputilmore.ContentTypeTextPlain] = mtRef
204204
}
205-
} else if schemaType != openapi3.TypeObject && schemaType != openapi3.TypeArray {
205+
} else if !openapi3.TypesRefIs(schemaType, openapi3.TypeObject, openapi3.TypeArray) {
206206
om := openapi3.OperationToMeta(path, method, op, []string{})
207207
om.MetaNotes = append(om.MetaNotes,
208208
fmt.Sprintf("E_BAD_MIME_TYPE_AND_SCHEMA MT[%s] type[%s]", mediaType, schemaType))

openapi3lint/ruleschemaobjectpropsexist/rule_schema_object_props_exist.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (rule RuleSchemaObjectPropsExist) ProcessSpec(spec *openapi3.Spec, pointerB
3333
vios := []lintutil.PolicyViolation{}
3434

3535
for schName, schRef := range spec.Components.Schemas {
36-
if schRef == nil || schRef.Value == nil || schRef.Value.Type != openapi3.TypeObject {
36+
if schRef == nil || schRef.Value == nil || !openapi3.TypesRefIs(schRef.Value.Type, openapi3.TypeObject) {
3737
continue
3838
}
3939
/*
@@ -56,7 +56,7 @@ func (rule RuleSchemaObjectPropsExist) ProcessSpec(spec *openapi3.Spec, pointerB
5656
pointerBase, schName)})
5757
}
5858
for propName, propRef := range schRef.Value.Properties {
59-
if propRef == nil || propRef.Value == nil || propRef.Value.Type != openapi3.TypeObject {
59+
if propRef == nil || propRef.Value == nil || !openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeObject) {
6060
continue
6161
}
6262
/*

openapi3lint/ruleschemapropenumstyle/rule_schema_prop_enum_style.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ func (rule RuleSchemaPropEnumStyle) ProcessSpec(spec *openapi3.Spec, pointerBase
5454
vios := []lintutil.PolicyViolation{}
5555

5656
for schName, schRef := range spec.Components.Schemas {
57-
if schRef == nil || schRef.Value == nil ||
58-
schRef.Value.Type != openapi3.TypeObject {
57+
if schRef == nil || schRef.Value == nil || !openapi3.TypesRefIs(schRef.Value.Type, openapi3.TypeObject) {
5958
continue
6059
}
6160

6261
for propName, propRef := range schRef.Value.Properties {
63-
if propRef.Value == nil ||
64-
propRef.Value.Type != "string" ||
62+
if propRef.Value == nil || !openapi3.TypesRefIs(propRef.Value.Type, openapi3.TypeString) ||
6563
len(propRef.Value.Enum) == 0 {
6664
continue
6765
}

0 commit comments

Comments
 (0)