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

Propose Update With Raw Dictionary #198

Merged
merged 1 commit into from
Mar 16, 2021

Conversation

FerdinaKusumah
Copy link
Member

@FerdinaKusumah FerdinaKusumah commented Jan 12, 2021

  1. Simplify nested if else in swagger.py
  2. Add default value in swagger.py
  3. Adding default value for consumes in doc.py
  4. Propose to update with dictionary value, actually i'm just lookup with current value and adding some changes so it can be match with current code.

my propose update will be like this

@app.route("/users")
@doc.summary("Api that return all users")
@doc.tag("users")
@doc.consumes(doc.Dictionary(fields={"id": doc.Integer(),
                                     "age": doc.Integer(),
                                     "address": doc.String(),
                                     "name": doc.String(),
                                     "details": doc.Dictionary(fields={
                                         "example": doc.String()
                                     }),
                                     }), location="body")
@doc.response(401, {"message": str}, description="Unauthorized")
@doc.response(402, {"message": str}, description="Unauthorized")
async def users(request):
    return json({"hello": "world"})

So it will display object in swagger body, this is an example when i'm test
Screen Shot 2021-01-13 at 00 00 50

@FerdinaKusumah FerdinaKusumah changed the title Simplify code Propose Update With Raw Dictionary Jan 12, 2021
@FerdinaKusumah FerdinaKusumah force-pushed the feature/refactoringCode branch 2 times, most recently from a1496cd to 44db91e Compare January 12, 2021 17:05
@ahopkins ahopkins merged commit ad60644 into sanic-org:master Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants