CodeGen API Simplification
See original GitHub issueI believe the codegen API can be simplified. E.g.
.withMethod("setIdAndName", sequence(
set(property(self(), "id"), arg(0)),
set(property(self(), "name"), arg(1))))
can become
.method("setIdAndName").args("id", "name").of(int.class, String.class).body(statements(assign("this.id", "this.name").to("id", "name")))
or
.method("setIdAndName").body(assign("this.id", "this.name").to("id", "name"))
as Person
defines the arguments and types this is implied.
Similarly
.withField("id", int.class)
...
.withMethod("getId", property(self(), "id"))
can become
.getter("id", int.class)
Also,
.withMethod("hashOfPojo", hash(property(arg(0), "id"), property(arg(0), "name")))
can become
.method("hashOfPojo").args("personPojo").of("ExamplePojo").returning(int.class).body(statements(returning(hash("personPojo.id", "personPojo.name"))))
or
.method("hashOfPojo").body(returning(hash("personPojo.id", "personPojo.name")))
as Person
defines the arguments
etc.
Basically,
- add shortcuts to all JavaBeans specific constructs
- Use builder pattern and fluent API
- a simple way to access arguments, fields, etc.
- a simple way to set fields and return values
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
API Code & Client Generator | Swagger Codegen
Codegen simplifies your build process by generating server stubs and client SDKs for any API defined with the OpenAPI specification. Download Codegen today....
Read more >Introduction to OpenAPI codegen | by Divyansh Sharma
Introduction to OpenAPI codegen - Simplify RESTful development. This blog gives an introduction to OpenAPI codegen. We will publish another ...
Read more >Simplify Framework - OpenAPI Based Serverless - GitHub
Generate Simplify Framework base projects with True-DevOps code skeleton to run on Cloud with API Gateway, AWS Lambda and other AWS Services from...
Read more >simplify-codegen - npm
Simplify Code Generator from OpenAPI 3.0 Specs. ... Start using simplify-codegen in your project by running `npm i simplify-codegen`.
Read more >Support for Swagger Codegen in REST APIs - YouTube
Swagger Codegen can simplify a build process by generating server stubs and client SDKs for any API, that is defined with the OpenAPI....
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 Free
Top 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
Here we have provided some of the goals and design decisions behind ActiveCodegen. It is a tool for dynamic class generation based on runtime parameters and information available in runtime. It supports code generation using functional composition of LISP-like expressions and ASTs. The current API is completely suitable for this task.
Since LISP like expressions and ASTs is supported. Perhaps some additional abilities which might prove to be useful: