Comments (6)
Not yet.
I think there will be many challenges in translate JSON schema to SQLAlchemy model, there is a project alchemyjsonschema which can convert SQLAlchemy model to JSON schema as a reference.
SQLAlchemy model needs to know which property is the primary key, and which is the index, in some cases, we don't want to expose some properties in a model, or expose some model. Those problems may resolve with the x-
property in Swagger for extending same database concepts.
from swagger-py-codegen.
Nice idea, but will you implement this as an optional feature?
I tried to explain it, and then discuss.
The generated code can be divided into two categories: overwritable and non-overwritable.
The code overwritable is totally defined by swagger docs, and the code non-overwritable is generated on first time, then maintained by the user.
The overwritable codes include:
- routes, defined by path and method in swagger.
- schemas, defined by parameters and schemas in swagger.
- validators, use schemas validate the request.
- filters, use schemas filter the response.
swagger-py-codegen' s purpose is to make those overwritable codes can be simply updated when the swagger doc is changed.
The other codes, for example, views, views content is not totally decided by swagger-py-codegen, so it's content will not be overwritten by default.
SQLAlchemy's model like views, the user will handle it contents, so it should be non-overwritable by default.
Another purpose of the project is: generates the necessary code for make a running application as the swagger doc defined.
The SQLAlchemy model is not a necessary condition for the working app, but the model code may be very useful for some scene.
So if this is an optional feature, we will be very pleased to accept your PR.
p.s. I intend to implement a custom template feature so that it can adapt to more special scene.
Thanks.
from swagger-py-codegen.
Yeah, I've been thinking about this, essentially I'll need a much more general solution, that generates:
- Models
- Persistence (optional)
- Tests (including mocks)
- Routes
… and can go in the reverse (back to Swagger from changes in models and/or routes)
PS: My Blueprint
s are quite different now, as I'm using bottle
with separate a different "api" in each directory, e.g.: user_api
, profile_api
, auth_api
, friends_api
.
from swagger-py-codegen.
wonderful!~~
from swagger-py-codegen.
So.. was this merged in?
from swagger-py-codegen.
First of all, thanks for the great project. It is very useful.
Most likely people using this generator is at the early stage of the project. At that time, all codes are overridable. :-)
Seems like all files under /api are non-overridable. If that is the case, why not making another folder "/db", put db related operation there. Some argument can add to let user select skip or upgrade or override.
Just 2 cents.
from swagger-py-codegen.
Related Issues (20)
- sanic下的bp会将__name__做成url_prefix,请问这个是本意就如此设计吗? HOT 1
- Schema Definitions Are Not Deterministically Ordered HOT 1
- Nested self reference to a definition, results in circular dependency error
- PyYAML 3.13 HOT 1
- Only generates demo>v1>schemas.py HOT 1
- jinja2.exceptions.UndefinedError: 'schemas' is undefined
- TypeError when use swagger HOT 2
- unexpected keyword argument 'spec' HOT 3
- Type Error: Unexpected Keyword Argument 'swagger' HOT 1
- name "RefResolver" is not defined HOT 2
- FileNotFoundError: [Errno 2] No such file or directory: 'api.yml'?
- AttributeError exception while generating code
- TypeError exception in response validation with falcon framework
- The browser (or proxy) sent a request that this server could not understand HOT 1
- conversion failed HOT 1
- UnicodeDecodeError HOT 1
- Help
- ImportError: attempted relative import with no known parent package
- can not generate file upload in swagger html??
- use 0.0.0.0 instead 127.0.0.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swagger-py-codegen.