-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(pkg/openapi3) Support schema in openapi3 format #136
Conversation
Codecov Report
@@ Coverage Diff @@
## master #136 +/- ##
==========================================
+ Coverage 82.14% 82.15% +0.01%
==========================================
Files 125 132 +7
Lines 5483 5907 +424
==========================================
+ Hits 4504 4853 +349
- Misses 664 723 +59
- Partials 315 331 +16
|
fbad000
to
8be015b
Compare
83a230c
to
d0cfa0c
Compare
Codecov Report
@@ Coverage Diff @@
## master #136 +/- ##
==========================================
- Coverage 82.70% 82.23% -0.47%
==========================================
Files 141 144 +3
Lines 6204 6385 +181
==========================================
+ Hits 5131 5251 +120
- Misses 725 761 +36
- Partials 348 373 +25
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR, I got a couple of comments regarding schema types.
pkg/providers/openapi3/schema.go
Outdated
func scalar(s *openapi.Schema) (specs.Template, error) { | ||
var t types.Type | ||
|
||
switch s.Type { | ||
case "string": | ||
t = types.String | ||
case "boolean": | ||
t = types.Bool | ||
case "number": | ||
t = types.Float | ||
case "integer": | ||
t = types.Int32 | ||
default: | ||
return specs.Template{}, fmt.Errorf("unknown type %s", s.Type) | ||
} | ||
|
||
return specs.Template{ | ||
Scalar: &specs.Scalar{Type: t}, | ||
}, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could easily add add support default
types fetched from openapi.Schema
.
default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if type is string, then default can be "foo" but cannot be 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I supported default for scalar types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*I just supported, pls take a look at the commit.
f3aad11
to
dc2d7d7
Compare
dc2d7d7
to
f484121
Compare
This PR introduces support for OpenAPI3 schema specifications. OpenAPI3 services/endpoints are not included due to OpenAPI3 implementation.