an OpenAPI interface only & model java code generator for Spring Boot.
See here.
to use snapshot versions add https://oss.sonatype.org/content/repositories/snapshots
as maven repository to your build file.
an OpenAPI 3.0 & 3.1 interface & model java code generator for Spring Boot
Home Page: https://docs.openapiprocessor.io
License: Apache License 2.0
an OpenAPI interface only & model java code generator for Spring Boot.
See here.
to use snapshot versions add https://oss.sonatype.org/content/repositories/snapshots
as maven repository to your build file.
add the possibility to skip generation of an endpoint.
It would be annoying if we can't use the generatr because it does not create proper code for a single (or multiple) endpoint(s).
By telling the generatr which endpoints to skip we can still use it for all the other endpoints with correct code and create a hand written endpoint for the skipped endpoints.
allow to map object type on endpoint
mapping notation:
map:
/foo:
types:
- from:
to:
the property order of model objects does not correspond to the order of the openapi.yaml
allow to map simple type global parameter with format
mapping notation:
map:
parameters:
- name:
from:
to:
the bean-validation
option given in the mapping file is not used..?
now (#68) that we have direct access to the mapping information in SpringGeneratr
move the options
to the mapping yaml.
That way everything that is related to the code generation is in the same place.
empty mapping.yaml crashes the generatr
... that code is never called ?
implement:
type |
format |
generatr Java type |
---|---|---|
string |
date |
OffsetDateTime |
add parameters that are not defined in the openapi to an endpoint via
map:
paths:
/foo:
parameters:
- add: request
as: javax.servlet.http.HttpServletRequest
allow to map simple type global response with format
mapping notation:
map:
responses:
- content:
from:
to:
support cookie parameters, i.e. generate method parameters annotated with @CookieValue
currently the parameter & property names are used as-is to generate interfaces and models. This can lead to invalid java identifiers.
creating type names for inline types doesn't properly handle the /
es in the path. It creates e.g. funny things like: Api/generatrRequestBody
for the request body of the path /api/generatr
.
support path parameters, i.e. generate method parameters annotated with @PathVariable
allow to map simple type global parameter with format
mapping notation:
map:
/foo:
types:
- from:
to:
allow to map object type global response
mapping notation:
map:
responses:
- content:
from:
to:
Should be possible to use the mapping to map an query parameter object to a Map
not needed atm.@RequestParam(name="prop") Map<String, String>
, the request parameter "prop" is converted into a map
@RequestParam Map<String, String>
, puts all request parameters into a map
@RequestParam MultiValueMap<String, String>
, puts all request parameters into a map, allowing multiple parameters of the same name
Example (openapi yaml snippet):
/endpoint-object:
get:
description: <
should be mapped to a `Props` pojo without `@RequestParam` annotation
/endpoint-object?prop1=foo&prop2=bar
parameters:
- name: props
description: query parameter object
in: query
schema:
$ref: '#/components/schemas/Props'
components:
schemas:
Props:
type: object
properties:
prop1:
type: string
prop2:
type: string
see #64
implement:
type |
format |
generatr Java type |
---|---|---|
string |
date |
LocalDate |
re-use object mapping
survive more type mapping yaml inconsistencies
support header parameters, i.e. generate method parameters annotated with @RequestHeader
@JsonProperty()
adds some noise to the code. Consider adding it only if a property name is not a valid java identifier.
the check if a bean validation annotation should be added fails with "0" constraints.
if (value)
which is false if value is 0value != null
it should be ResponseEntity<Void>
e.g. allow to map
type string
with format date-time
mapping notation:
map:
types:
- from: string/date-time
to: java.time.ZonedDateTime
for example
....
parameters:
in: query
name: page
schema:
type: integer
default: 0
should write
@RequestParam(value = "page", required = false, defaultValue="0") Integer page
Assuming the following open api snippet for a request body for uploading multiple files:
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
files:
type: array
items:
type: string
format: binary
the generatr should create an additional query parameter instead of a @RequestBody
parameter, in this case as array
@RequestParam(name = "files") MultipartFile[] files
The following openapi query parameter
/foo:
get:
parameters:
- name: props
in: query
explode: true
schema:
type: object
properties:
prop1:
type: string
prop2:
type: string
The explode: true
tells us that the object is serialized as multiple query parameters. The generatr should produce an endpoint like this:
@GetMapping(path = "/endpoint-object")
ResponseEntity<Void> getEndpointObject(GetFooProps props);
@RequestParam
annotation... and crashes with a stack overflow exception
merge with object mapping
support javax.validation.validation-api by
@Valid
annotation to parametersopenapi | annotation | comment |
---|---|---|
minimum | @Min |
only if exclusiveMinimum = false (default) |
maximum | @Max |
only if exclusiveMaximum = false (default) |
minLength | @Size(min = .. ) |
|
maxLength | @Size(max = .. ) |
|
? | @NotNull |
default? |
? | @Null |
|
pattern | @Pattern |
allow to map object type endpoint response
mapping notation:
map:
/foo:
responses:
- content:
from: object
to:
allow to map simple type endpoint response with format
mapping notation:
map:
/foo:
responses:
- content:
from:
to:
issue:
in case a DataType
is a generic type, String DataType.getImport()
does not contain the imports of the generic types.
solution:
The method should change its return type Set<String>
and add the generic types.
looks like the target type of a type mapping gets no import statement in the generate code. For example using the following mapping
map:
paths:
/api/generatr:
types:
- from: ApiGeneratrRequestBody
to: org.springframework.web.multipart.MultipartFile
it does not generate an import for MultipartFile
.
Is there no test?
check if using an external code formatter improves the generated code. Especially for long lines.
candidates:
- https://github.com/google/google-java-format
- https://github.com/jhipster/prettier-java/tree/master/packages/prettier-plugin-java (javascript)
Assuming the following open api snippet for a request body:
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
other:
type: string
the generatr should create an additional query parameter for each property of the schema object instead of a @ReqeustBody
parameter, in this case
@RequestParam(name = "file") MultipartFile file,
@RequestParam(name = "other") String other
the generated enum model class is missing the imports for @JsonValue
& @JsonCreator
.
.. it should use processor instead of generatr
support OpenAPI requestBody:
block, annotate method parameter with @RequestBody
the generatr should log the keys from the options map that it will not use so the user does not need to debug the code to find out why it is not working.
or do it here: openapi-processor/openapi-processor-gradle#3
allow to map object type global parameter with format
mapping notation:
map:
parameters:
- name:
from:
to:
support enum
constraint on types by generating an enum class (?)
schema:
type: string
enum: [asc, desc]
generatr creates code like this:
@RequestParam(name = "page", required = false, defaultValue = 0) Integer page,
but should be
@RequestParam(name = "page", required = false, defaultValue = "0") Integer page,
allow to map simple type endpoint parameter with format
mapping notation:
map:
/foo:
parameters:
- name:
from:
to:
allow to map object type endpoint parameter
mapping notation:
map:
/foo
parameters:
- name:
from: object
to:
the generatr does not add the import for the @ResponseBody
annotation when an endpoint method is using it.
Is there no test for this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.