Skip to content
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

Not including a 'produces' in a swagger definition results in an error #53

Closed
iwsmith opened this issue Aug 19, 2015 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@iwsmith
Copy link

iwsmith commented Aug 19, 2015

Hi again,

I found out that if you don't include produces section you will get a very odd error:

Traceback (most recent call last):
  File "/Users/iwsmith/anaconda/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/iwsmith/anaconda/lib/python2.7/site-packages/flask/app.py", line 1478, in full_dispatch_request
    response = self.make_response(rv)
  File "/Users/iwsmith/anaconda/lib/python2.7/site-packages/flask/app.py", line 1577, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/Users/iwsmith/anaconda/lib/python2.7/site-packages/werkzeug/wrappers.py", line 841, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/Users/iwsmith/anaconda/lib/python2.7/site-packages/werkzeug/test.py", line 867, in run_wsgi_app
    app_rv = app(environ, start_response)
TypeError: 'object' object is not callable

The swagger fragment that generated this is below:

/feedback/{transaction_id}:
    put:
      description: Notify Babel of actions taken based on a recommendations
      consumes:
      - application/json
      operationId: app.put_feedback
      parameters:
        - in: path
          name: transaction_id
          type: string
          required: true
        - in: query
          name: action
          type: string
          required: true
          enum:
          - click
          - download
        - $ref: '#/parameters/paper_id_query'
        - $ref: '#/parameters/publisher_query'
        - $ref: '#/parameters/client_id'
      responses:
        "200":
          description: OK

I fixed this by including a produces: -application/json in the definition.

@hjacobs
Copy link
Contributor

hjacobs commented Aug 24, 2015

Probably it makes sense to assume "application/json" as default? The Swagger spec does not mention any default behavior and "produces" seems to be optional.

@iwsmith
Copy link
Author

iwsmith commented Aug 24, 2015

That seems like a reasonable default, though I think adding a more descriptive error message would also be a reasonable, and potentially less surprising. Both are good though :-)

@hjacobs hjacobs added the bug label Aug 24, 2015
jmcs added a commit that referenced this issue Aug 26, 2015
@jmcs jmcs self-assigned this Aug 26, 2015
jmcs added a commit that referenced this issue Aug 26, 2015
@jmcs jmcs added this to the 0.9 milestone Aug 26, 2015
jmcs added a commit that referenced this issue Aug 26, 2015
@jmcs jmcs closed this as completed Aug 26, 2015
@jmcs jmcs removed the in progress label Aug 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants