-
Notifications
You must be signed in to change notification settings - Fork 11
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
Openapi 3.1 #17
Openapi 3.1 #17
Conversation
Adoption of softwaremill/tapir#1223 by @rojekp
Add Initial petstore example with test
Add Schema test from spec
|
||
sealed trait AnySchema extends SchemaLike | ||
|
||
object AnySchema { |
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.
suggestions for names here?
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.
not entirely sure if its useful to have the encodings in the model, or if this should possibly be a configuration of encoder.
not if then else
prefixItems, contains, patternProperties Introduce new Pattern wrapper to make it possible to write a validator for regex
Need to figure out how to deal with AsyncAPI since it does not really support all of json-schema. Should we assume that users that care about async-api will limit themselves to the subset that it supports? |
@adamw is this a direction that is interesting for the library? |
@hamnis Sure, sorry I somehow thought that this is WIP. I think most of these changes are source-backwards-compatible, so we should be able to use this in tapir, replacing the OpenAPI version? |
It is mostly source compatible yes, but it is not binary compatible. I just noticed the build failed. I will have a look. |
Yes, though in case of sttp-apispec we're still in 0.x versions, and as for tapir - this doesn't affect |
H @hamnis Thanks for your input. I'm trying to figure out if we could utilize these changes in the current tapir documentation creation logic by using locally build The small ones are:
but the expected form is:
but the expected value is:
If I'm not mistaken both of these problems should be solved as a part of this PR as encoders are here. The big ones i.e. breaking backward compatibility are:
In 3.1:
"exclusive" is no longer a boolean (failing test: "exclusive bounds" / "VerifyYamlTest")
In 3.1:
Old handling is not allowed as "In order to achieve the goal of letting JSON Schema tools understand OpenAPI, it was decided to remove nullable entirely instead of deprecate it." (failing test: "should mark optional fields as nullable when configured to do so" in "VerifyYamlTest") I'm not sure how to gracefully handle these... ( FYI @adamw ) |
the two small ones I will fix. Adds these as tests here as well. for the big ones, I suppose we can do something like I did for encoding of AnySchema, meaning a configuration of the Encoders. |
Yeah I guess having a single model, and configurable 3.0 and 3.1 encoders will do the trick. Thanks :) |
I suppose we could also add a jsonschema-circe module here and let the openapi depend on that. |
@rafalambrozewicz I think all issues should be resolved now. |
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.
Thanks, @hamnis - it did the trick, still, one new issue popped up, and two minor ones arose.
- unknown "extensions:" keyword gets added to yaml, when we want to add an extension. For example in "should add openapi extensions to the schema" / "VerifyYamlTest" test, the expected result is:
components:
schemas:
FruitAmount:
...
type: object
properties:
...
x-schema:
string: a
int: 1
but the actual is:
components:
schemas:
FruitAmount:
...
type: object
properties:
...
extensions:
x-schema:
string: a
int: 1
Two other issues are minor as produced yml is valid, but the order of properties seems odd.
- null handling, null information is the very first element, usually it is added as last (test: "should mark optional fields as nullable when configured to do so" / "VerifyYamlTest"):
expected:
optionalIntField:
type:integer
format:int32
nullable:true
actual:
optionalIntField:
nullable:true
type:integer
format:int32
- exclusiveMinimum / exclusiveMaximum information not next to "minimum" "maximum" (test: "exclusive bounds" / "VerifyYamlTest").
expected:
schema:
type: integer
format: int32
minimum: 0
exclusiveMinimum: true
maximum: 42
exclusiveMaximum: true
actual:
schema:
type: integer
format: int32
minimum: 0
maximum: 42
exclusiveMinimum: true
exclusiveMaximum: true
- Extension expansion - grouping of min/max with exclusive min/max
- nullable at end
@rafalambrozewicz I tested with running the tests on tapir/openapi docs and it passed. So I think this should be good now. https://gist.github.com/hamnis/3c1339e98627fe51d40018d431f95ca8 |
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.
Thanks, @hamnis I confirm that we are good now since all tapir docs generation tests are passing. In general, it looks good to me 👍 Still - I've added some questions and suggestions.
asyncapi-circe/src/main/scala/sttp/apispec/asyncapi/circe/package.scala
Outdated
Show resolved
Hide resolved
...pi-circe/src/main/scala/sttp/apispec/openapi/internal/InternalSttpOpenAPICirceDecoders.scala
Outdated
Show resolved
Hide resolved
openapi-model/src/main/scala/sttp/apispec/openapi/OpenAPI.scala
Outdated
Show resolved
Hide resolved
Added to make sure we need to check as little as possible for validation purposes.
Based on the PR in softwaremill/tapir#1271
Added some missing properties.
Need to work through the spec to make sure we have everything
Fixes #16
Adds parsing of openapi files for #2