Skip to content

Commit fffb348

Browse files
Update api spec (#95)
* YOYO NEW API SPEC! * fixes Signed-off-by: Jess Frazelle <[email protected]> * fix base64 Signed-off-by: Jess Frazelle <[email protected]> * bump version Signed-off-by: Jess Frazelle <[email protected]> --------- Signed-off-by: Jess Frazelle <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 5121d43 commit fffb348

13 files changed

+2372
-1489
lines changed

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.2.21
1+
v0.2.22

cmd/json_base64.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ func (u Base64) MarshalJSON() ([]byte, error) {
1717
return []byte("null"), nil
1818
}
1919

20-
return []byte(`"` + base64.StdEncoding.EncodeToString(u.Inner) + `"`), nil
20+
return []byte(`"` + base64.RawStdEncoding.EncodeToString(u.Inner) + `"`), nil
2121
}
2222

2323
func (u Base64) String() string {
2424
if u.Inner == nil {
2525
return ""
2626
}
2727

28-
return base64.StdEncoding.EncodeToString(u.Inner)
28+
return base64.RawStdEncoding.EncodeToString(u.Inner)
2929
}
3030

3131
// UnmarshalJSON implements the json.Unmarshaler interface.
@@ -45,7 +45,7 @@ func (u *Base64) UnmarshalJSON(data []byte) (err error) {
4545
}
4646

4747
// Fractional seconds are handled implicitly by Parse.
48-
uu, err := base64.StdEncoding.DecodeString(strings.Trim(string(data), `"`))
48+
uu, err := base64.RawStdEncoding.DecodeString(strings.Trim(string(data), `"`))
4949
if err != nil {
5050
return err
5151
}

cmd/json_base64_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@ func TestBase64Null(t *testing.T) {
3030
t.Errorf("UnmarshalJSON failed: %v", err)
3131
}
3232
}
33+
34+
func TestBase64String(t *testing.T) {
35+
var jsonBase64 Base64
36+
if err := jsonBase64.UnmarshalJSON([]byte("diAtMC4wMDEgLTAuMDAxIDAuMDAxCnYgMC4wMDEgLTAuMDAxIDAuMDAxCnYgMC4wMDEgMC4wMDEgMC4wMDEKdiAtMC4wMDEgMC4wMDEgMC4wMDEKdiAtMC4wMDEgMC4wMDEgLTAuMDAxCnYgMC4wMDEgMC4wMDEgLTAuMDAxCnYgMC4wMDEgLTAuMDAxIC0wLjAwMQp2IC0wLjAwMSAtMC4wMDEgLTAuMDAxCnZuIDAgMCAxCnZuIDAgMSAwCnZuIDEgMCAwCnZuIDAgMCAtMQp2biAtMSAwIDAKdm4gMCAtMSAwCm8gVW5uYW1lZC0wCmYgMS8vMSAyLy8xIDMvLzEKZiAxLy8xIDMvLzEgNC8vMQpmIDUvLzIgNC8vMiAzLy8yCmYgNS8vMiAzLy8yIDYvLzIKZiA2Ly8zIDMvLzMgMi8vMwpmIDYvLzMgMi8vMyA3Ly8zCmYgNy8vNCA4Ly80IDUvLzQKZiA3Ly80IDUvLzQgNi8vNApmIDgvLzUgMS8vNSA0Ly81CmYgOC8vNSA0Ly81IDUvLzUKZiA3Ly82IDIvLzYgMS8vNgpmIDcvLzYgMS8vNiA4Ly82Cg")); err != nil {
37+
t.Errorf("UnmarshalJSON failed: %v", err)
38+
}
39+
40+
if err := jsonBase64.UnmarshalJSON(nil); err != nil {
41+
t.Errorf("UnmarshalJSON failed: %v", err)
42+
}
43+
}

cmd/types.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ func (data *Data) generateObjectType(name string, s *openapi3.Schema, spec *open
250250
if v.Value.Type == "object" && v.Value.Properties != nil && len(v.Value.Properties) > 0 {
251251
// Check if we already have a schema for this one of.
252252
if _, ok := spec.Components.Schemas[k]; !ok {
253-
if err := data.generateObjectType(k, v.Value, spec); err != nil {
253+
n := printProperty(k)
254+
if n == "Error" {
255+
n = name + "Error"
256+
}
257+
if err := data.generateObjectType(n, v.Value, spec); err != nil {
254258
return err
255259
}
256260
}
@@ -325,7 +329,7 @@ func (data *Data) generateOneOfType(name string, s *openapi3.Schema, spec *opena
325329

326330
for index, oneOf := range s.OneOf {
327331
// We should have a better way of avoiding duplicates. This is a hot fix, but does not scale.
328-
if types[index] == "InputFormat coords" || types[index] == "OutputFormat coords" {
332+
if types[index] == "InputFormat coords" || types[index] == "OutputFormat coords" || types[index] == "ModelingCmd path" || types[index] == "ModelingCmd interaction" || types[index] == "ModelingCmd window" || types[index] == "OkModelingCmdResponse entity_id" {
329333
continue
330334
}
331335

examples_test.go

Lines changed: 15 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/perimeterx/marshmallow v1.1.4 // indirect
2424
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
2525
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect
26-
golang.org/x/sys v0.10.0 // indirect
26+
golang.org/x/sys v0.11.0 // indirect
2727
gopkg.in/yaml.v2 v2.4.0 // indirect
2828
gopkg.in/yaml.v3 v3.0.1 // indirect
2929
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
7575
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7676
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7777
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
78-
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
79-
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
78+
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
79+
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8080
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
8181
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
8282
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

json_base64.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ func (u Base64) MarshalJSON() ([]byte, error) {
1717
return []byte("null"), nil
1818
}
1919

20-
return []byte(`"` + base64.StdEncoding.EncodeToString(u.Inner) + `"`), nil
20+
return []byte(`"` + base64.RawStdEncoding.EncodeToString(u.Inner) + `"`), nil
2121
}
2222

2323
func (u Base64) String() string {
2424
if u.Inner == nil {
2525
return ""
2626
}
2727

28-
return base64.StdEncoding.EncodeToString(u.Inner)
28+
return base64.RawStdEncoding.EncodeToString(u.Inner)
2929
}
3030

3131
// UnmarshalJSON implements the json.Unmarshaler interface.
@@ -45,7 +45,7 @@ func (u *Base64) UnmarshalJSON(data []byte) (err error) {
4545
}
4646

4747
// Fractional seconds are handled implicitly by Parse.
48-
uu, err := base64.StdEncoding.DecodeString(strings.Trim(string(data), `"`))
48+
uu, err := base64.RawStdEncoding.DecodeString(strings.Trim(string(data), `"`))
4949
if err != nil {
5050
return err
5151
}

json_base64_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@ func TestBase64Null(t *testing.T) {
3030
t.Errorf("UnmarshalJSON failed: %v", err)
3131
}
3232
}
33+
34+
func TestBase64String(t *testing.T) {
35+
var jsonBase64 Base64
36+
if err := jsonBase64.UnmarshalJSON([]byte("diAtMC4wMDEgLTAuMDAxIDAuMDAxCnYgMC4wMDEgLTAuMDAxIDAuMDAxCnYgMC4wMDEgMC4wMDEgMC4wMDEKdiAtMC4wMDEgMC4wMDEgMC4wMDEKdiAtMC4wMDEgMC4wMDEgLTAuMDAxCnYgMC4wMDEgMC4wMDEgLTAuMDAxCnYgMC4wMDEgLTAuMDAxIC0wLjAwMQp2IC0wLjAwMSAtMC4wMDEgLTAuMDAxCnZuIDAgMCAxCnZuIDAgMSAwCnZuIDEgMCAwCnZuIDAgMCAtMQp2biAtMSAwIDAKdm4gMCAtMSAwCm8gVW5uYW1lZC0wCmYgMS8vMSAyLy8xIDMvLzEKZiAxLy8xIDMvLzEgNC8vMQpmIDUvLzIgNC8vMiAzLy8yCmYgNS8vMiAzLy8yIDYvLzIKZiA2Ly8zIDMvLzMgMi8vMwpmIDYvLzMgMi8vMyA3Ly8zCmYgNy8vNCA4Ly80IDUvLzQKZiA3Ly80IDUvLzQgNi8vNApmIDgvLzUgMS8vNSA0Ly81CmYgOC8vNSA0Ly81IDUvLzUKZiA3Ly82IDIvLzYgMS8vNgpmIDcvLzYgMS8vNiA4Ly82Cg")); err != nil {
37+
t.Errorf("UnmarshalJSON failed: %v", err)
38+
}
39+
40+
if err := jsonBase64.UnmarshalJSON(nil); err != nil {
41+
t.Errorf("UnmarshalJSON failed: %v", err)
42+
}
43+
}

0 commit comments

Comments
 (0)