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

adding example field to request_schema #89

Closed
Niccolum opened this issue May 6, 2020 · 10 comments
Closed

adding example field to request_schema #89

Niccolum opened this issue May 6, 2020 · 10 comments

Comments

@Niccolum
Copy link

Niccolum commented May 6, 2020

So, i see, that decorator @request_schema doesn't have example field (it not pass to options)
So, I can offer the following solution:

def request_schema(schema, locations=None, put_into=None, **kwargs):
...
    if not locations:
        locations = kwargs.pop("location", None)
...
options = {
    "required": kwargs.pop("required", False),
    **kwargs
}

If you agree with me and can do it or if you let me do PR - please, reply
If examples already can passed to @docs or @request_schema - please, adding this to docs

@maximdanilchenko
Copy link
Owner

@Niccolum, yes, you can do PR.

@Niccolum
Copy link
Author

Niccolum commented May 6, 2020

I see it is not so simple.
I will try to fix this problem.
I will report the result later

@maximdanilchenko
Copy link
Owner

Ok. Please, tell results. I will help or make changes by myself if needed

@Niccolum
Copy link
Author

Niccolum commented May 6, 2020

So, Actually, I have a problem.
I found how to correctly transfer examples, I found where, but so far I am at a loss how to transfer them to definitions

So, my changes now in my local fork:

P.S. fix here also #67
P.P.S. added 3.8 support to setup.py (it's working on it, i checked)
P.P.P.S. I understand that this is not enough for PR. Can you help me for solution this problem, @maximdanilchenko ? I know apispec marshmallow ext badly =(
P.P.P.P.S All tests passed now

@Niccolum
Copy link
Author

Niccolum commented May 6, 2020

UPD:
Found hack solution. Please, can you help me to create from it normal solution?)
Adding PR for you
#90
@maximdanilchenko Waiting for your suggestions)
P.S. Of course, need add tests for new functionality. I adding it later.
P.P.S. Works fine with swagger 2 version.
Do not testing with openapi 3. (as I see - this is not necessary)

@Niccolum
Copy link
Author

Niccolum commented May 7, 2020

I'm still working on ticket, writing some tests and I have a question.
Do you think it is normal that an example that was intended for only one endpoint appears in the ref scheme, and, accordingly, it exists on all endpoints with this scheme. I don’t see in the swagger standard how to make sure that there is an example for only one endpoint, if it uses a ref scheme.
UPD: found one more hack. I will show today the general solution that I propose, a little later

@Niccolum
Copy link
Author

Niccolum commented May 7, 2020

Finally, done my PR #90
@maximdanilchenko please, look at him, waiting your feedback.

@Niccolum
Copy link
Author

ping

@Niccolum
Copy link
Author

PR 90 already merged. I think time to close issue

@sainoba
Copy link

sainoba commented Mar 21, 2021

Are there any plans to make a release to include this change?

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

3 participants