Giter VIP home page Giter VIP logo

Comments (6)

rejown avatar rejown commented on May 22, 2024 1

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.

rejown avatar rejown commented on May 22, 2024

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.

SamuelMarks avatar SamuelMarks commented on May 22, 2024

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 Blueprints 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.

daisymark avatar daisymark commented on May 22, 2024

wonderful!~~

from swagger-py-codegen.

advance512 avatar advance512 commented on May 22, 2024

So.. was this merged in?

from swagger-py-codegen.

leslie-wang avatar leslie-wang commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.