-
Notifications
You must be signed in to change notification settings - Fork 477
POST and PUT requests add 201 response by default #490
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
Comments
hi @pezholio … did I understanding it right, two response objects would be generated in the swagger documentation, one with In my understanding of the http status codes, this is the most correct documentation for your described please can you provide a pseudo code – perfectly as a spec 😉 - so it can be reproduced and documented, thanks |
Hi, Here's my actual code:
The expected result would be for only one response (a 202) to be generated, but Grape Swagger seems to generate a response for 201 as well, as shown here: ...
{
"responses": {
"201": {
"description": "Creates a dataset for an authenticated user. Returns a Job URL, which you can then poll to check the creation status of a job",
"schema": {
"$ref": "#/definitions/Dataset"
}
},
"202": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Job"
}
}
}
}
... |
ah, I see … what I'm still intersted in is, how looks the definition of |
Here you go 😄 module Octopub
module Entities
class Dataset < Grape::Entity
include GrapeRouteHelpers::NamedRouteMatcher
expose :id
expose :url do |dataset|
api_datasets_path(id: dataset.id)
end
expose :name
expose :description
expose :publisher do
expose :publisher_name, as: :name
expose :publisher_url, as: :url
end
expose :license do |dataset|
license = Odlifier::License.define(dataset.license)
{
id: license.id,
title: license.title,
url: license.url
}
end
expose :frequency
expose :owner
expose :url, as: :github_url
expose :gh_pages_url
expose :certificate_url
expose :dataset_files, using: Octopub::Entities::File, as: :files, documentation: { is_array: true }
end
end
end |
no, sorry I mean the swagger definition for Dataset, if they exist |
Ah, gotcha - here you go: {
"Dataset": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"github_url": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"publisher": {
"type": "string"
},
"license": {
"type": "string"
},
"frequency": {
"type": "string"
},
"owner": {
"type": "string"
},
"gh_pages_url": {
"type": "string"
},
"certificate_url": {
"type": "string"
},
"files": {
"type": "array",
"items": {
"$ref": "#/definitions/File"
}
}
},
"description": "Edits a dataset for an authenticated user. Returns a Job URL, which you can then poll to check the creation status of a job"
}
} I've put the whole generated Swagger file in a gist if that helps too |
it looks all fine, but of this #file-swagger-json-L483, here is the bug … please can you provide a spec for only this part |
… and you should add:
but this isn't valid in swagger :( |
I opened an issue #748 for it |
Ah, nice. Thanks 👍 I'll try and get a spec written up today for the other issue 😄 |
I've added a failing spec here: The result is:
I assume that the issue is because grape-swagger assumes all PUT and POST requests will result in a 201 response by default, and |
Fixed by #491 |
My app actually returns a 202, as the job is queued and a URL to poll is returned, but the generated Swagger docs return a 201 response, as well as my (correct) 202 response. Is this by design? If so, can I override this?
The text was updated successfully, but these errors were encountered: