question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blueprint definitions

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
lafrechcommented, May 23, 2019

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 everywhere

@api.definition('Pet')

and the schemas will be registered automatically anyway.

The default behaviour in apispec is to register PetSchema as Schema. 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?

0reactions
lafrechcommented, Sep 19, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found