Skip to content

Commit d996181

Browse files
authored
Upgrade github.com/pb33f/libopenapi to v0.14.4 (#111)
* upgrade to libopenapi `v0.14.3` * add changelog for bug fix * update to `v0.14.4`
1 parent f809dfa commit d996181

29 files changed

+867
-737
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: BUG FIXES
2+
body: Fixed a bug where schema defaults were not detected for integer/int32 properties
3+
time: 2023-12-20T13:31:59.436063-05:00
4+
custom:
5+
Issue: "111"

go.mod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/hashicorp/cli v1.1.6
88
github.com/hashicorp/terraform-plugin-codegen-spec v0.1.0
99
github.com/mattn/go-colorable v0.1.13
10-
github.com/pb33f/libopenapi v0.13.22
10+
github.com/pb33f/libopenapi v0.14.4
1111
gopkg.in/yaml.v3 v3.0.1
1212
)
1313

@@ -16,21 +16,25 @@ require (
1616
github.com/Masterminds/semver/v3 v3.2.0 // indirect
1717
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
1818
github.com/armon/go-radix v1.0.0 // indirect
19+
github.com/bahlo/generic-list-go v0.2.0 // indirect
1920
github.com/bgentry/speakeasy v0.1.0 // indirect
21+
github.com/buger/jsonparser v1.1.1 // indirect
2022
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
2123
github.com/fatih/color v1.16.0 // indirect
2224
github.com/google/uuid v1.3.0 // indirect
2325
github.com/hashicorp/errwrap v1.1.0 // indirect
2426
github.com/hashicorp/go-multierror v1.1.1 // indirect
2527
github.com/huandu/xstrings v1.4.0 // indirect
2628
github.com/imdario/mergo v0.3.15 // indirect
29+
github.com/mailru/easyjson v0.7.7 // indirect
2730
github.com/mattn/go-isatty v0.0.20 // indirect
2831
github.com/mitchellh/copystructure v1.2.0 // indirect
2932
github.com/mitchellh/reflectwalk v1.0.2 // indirect
3033
github.com/posener/complete v1.2.3 // indirect
3134
github.com/shopspring/decimal v1.3.1 // indirect
3235
github.com/spf13/cast v1.5.0 // indirect
3336
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
37+
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
3438
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
3539
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
3640
github.com/xeipuuv/gojsonschema v1.2.0 // indirect

go.sum

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj
66
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
77
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
88
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
9+
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
10+
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
911
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
1012
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
13+
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
14+
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
1115
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
1216
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
1317
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
@@ -62,13 +66,16 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:
6266
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
6367
github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
6468
github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
69+
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
6570
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
6671
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
6772
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
6873
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
6974
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
7075
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
7176
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
77+
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
78+
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
7279
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
7380
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
7481
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
@@ -95,8 +102,10 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
95102
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
96103
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
97104
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
98-
github.com/pb33f/libopenapi v0.13.22 h1:QivxHLf+ZaYl2mFivUFkKZ7315mtYMipaQP5zp0U1H4=
99-
github.com/pb33f/libopenapi v0.13.22/go.mod h1:Lv2eEtsAtbRFlF8hjH82L8SIGoUNgemMVoKoB6A9THk=
105+
github.com/pb33f/libopenapi v0.14.3 h1:GeUaHFre9WiI5jHAg283HvBNdxhSKfFkNQikNAj2gqY=
106+
github.com/pb33f/libopenapi v0.14.3/go.mod h1:m+4Pwri31UvcnZjuP8M7TlbR906DXJmMvYsbis234xg=
107+
github.com/pb33f/libopenapi v0.14.4 h1:NbcYaBbG/6pnJM8lw4F6b5e54HandyKF452HUl4+9j4=
108+
github.com/pb33f/libopenapi v0.14.4/go.mod h1:m+4Pwri31UvcnZjuP8M7TlbR906DXJmMvYsbis234xg=
100109
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
101110
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
102111
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
@@ -116,10 +125,12 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
116125
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
117126
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
118127
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
119-
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
120-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
128+
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
129+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
121130
github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk=
122131
github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ=
132+
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
133+
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
123134
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
124135
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
125136
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=

internal/cmd/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (cmd *GenerateCommand) runInternal(logger *slog.Logger) error {
160160
}
161161

162162
// 7. Log a warning if the provider code spec is not valid based on the JSON schema
163-
err = spec.Validate(context.Background(), bytes)
163+
err = spec.Validate(context.TODO(), bytes)
164164
if err != nil {
165165
logger.Warn(
166166
"generated provider code spec failed validation",

internal/cmd/testdata/kubernetes/provider_code_spec.json

Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,10 @@
755755
{
756756
"name": "weight",
757757
"int64": {
758-
"computed_optional_required": "required",
758+
"computed_optional_required": "computed_optional",
759+
"default": {
760+
"static": 0
761+
},
759762
"description": "Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100."
760763
}
761764
}
@@ -1033,7 +1036,10 @@
10331036
{
10341037
"name": "weight",
10351038
"int64": {
1036-
"computed_optional_required": "required",
1039+
"computed_optional_required": "computed_optional",
1040+
"default": {
1041+
"static": 0
1042+
},
10371043
"description": "weight associated with matching the corresponding podAffinityTerm, in the range 1-100."
10381044
}
10391045
}
@@ -1360,7 +1366,10 @@
13601366
{
13611367
"name": "weight",
13621368
"int64": {
1363-
"computed_optional_required": "required",
1369+
"computed_optional_required": "computed_optional",
1370+
"default": {
1371+
"static": 0
1372+
},
13641373
"description": "weight associated with matching the corresponding podAffinityTerm, in the range 1-100."
13651374
}
13661375
}
@@ -2087,7 +2096,10 @@
20872096
{
20882097
"name": "port",
20892098
"int64": {
2090-
"computed_optional_required": "required",
2099+
"computed_optional_required": "computed_optional",
2100+
"default": {
2101+
"static": 0
2102+
},
20912103
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535."
20922104
}
20932105
},
@@ -2254,7 +2266,10 @@
22542266
{
22552267
"name": "container_port",
22562268
"int64": {
2257-
"computed_optional_required": "required",
2269+
"computed_optional_required": "computed_optional",
2270+
"default": {
2271+
"static": 0
2272+
},
22582273
"description": "Number of port to expose on the pod's IP address. This must be a valid port number, 0 \u003c x \u003c 65536."
22592274
}
22602275
},
@@ -2333,7 +2348,10 @@
23332348
{
23342349
"name": "port",
23352350
"int64": {
2336-
"computed_optional_required": "required",
2351+
"computed_optional_required": "computed_optional",
2352+
"default": {
2353+
"static": 0
2354+
},
23372355
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535."
23382356
}
23392357
},
@@ -2795,7 +2813,10 @@
27952813
{
27962814
"name": "port",
27972815
"int64": {
2798-
"computed_optional_required": "required",
2816+
"computed_optional_required": "computed_optional",
2817+
"default": {
2818+
"static": 0
2819+
},
27992820
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535."
28002821
}
28012822
},
@@ -3699,7 +3720,10 @@
36993720
{
37003721
"name": "port",
37013722
"int64": {
3702-
"computed_optional_required": "required",
3723+
"computed_optional_required": "computed_optional",
3724+
"default": {
3725+
"static": 0
3726+
},
37033727
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535."
37043728
}
37053729
},
@@ -3866,7 +3890,10 @@
38663890
{
38673891
"name": "container_port",
38683892
"int64": {
3869-
"computed_optional_required": "required",
3893+
"computed_optional_required": "computed_optional",
3894+
"default": {
3895+
"static": 0
3896+
},
38703897
"description": "Number of port to expose on the pod's IP address. This must be a valid port number, 0 \u003c x \u003c 65536."
38713898
}
38723899
},
@@ -3945,7 +3972,10 @@
39453972
{
39463973
"name": "port",
39473974
"int64": {
3948-
"computed_optional_required": "required",
3975+
"computed_optional_required": "computed_optional",
3976+
"default": {
3977+
"static": 0
3978+
},
39493979
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535."
39503980
}
39513981
},
@@ -4407,7 +4437,10 @@
44074437
{
44084438
"name": "port",
44094439
"int64": {
4410-
"computed_optional_required": "required",
4440+
"computed_optional_required": "computed_optional",
4441+
"default": {
4442+
"static": 0
4443+
},
44114444
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535."
44124445
}
44134446
},
@@ -5332,7 +5365,10 @@
53325365
{
53335366
"name": "port",
53345367
"int64": {
5335-
"computed_optional_required": "required",
5368+
"computed_optional_required": "computed_optional",
5369+
"default": {
5370+
"static": 0
5371+
},
53365372
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535."
53375373
}
53385374
},
@@ -5499,7 +5535,10 @@
54995535
{
55005536
"name": "container_port",
55015537
"int64": {
5502-
"computed_optional_required": "required",
5538+
"computed_optional_required": "computed_optional",
5539+
"default": {
5540+
"static": 0
5541+
},
55035542
"description": "Number of port to expose on the pod's IP address. This must be a valid port number, 0 \u003c x \u003c 65536."
55045543
}
55055544
},
@@ -5578,7 +5617,10 @@
55785617
{
55795618
"name": "port",
55805619
"int64": {
5581-
"computed_optional_required": "required",
5620+
"computed_optional_required": "computed_optional",
5621+
"default": {
5622+
"static": 0
5623+
},
55825624
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535."
55835625
}
55845626
},
@@ -6040,7 +6082,10 @@
60406082
{
60416083
"name": "port",
60426084
"int64": {
6043-
"computed_optional_required": "required",
6085+
"computed_optional_required": "computed_optional",
6086+
"default": {
6087+
"static": 0
6088+
},
60446089
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535."
60456090
}
60466091
},
@@ -6851,7 +6896,10 @@
68516896
{
68526897
"name": "max_skew",
68536898
"int64": {
6854-
"computed_optional_required": "required",
6899+
"computed_optional_required": "computed_optional",
6900+
"default": {
6901+
"static": 0
6902+
},
68556903
"description": "MaxSkew describes the degree to which pods may be unevenly distributed. When `whenUnsatisfiable=DoNotSchedule`, it is the maximum permitted difference between the number of matching pods in the target topology and the global minimum. The global minimum is the minimum number of matching pods in an eligible domain or zero if the number of eligible domains is less than MinDomains. For example, in a 3-zone cluster, MaxSkew is set to 1, and pods with the same labelSelector spread as 2/2/1: In this case, the global minimum is 1. | zone1 | zone2 | zone3 | | P P | P P | P | - if MaxSkew is 1, incoming pod can only be scheduled to zone3 to become 2/2/2; scheduling it onto zone1(zone2) would make the ActualSkew(3-1) on zone1(zone2) violate MaxSkew(1). - if MaxSkew is 2, incoming pod can be scheduled onto any zone. When `whenUnsatisfiable=ScheduleAnyway`, it is used to give higher precedence to topologies that satisfy it. It's a required field. Default value is 1 and 0 is not allowed."
68566904
}
68576905
},
@@ -8185,7 +8233,10 @@
81858233
{
81868234
"name": "lun",
81878235
"int64": {
8188-
"computed_optional_required": "required",
8236+
"computed_optional_required": "computed_optional",
8237+
"default": {
8238+
"static": 0
8239+
},
81898240
"description": "lun represents iSCSI Target Lun number."
81908241
}
81918242
},

internal/explorer/config_explorer.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,29 @@ func extractOp(paths *high.Paths, oasLocation *config.OpenApiSpecLocation) (*hig
117117
return nil, nil
118118
}
119119

120-
if paths == nil || paths.PathItems == nil || paths.PathItems[oasLocation.Path] == nil {
120+
if paths == nil || paths.PathItems == nil || paths.PathItems.GetOrZero(oasLocation.Path) == nil {
121121
return nil, fmt.Errorf("path '%s' not found in OpenAPI spec", oasLocation.Path)
122122
}
123123

124+
pathItem, _ := paths.PathItems.Get(oasLocation.Path)
125+
124126
switch strings.ToLower(oasLocation.Method) {
125127
case low.PostLabel:
126-
return paths.PathItems[oasLocation.Path].Post, nil
128+
return pathItem.Post, nil
127129
case low.GetLabel:
128-
return paths.PathItems[oasLocation.Path].Get, nil
130+
return pathItem.Get, nil
129131
case low.PutLabel:
130-
return paths.PathItems[oasLocation.Path].Put, nil
132+
return pathItem.Put, nil
131133
case low.DeleteLabel:
132-
return paths.PathItems[oasLocation.Path].Delete, nil
134+
return pathItem.Delete, nil
133135
case low.PatchLabel:
134-
return paths.PathItems[oasLocation.Path].Patch, nil
136+
return pathItem.Patch, nil
135137
case low.OptionsLabel:
136-
return paths.PathItems[oasLocation.Path].Options, nil
138+
return pathItem.Options, nil
137139
case low.HeadLabel:
138-
return paths.PathItems[oasLocation.Path].Head, nil
140+
return pathItem.Head, nil
139141
case low.TraceLabel:
140-
return paths.PathItems[oasLocation.Path].Trace, nil
142+
return pathItem.Trace, nil
141143
default:
142144
return nil, fmt.Errorf("method '%s' not found at OpenAPI path '%s'", oasLocation.Method, oasLocation.Path)
143145
}
@@ -158,7 +160,7 @@ func extractSchemaProxy(document high.Document, componentRef string) (*highbase.
158160
}
159161

160162
// populate low-level schema, using root document.Index for resolving
161-
err = lowSchema.Build(context.Background(), indexRef.Node, document.Index)
163+
err = lowSchema.Build(context.TODO(), indexRef.Node, document.Index)
162164
if err != nil {
163165
return nil, fmt.Errorf("error populating low-level schema: %w", err)
164166
}

0 commit comments

Comments
 (0)