Skip to content

When not specifying a model for http_codes invalid model is created #385

Closed
@wleeper

Description

@wleeper

Expected: The default behavior when no model is specified for an output 200/201 message should not produce a schema tag for the output. This was how grape-swagger worked for in 0.10.2

Actual: A definition matching the endpoint name and based on input parameters is created and used as the output schema. This seems overly idealistic. There are many cases where an endpoint will take in parameters and return something entirely different as output. This puts a requirement to define an output model for every endpoint.

The code that generates this definition is something I would like to see used however to optionally create an input scheme based on the parameters, that is another story though

Example:

...
        #
        desc 'Return reticulated value for a spline',
          http_codes: [
            { code: 200, message: 'is Spline Reticulated' },
            { code: 404, message: 'Not Found' }
          ]
        params do
          requires :id, type: Integer, desc: 'Spline id.'
        end
        get ':id/reticulated' do
          error!({ code: 404, message: 'Not Found' }) unless @@splines[params[:id] -1]
          present @@splines[params[:id] -1].reticulated
        end
...

Produces:

"/splines/{id}/reticulated": {
"get": {
"description": "Return reticulated value for a spline",
"produces": [
"application/json"
],
"parameters": [
{
"in": "path",
"name": "id",
"description": "Spline id.",
"type": "integer",
"format": "int32",
"required": true
}
],
"responses": {
"200": {
"description": "is Spline Reticulated",
"schema": {
"$ref": "#/definitions/Reticulated"
}
},
"404": {
"description": "Not Found"
}
},
"tags": [
"splines"
],
"operationId": "getSplinesIdReticulated"
}
},

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions