Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Commit

Permalink
Pass the example(s) from a requestBody to the Field as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn Jacobs committed Oct 18, 2019
1 parent 4d3e3e1 commit 5784927
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apistar/schemas/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,10 @@ def get_link(
]

# TODO: Handle media type generically here...
body_schema = lookup(
operation_info, ["requestBody", "content", "application/json", "schema"]
body_definition = lookup(
operation_info, ["requestBody", "content", "application/json"]
)
body_schema = body_definition.get("schema")

encoding = None
if body_schema:
Expand All @@ -473,7 +474,13 @@ def get_link(
field_name = lookup(
operation_info, ["requestBody", "x-name"], default=field_name
)
fields += [Field(name=field_name, location="body", schema=schema)]
fields += [
Field(
name=field_name, location="body", schema=schema,
example=body_definition.get("example"),
examples=body_definition.get("examples")
)
]

return Link(
name=name,
Expand Down

0 comments on commit 5784927

Please sign in to comment.