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

Feedback #31

Closed
assem-ch opened this issue Mar 4, 2020 · 10 comments
Closed

Feedback #31

assem-ch opened this issue Mar 4, 2020 · 10 comments

Comments

@assem-ch
Copy link

assem-ch commented Mar 4, 2020

Thank you for this library, this will be very useful for people who wants to use pydantic in their APIs.

I had some issues when I tried the lib:

  • The JSON body is always requested in swagger/redoc in every endpoint even if it's a GET or need no body
  • The headers are working for me when I use postman, but in documentation they are shown as an object and they are not passed to endpoints.
  • Can you add option to select what documentation to expose at registration step, and if possible option to change the doc url
  • I guess you are validating the response even if there is no validation is set up : The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a int.. I think you have to keep everything optional.
  • If possible to add description to each endpoint
@kemingy
Copy link
Member

kemingy commented Mar 4, 2020

Thanks for your feedback.

  1. I don't really understand this issue. Is it related to Remove requestBody field for operations that don't have them #22 ? If not, can you give me some details?
  2. I find the Swagger frontend API console has some bugs for headers. I'll check this.
  3. Currently the config
    self.PATH = 'apidoc'
    support to change the /apidoc to other paths. This can be done by SpecTree('flask', path='doc'). I can set a default UI in this path that can be changed during registration.
  4. The response will be validated only when resp is set with pydantic.BaseModel.
    if resp and resp.has_model():
    model = resp.find_model(response.status_code)
    model.validate(response.get_json())
    return response
    def has_model(self):
    """
    :returns: boolean -- does this response has models or not
    """
    return True if self.code_models else False

    As for your error message, can you offer the code?
  5. The function docs will be used as endpoints' summary(first line) and description(the rest). Try the demo. I guess the tutorial is not good enough.

@assem-ch
Copy link
Author

assem-ch commented Mar 4, 2020

  1. yes

Screen Shot 2020-03-04 at 3 46 18 PM

  1. can you present the headers documention as this:

Screen Shot 2020-03-04 at 3 50 53 PM

4. the error is 500, internal error:
[x]   File "/usr/local/lib/python3.7/site-packages/werkzeug/test.py", line 1096, in run_wsgi_app
[x]     app_rv = app(environ, start_response)
[x] TypeError: 'dict' object is not callable

@kemingy
Copy link
Member

kemingy commented Mar 4, 2020

  1. Is this because of you passed json argument in validate()? I didn't find this error when I run the demo code in README.

For 1 and 4, can you give me some examples to reproduce this error?

@assem-ch
Copy link
Author

assem-ch commented Mar 4, 2020

  1. that its for every endpoint , not just json, even GET has it. I am using the version in pypi, may be not the same as master's?
    . 4. try to not set the resp argument

@kemingy
Copy link
Member

kemingy commented Mar 5, 2020

For 1, I'll remove JSON body in GET.

For 4, if you are using flask as the backend service, you should return what you want. For example: return jsonify(msg='hello'). I cannot reproduce this. Can you give me a minimal reproducible example?

@assem-ch
Copy link
Author

assem-ch commented Mar 5, 2020

  1. Sorry my mistake, I didn't use the jsonify , the lib I was using before was doing json-ification automatically

I can contribute with code , so please just let me if you need any help

@assem-ch
Copy link
Author

assem-ch commented Mar 5, 2020

  1. please remove json body even in posts when there is no JSON specified.
  2. (new) for the json param in validate, what do you think about using the name body instead

@kemingy
Copy link
Member

kemingy commented Mar 6, 2020

  1. It won't have JSON request body in swagger unless you use validate(json=MyJSONobject). If you still get this error, please offer some example code to reproduce it.
  2. JSON is not the only HTTP content-type. So it should be specific as json.

@kemingy
Copy link
Member

kemingy commented Mar 8, 2020

The header issue in Swagger page should be fixed in v0.2.8.

@kemingy
Copy link
Member

kemingy commented Mar 16, 2020

I'll close this issue. Feel free to re-open it if you still have the same questions.

@kemingy kemingy closed this as completed Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants