How to structure a real world application
See original GitHub issueHi,
I believe that due to recent updates in both apispec
and marshmallow
my application started to throw warnings and exceptions (e.g., marshmallow.exceptions.RegistryError
, apispec.exceptions.DuplicateComponentNameError
) that were not happening a few weeks ago.
I couldn’t came up with a minimal example to illustrate this yet. But I wonder if you could provide an example (beyond the basic “Petstore example” from the docs) of how to structure a more realistic application (like using the application factory pattern, splitting schemas and views in different modules, etc).
Regards,
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:11 (6 by maintainers)
Top Results From Across the Web
How do you Learn to Build Substantial, Real-World Apps?
Building a real-world application requires a lot of work and a lot of skills other than technology if you want to set up...
Read more >How to structure a real-world monorepo Serverless app
In this post we look at how to organize monorepo Serverless Framework apps in detail. We'll also look at how to share common...
Read more >How Story Structure Relates to the Real World - Storymind
In this article I'd like to share with you some of the insights into the relationship of story structure to real life that...
Read more >How to Plan a Real World Web Application from Scratch? in 2020 by ...
How to plan a website structure? In today's video I will teach you how you go from idea to actually crafting a professional...
Read more >What are the real world applications of data structure ... - Quora
Take a business ledger. They are arrays of pages. The pages are arrays of structures, each structure has a number in each column....
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
Hi again,
I wanted to share the 2 things I had to do in order to adapt my application to be compatible with flask-rest-api 0.13 ( actually, apispec>1.0.0b6, marshmallow>3.0.0rc3).
init_app
Otherwise, I’d get:when using the
Api.definition
decorator with a schema having a nested field declared with a class name string like in two-way nesting in marshmallow schemas .You can solve this either not using the
Api.definition
or making sure to import all your schemas before callinginit_app
.when using the
Api.definition
decorator, orwhen the
Api.definition
decorator is not used at all but there are nested fields declared with modifiers (likeonly=('id', )
).In the first case (using the
Api.definition
decorator), the issue is thatapispec
is also registering schemas in the spec’s components using its default schema_name_resolver.In the second case (not using the
Api.definition
and having nested fields with modifiers),apispec
tries to register the same schema name for each modifiers combination used and shows the warning.The workaround I found for this is to don’t let
apispec
to register nested schemas automatically and use theApi.definition
decorator. For this I callinit_app
passing a custom marshmallow plugin:For a minimal example reproducing these two issues you may want to checkout flask-rest-api-example.
Regards,
I’ve been working on a simple real-life example and I came up with a minimal application using sqlalchemy.
https://github.com/lafrech/flask-smorest-sqlalchemy-example
Not done (are such things ever done ?) but feedback welcome already.