Blueprint definitions
See original GitHub issueHi,
I’m creating an app with many blueprints for different sections of the API. It seems there should be a way to define definitions inside the blueprint. Something like:
blp = Blueprint(
'pets', 'pets', url_prefix='/pets',
description='Operations on pets'
)
@blp.definition('Pet')
class PetSchema(ma.Schema):
class Meta:
strict = True
ordered = True
id = ma.fields.Int(dump_only=True)
name = ma.fields.String()
It’s not suitable to create a circular dependency where the API is defined so it seems you need to do something like:
api=Api()
@api.definition('Pet')
Any recommendations on workarounds? thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Blueprint Definition & Meaning - Merriam-Webster
The meaning of BLUEPRINT is a photographic print in white on a bright blue ground or blue on a white ground used especially...
Read more >Blueprint - Definition, Meaning & Synonyms - Vocabulary.com
The literal meaning of a blueprint is a paper — which is blue — with plans for a building printed on it. You...
Read more >BLUEPRINT | definition in the Cambridge English Dictionary
a complete plan that explains how to do or develop something : The report provided a blueprint for relieving the county's crowded jail...
Read more >Blueprint definition and meaning | Collins English Dictionary
A blueprint for something is a plan or set of proposals that shows how it is expected to work. The president will offer...
Read more >Blueprint Definition & Meaning - Dictionary.com
a detailed outline or plan of action : a blueprint for success. verb (used with object). to make a blueprint of or for....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We realized today that thanks to the schema auto-registration feature introduced in apispec 1.0, there is actually no need to register the schema manually.
In other words, you can remove the call to
definition
everywhereand the schemas will be registered automatically anyway.
The default behaviour in apispec is to register
PetSchema
asSchema
. This is based on the assumption that people call their schemas with the name of the model suffixed with"Schema"
. This behaviour can be changed for specific needs but I think it is a reasonable convention.@qcho, can you please try to remove all calls to the
definition
decorator and tell me if it works?Closing this. I think this is not an issue anymore thanks to apispec auto-registration feature.
Feel free to comment if it is still an issue.