-
Notifications
You must be signed in to change notification settings - Fork 435
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
Add Open API document for OSB API #389
Conversation
Hey n3wscott! Thanks for submitting this pull request! I'm here to inform the recipients of the pull request that you and the commit authors have already signed the CLA. |
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.
When validating I get:
Errors
Schema error at components.parameters['APIVersion']
should NOT have additional properties
additionalProperty: default, schema
Jump to line 379
Schema error at components.parameters['APIVersion'].in
should be equal to one of the allowed values
allowedValues: path, query, cookie
Jump to line 381
Also, as an FYI, this would be a breaking change for service authors that currently use the 2.12 swagger spec to generate code since you changed parameters and objects slightly. I'm not (necessarily) saying that's a problem.
I'll have more time to review next week.
@rhodie27 Yes, there is an open bug with swagger editor not pulling in parameters from components correctly. swagger-api/swagger-ui#3976 swagger-api/swagger-ui#3558 But I think what is in this PR is correct based on the Open API spec. The swagger UI works correctly. I will double check the spec... I think I am correct and the tools have not caught up to the new stuff in 3.0.0. https://swagger.io/docs/specification/components/ |
Here are some random nit-picking comments.
|
I would vote for no validation in the first version of the swagger spec. It might be useful to not have the validation in to allow folks to poke at bad brokers. If we still want validation, could it be a followup exercise?
The spec says MAY for an error and expected to be
I opted to only use the spec. I have updated based on feedback, adding the missing return types and enums, but I am hesitating to add more validation to the doc just because it is hard to know when to stop. I think it could be a valuable addition to the Open API document, but it is still possible to do as a followup and we could do it one resources |
schema: | ||
$ref: '#/components/schemas/ServiceInstanceUpdateRequest' | ||
responses: | ||
'200': |
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.
This is missing the operation
field that is valid in the response of PATCH on Service Instances
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.
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.
done.
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.
Looking at the spec, for PATCH it says this:
200 --> MUST be returned if the request's changes have been applied. The expected response body is {}.
So the spec does not say the operation
field is allowed.
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.
@n3wscott I agree; operation
shouldn't be returned here as a 200 implies the update has completed synchronously.
type: boolean | ||
responses: | ||
'200': | ||
description: OK |
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.
This is missing the operation field that is valid in the response of DELETE on Service Instances
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.
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.
done.
So, what's the meaning of this excerpt:
|
@fmui it means that 409 must at least return |
@avade thanks for the review! I will fix those missing return params up when I next get a chance. |
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.
Added AsyncOperation. @avade please remove conflict label.
type: boolean | ||
responses: | ||
'200': | ||
description: OK |
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.
done.
schema: | ||
$ref: '#/components/schemas/ServiceInstanceUpdateRequest' | ||
responses: | ||
'200': |
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.
done.
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 a lot @mattmcneeney for the review!
Check out the new version with the updates here: Live
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/AsyncOperation' |
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.
This was a mistake, AsyncOperation was suppose to be used for only the update, not the create.
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ServiceInstanceProvision' |
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.
This is true. My argument is it might not hurt anything to allow an optional field be defined in the Open API doc for the 201 case. the 200 and 202 cases are the same object.
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ServiceInstanceProvision' |
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.
The 200 could apply to the sync or async cases.
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Object' |
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.
This is what the spec says:
400 -> MUST be returned if the request is malformed or missing mandatory data.
And then
Service Brokers can include a user-facing message in the description field;
I struggled with this TBH, the spec says some responses should {}
some should be in the { "error":"" , "description":""}
form and some it does not say. The line below the table says the quote above but it is not clear is that applies to all or some.
So I opted to define the response as Object at least, and where the spec calls it out, define the response as Error.
Perhaps this is something we update after the doc has some usage if it is not working for folks or is unclear.
schema: | ||
$ref: '#/components/schemas/ServiceInstanceUpdateRequest' | ||
responses: | ||
'200': |
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.
Looking at the spec, for PATCH it says this:
200 --> MUST be returned if the request's changes have been applied. The expected response body is {}.
So the spec does not say the operation
field is allowed.
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Object' |
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 made an issue to clear this up.
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' |
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.
This is not how I read the spec.
I made an issue to clear this up.
The Error object has both fields optional.
- volume_mount | ||
bindable: | ||
type: boolean | ||
metadata: |
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 a bad idea. Added.
openapi.yaml
Outdated
- service_id | ||
properties: | ||
context: | ||
$ref: '#/components/schemas/Object' |
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.
done.
openapi.yaml
Outdated
- plan_id | ||
properties: | ||
context: | ||
$ref: '#/components/schemas/Object' |
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.
done
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 for the speedy turnaround @n3wscott 👏
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ServiceInstanceProvision' |
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.
Ah. I hadn't considered returning the id of a completed async operation (when a service instance has successfully been provisioned async).
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ServiceInstanceProvision' |
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.
Yeah, but that could make platform authors write logic to handle polling when they get a 201 which should never be used.
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/AsyncOperation' |
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.
👍
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Object' |
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.
Sounds good. If we can use this PR as an opportunity to clear up ambiguities in the spec, then I'd love for any error to be able to return the defined error object :)
schema: | ||
$ref: '#/components/schemas/ServiceInstanceUpdateRequest' | ||
responses: | ||
'200': |
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.
@n3wscott I agree; operation
shouldn't be returned here as a 200 implies the update has completed synchronously.
application/json: | ||
schema: | ||
$ref: '#/components/schemas/AsyncOperation' | ||
'400': |
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.
Awesome, thanks!
application/json: | ||
schema: | ||
$ref: '#/components/schemas/AsyncOperation' | ||
'400': |
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.
👍
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Object' |
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.
👍
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Object' |
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.
Tracking in #403
openapi.yaml
Outdated
plan_id: | ||
type: string | ||
context: | ||
$ref: '#/components/schemas/Object' |
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.
Did you spot this one too @n3wscott ?
items: | ||
$ref: '#/components/schemas/Service' | ||
|
||
Service: |
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 believe this and all others need to include the type: object
attribute, otherwise you're saying they can also be arrays or primitives. At least that's how it was in OpenAPI 2.0.
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.
Nice catch!
openapi.yaml
Outdated
# This is the Open API interface for Open Service Broker API. Every attempt will | ||
# be made to make the Open API version of OSB API accurately represent the | ||
# written specification. If the spec and this document conflict, the spec is | ||
# the authroity. |
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.
s/authroity/authority/
Would it make sense to put a link to the rendered swagger on the repo README so that it is easily accessible by people? |
Sounds like a good follow-up. Maybe even a symlink to a git tag when next release happens. |
paths: | ||
/v2/catalog: | ||
get: | ||
summary: get the catalog of services that the service broker offers |
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.
Can we start these with capital letters? Get the catalog...
It looks better to me when generated.
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 can in a follow-up!
I'm new to OAPI but is there a way in the "Example Value" that it generates to have it do something like add a "?" when a field is optional? Showing that example is really helpful, but I'm missing the required/optional aspect of each field. |
@maximilien ^^ |
@duglin This is a quirk of the default swagger ui, click the tab next to "example value" called "Model" and you will see the object in table format with the required fields with descriptions if the model has them. |
Ah, I didn't realize the "Model" thing was a link - nice |
@n3wscott did you want to fix the two spots @mattmcneeney commented on? |
@duglin the error pr is not in yet I think |
Sorry, not sure what you mean by "error pr" |
Matt are your issues resolved? github shows you're still requesting changes |
Yes - but if we can get #409 merged then it'd be awesome to update the OpenAPI doc with that change before merging it in (as it makes many of the errors much simpler) |
@n3wscott I think there are a few edits that people want to see before we merge this - any chance of getting those in? |
Relates to #160
Ready.