Code Monkey home page Code Monkey logo

lapidary-render's People

Contributors

rafalkrupinski avatar

Watchers

 avatar

lapidary-render's Issues

Better reserved name handling

Name of any schema, parameter or property can ba any valid string, excluding Unicode control characters, while python accepts only alphanumerics + underscore (_), which has a special meaning if placed at the beginning.

Possible ways of handling names that are not valid python identifiers:

  • fail
  • use x-lapidary-names or x-lapidary-name
  • employ default name mangling
  • in case of object schema properties - skip from model definition, but support as an object variable + validate

Generate models for composite schemas

Composite schemas are those using oneOf, anyOf, allOf and not.

  • each schema will be represented as a single class (no inheritance)
  • only schemas that are either defined inline or referenced under the paths, responses or x-apiResponses elements will be source for model classes
  • schemas will be processed recursively
  • all properties from all schemas will be present, except from not schema, which properties should be excluded
  • each fields attributes (type, required, nullable) will reflect all the schemas, using the least restrictive one.
  • processing contradictory schemas will fail

External renderer

It would be great if I could offload rendering to an external project like cookiecutter or copier. lapidary-render could focus on developing template and generating model.

Unfortunately theses projects are designed to generate project stubs, with single file being generated from each template.

Add build script for poetry

Poetry has an undocumented feature allowing to run a custom script while building the project.

Use this feature to generate sources on build, instead committing the code to the VCS.

handle directed properties (readOnly writeOnly)

readOnly and writeOnly properties really mean response- and request - only. it's really a direction and not access.

  1. Add field Annotation Only(direction:Literal['read',''write], required: bool)
  2. add custom parser to base model class to support that annotation
  3. pass direction in the model.dump_python call
  4. render all directed properties as non-required, with added Only annotation
class MyModel(BaseModel)
    directed_field: Annotated[MyType|None, pydantic.Field(...), Only('read', required=True)] = None

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.