This repository was archived by the owner on Jul 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 146
Introduce root endpoints' schemas #321
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yeralin
commented
Aug 23, 2019
diego-plan9
reviewed
Sep 4, 2019
It is done to highlight this schema being used with GET request (using query parameters).
Member
|
Following up on Can you make |
diego-plan9
approved these changes
Sep 6, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #289
Adds schemas that describe request and response payloads for "root" endpoints.
Details and comments
I found couple problems while preparing this PR:
marshmallow.fileds.Dictis not fully supportedIf you look at the official doc for
Dictfield under Marshmallow 2.0: https://marshmallow.readthedocs.io/en/2.x-line/api_reference.html#marshmallow.fields.DictIt states: "This field is only appropriate when the structure of nested data is not known." i.e. if you use
mashmallow.fields.Dictfield under your schema, it will be deserialized as a simpledictobject, no support formarshmallow.fields.Nested.However, if you look at docs for
Dictin Marshmallow 3.0:https://marshmallow.readthedocs.io/en/stable/api_reference.html#marshmallow.fields.Dict
You can explicitly set a nested schema for keys and values like:
They discussed the implementation of this feature under marshmallow-code/marshmallow#483
Because of this limitation schemas like
HubsResponseSchemaandCircuitResponseSchemacan only be deserialized partially.Also because of this issue,

marshmallow-jsonschemapackage cannot generate a proper JSON schema for nested dicts, and rendered as<not serializable>:HubsResponseSchemawill always fail bc@bind_schemadoes not allow passingmany = TrueThe issue was raised under
qiskit-terrarepo: Qiskit/qiskit#3021If we were to create a model for
HubsResponseSchemausing@bind_schemadecorator, and then use it to deserialize hubs response payload, the deserialization will always fail withModelValidationError. The reason is bc the payload is of the following format:[<payload>]i.e. the payload is wrapped in an array. This could be easily fixed by passingmany = Truewhile creating an instance ofHubsResponseSchema(many=True), but the instance is created internally in@bind_schemadecorator, and we cannot pass any arguments inside.