Starter StackGen

Starter StackGen CORE Service Generator

License

License

GroupId

GroupId

io.starter
ArtifactId

ArtifactId

stackgen
Last Version

Last Version

0.9.25
Release Date

Release Date

Type

Type

jar
Description

Description

Starter StackGen
Starter StackGen CORE Service Generator
Project Organization

Project Organization

Starter Inc.
Source Code Management

Source Code Management

https://github.com/StarterInc/StackGen

Download stackgen

How to add to project

<!-- https://jarcasting.com/artifacts/io.starter/stackgen/ -->
<dependency>
    <groupId>io.starter</groupId>
    <artifactId>stackgen</artifactId>
    <version>0.9.25</version>
</dependency>
// https://jarcasting.com/artifacts/io.starter/stackgen/
implementation 'io.starter:stackgen:0.9.25'
// https://jarcasting.com/artifacts/io.starter/stackgen/
implementation ("io.starter:stackgen:0.9.25")
'io.starter:stackgen:jar:0.9.25'
<dependency org="io.starter" name="stackgen" rev="0.9.25">
  <artifact name="stackgen" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.starter', module='stackgen', version='0.9.25')
)
libraryDependencies += "io.starter" % "stackgen" % "0.9.25"
[io.starter/stackgen "0.9.25"]

Dependencies

compile (74)

Group / Artifact Type Version
org.springframework.boot : spring-boot-devtools jar 2.3.7.RELEASE
com.zaxxer : HikariCP jar 3.4.5
io.springfox : springfox-swagger2 jar 2.9.2
org.springframework : spring-websocket jar
org.springframework : spring-messaging jar
org.springframework.boot : spring-boot-starter jar 2.3.7.RELEASE
org.mockito : mockito-core jar 3.3.3
org.springframework.boot : spring-boot-starter-web jar 2.1.3.RELEASE
de.codecentric : spring-boot-admin-server jar
de.codecentric : spring-boot-admin-server-ui jar
org.springframework.security : spring-security-web jar
org.springframework.boot : spring-boot-starter-security jar 2.3.7.RELEASE
org.springframework.boot : spring-boot-test jar 2.3.7.RELEASE
org.springframework : spring-test jar 5.2.2.RELEASE
org.springframework.boot : spring-boot-starter-tomcat jar 2.1.3.RELEASE
org.springframework : spring-core jar
org.springframework : spring-context jar
org.apache.maven : maven-embedder jar 3.5.0
org.apache.maven : maven-artifact jar 3.6.0
org.apache.maven.wagon : wagon-http-lightweight jar 3.2.0
com.google.guava : guava jar 27.0-jre
org.jdom : jdom jar 1.1.3
javax.ws.rs : javax.ws.rs-api jar 2.1
com.brsanthu : migbase64 jar 2.2
org.glassfish.jersey.core : jersey-common jar
org.glassfish.jersey.media : jersey-media-multipart jar
org.glassfish.jersey.media : jersey-media-json-jackson jar
org.glassfish.jersey.core : jersey-client jar
org.apache.cxf : cxf-rt-frontend-jaxrs jar 2.2.3
org.apache.cxf : cxf-rt-transports-http jar 2.2.3
com.samskivert : jmustache jar 1.15
com.github.spullara.mustache.java : compiler jar 0.9.2
com.squareup : javapoet jar 1.11.1
org.jvnet : mimepull jar 1.6
com.jamesmurty.utils : java-xmlbuilder jar 0.4
net.sf.ehcache : ehcache jar 2.10.6
com.sun.mail : javax.mail jar 1.6.2
javax.mail : javax.mail-api jar 1.6.2
junit : junit jar 4.13.1
org.json : json jar 20160212
org.mozilla : rhino jar 1.7R4
org.quartz-scheduler : quartz-jobs jar 2.2.1
org.mybatis.generator : mybatis-generator-core jar 1.4.0
org.mybatis : mybatis-typehandlers-jsr310 jar 1.0.2
com.sun.jersey.contribs : jersey-multipart jar 1.8
org.aspectj : aspectjrt jar 1.9.6
org.aspectj : aspectjtools jar 1.9.6
org.aspectj : aspectjweaver jar 1.9.6
org.mybatis : mybatis jar 3.5.3
org.mybatis.dynamic-sql : mybatis-dynamic-sql jar 1.1.4
org.apache.shiro : shiro-core jar 1.2.3
org.apache.shiro : shiro-web jar 1.2.3
org.apache.shiro : shiro-ehcache jar 1.2.3
org.apache.tomcat : tomcat-jdbc jar 7.0.50
org.apache.tomcat : tomcat-dbcp jar 7.0.50
com.mchange : c3p0 jar 0.9.5.5
com.mchange : mchange-commons-java jar 0.2.20
com.squareup.okhttp3 : okhttp jar 3.14.9
com.squareup.okhttp3 : logging-interceptor jar 3.14.9
org.threeten : threetenbp jar 1.3.6
io.gsonfire : gson-fire jar 1.8.3
com.google.code.gson : gson jar 2.8.6
com.fasterxml.jackson.core : jackson-core jar
io.swagger.parser.v3 : swagger-parser jar 2.0.15
io.swagger.parser.v3 : swagger-parser-core jar 2.0.15
io.swagger.core.v3 : swagger-core jar 2.0.6
io.swagger : swagger-codegen jar 2.4.8
io.swagger : swagger-models jar 1.6.0
io.swagger.core.v3 : swagger-models jar 2.1.1
io.starter : OpenXLS jar 11.0.4
net.java.dev.jets3t : jets3t jar 0.9.4
mysql : mysql-connector-java jar 8.0.22
org.postgresql : postgresql jar 42.2.18
org.imgscalr : imgscalr-lib jar 4.2

provided (1)

Group / Artifact Type Version
javax.servlet : javax.servlet-api jar 4.0.1

Project Modules

There are no modules declared in this project.

Starter StackGen™ Code Generator

StackGen CI

Generate Apps and Stacks from OpenAPI/Swagger spec files -- CodeGen for Developers

Take an input OpenAPI/Swagger spec file and generate a full-stack Spring Boot microservice.

Generates Spring MVC/Model Objects and publishes via REST apis. Full stack RESTful MicroServices using simple YAML files to define your data models.

Don't refactor... Regenerate!

Generate an app from swagger YAML

  • YAML -> Swagger client
  • Swagger Client -> entity classes
  • Swagger Client -> DML for database
  • Swagger Client -> ReactJS/ReactNative/React360 screens

Introduction

Starter StackGen can be used either as a Java command-line program, or as a library called from your own Java code.

The primary means of controlling the output of the program is via command line arguments.

java -jar StarterStackGen-1.0.0.jar -DSWAGGER_LANG=spring -DSWAGGER_LIB=resteasy ...

These settings are converted to System properties within the StackGen program and are used to configure the output from the program.

// main output type
// (ie: spring, jersey2)
configurator.setLang(SWAGGER_LANG);

// the JSON serialization library to use
// (ie: jersey2, resteasy, resttemplate)
configurator.setLibrary(SWAGGER_LIB);

Development Best Practices

  • Fork the StackGen project and leverage github with Conventional Commits Conventional Commits

  • Only connect to database server via https.

  • To improve DB security, disallow WAN connections to the Database via GRANT permissions, then use an SSH tunnel to connect to the database for local testing.

TODO: document DB tunneling over SSH

  • Use SecureField™ configuration for any PII (Personal Identifying Information) data to protect user privacy.

Keep in mind SecureField™s cannot be used in searches, so consider adding appropriate keyword-based search fields.

Starter StackGen Code Generation Steps:

  1. Swagger Schema -> Java POJOs
  2. Java POJOs -> SQL Database Tables
  3. SQL Database -> ORM Mapping Data Objects (MyBatis)
  4. ORM Mapping Data Objects Wrapped by StackGen Model Objects
  5. Use StackGen Model Objects in your Java code (optional)
  6. Start Spring Boot microservice and access Model Objects via REST apis (optional)

Step 1: Create an Swagger Schema for your Application

Generating a Starter StackGen application requires that you provide/create an OpenAPI schema that defines the application's objects, RESTful APIs and the schema for your SQL database.

Learn about OpenAPI

Inputting your Swagger schema to Starter StackGen will result in the creation of a Java Maven application residing in the generator output folder ("./gen" by default).

Apache Maven is a popular open source Java build tool which manages dependencies, builds the appliction, and allows for running Java programs with test and service automation.

MyBatis ORM is a popular open source Java Object Relational Mapping library which allows you to define simple and complex Data Objects that map to your SQL database (in this case MySQL). Using MyBatis, you can easily insert, update, delete and search for data in your Database using convenient Java Data Objects. If you are new to MyBatis, you should check out this Excellent Tutorial.

Before running Starter StackGen on your Swagger spec, you will need to create a Database (MySQL) and a default schema.

We recommend the use of an AWS LightSail Database instance to run the database and using MySQL Workbench free database management utility to work with the data.

Additionally, you may consider connecting over an SSH tunnel but for now that is left out of the scope of this Tutorial.

Step 2: Build and Launch your Generated Application

After generating your application, you can treat the output as you would any standard Maven Java application.

One of the benefits of using Maven is the dependence on standardized file paths and project defaults, so the layout of the project files should be familiar to anyone who has worked with Maven in the past.

gen
├── src
│   └── main
│       ├── java
│       │   └── io
│       │       ├── starter
│       │       │   └── ignite
│       │       │       ├── api
│       │       │       ├── invoker
│       │       │       └── model
│       │       │           └── dao <-- THIS IS WHERE THE Data Object Classes Reside
│       │       └── swagger
│       │           └── configuration
│       └── resources
│           └── io
│               └── starter
│                   └── ignite
│                       └── sqlmaps <-- Generated MyBatis ORM Mappings
└── target <-- Maven Build Output

To build the project after generation, use the following commands from the command line:

mvn clean install -U

If you have selected the "spring-boot" (default) application framework, you can run the service with a single line of code:

cd <project_folder>gen
mvn spring-boot:run

To distribute the spring boot service, you can simply copy the deployment jar from the "target" folder to your server and launch it directly as an executable jar:

testbed$ java -jar -Dio.starter.ignite.secure_key=W43sdfNpOSDF0madfT40wwjTaaadfaeQo449Qa9rygfrm5fX21Dg= -DRDS_HOSTNAME=db.yourco.com -DRDS_DB_NAME=ignite -DRDS_USERNAME=igniteuser -DRDS_PASSWORD=**********  ignite-1.0.1-exec.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.9.RELEASE)

Dec 22, 2018 12:43:47 PM io.starter.ignite.invoker.Swagger2SpringBoot logStarting
INFO: Starting Swagger2SpringBoot v1.0.1 on Johns-MacBook.local with PID 22593 (/Users/john/workspace2019/testbed/ignite-1.0.1-exec.jar started by john in /Users/john/workspace2019/testbed)

You should see the Starter StackGen banner and assuming the application starts correctly, you will see output similar to the following on the console:

[main] INFO springfox.documentation.spring.web.scanners.ApiListingReferenceScanner - Scanning for api listing references
Dec 07, 2018 10:38:18 AM org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer start
INFO: Tomcat started on port(s): 8080 (http)
Dec 07, 2018 10:38:18 AM io.starter.ignite.invoker.Swagger2SpringBoot logStarted
INFO: Started Swagger2SpringBoot in 20.395 seconds (JVM running for 38.247)

Step 3: Access the Running Application

Once launched, your new Starter StackGen application is ready to serve JSON data from then RESTful endpoints that were defined in the OpenAPI schema.

  1. Open a browser: http://localhost:8080
  2. Verify that the RESTful endpoints match your expectations from the input file
  3. If there are problems with your REST api, you can easily fix the OpenAPI schema and then re-run the StackGen generation script.

Now is the time to correct any obvious errors in the Schema as it will speed up further development the more complete and correct your underlying application is.

If you have set the option to overwrite the Database tables if they already exist, then any data you have entered in the database will be saved off in the renamed original table.

Encrypted data can only be recovered from SecureFields™ columns if the SecureFields setting is enabled on the field in the OpenAPI schema.

  1. As you can see the application data can be accessed from the REST api, however Starter StackGen also generates a jar file which is usable as a dependency in your projects without running the Spring Boot RESTful service.

So you can use your generated Java objects from within your application directly, through a RESTful api/service or both, depending upon your application architecture.

  1. TODO: enable monitoring
  2. TODO: describe app testing

Resources

The benefits of declaring your Object and API definitions in a human-readable text file format, and regenerating as much code as possible when changes are made, is even more compelling as application complexity increases.

io.starter

Starter Inc.

iBPM, LCDP, CodeGen, Spreadsheets and Automation

Versions

Version
0.9.25
0.9.24
0.9.23
0.9.22
0.9.21
0.9.20
0.9.19
0.9.18
0.9.7
0.9.6
0.9.5
0.9.3