Skip to content

Commit 587fa18

Browse files
committed
improved docs
1 parent c9568e2 commit 587fa18

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

README.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,36 @@ expectations:
1616

1717
- it generates simple code.
1818

19-
- it handles Spring types like `Page<>`, `Pageable`.
19+
- it allows type mappings (with generic values) to map schemas defined in the openapi.yaml to existing java classes.
20+
This includes Spring types like `Page<>` & `Pageable`.
21+
22+
- it allows to add additional parameters to an endpoint. For example to pass the `HttpServletRequest` to the controller
23+
method.
24+
25+
- it handles multiple responses by generating one controller method for each response content type.
2026

21-
- WebFlux support.
27+
- WebFlux support, may need its own generatr.
2228

2329

2430

2531
# Status
2632

27-
(October 2019) this is work in progress.
33+
(November 2019) this is work in progress.
2834

2935
current status & limitations:
3036

37+
## status
3138
- generates interfaces & models for all endpoints
32-
- supports openapi.yaml files that reference other files
33-
- property names in the openapi description must be java compatible (i.e. no `@JsonProperty` on model classes)
39+
40+
## limitations
41+
- property names in the openapi description must be java compatible (i.e. no `@JsonProperty` yet on model classes)
3442
- limited parameter support
3543
- query parameters (i.e. `in: query`)
3644
- does handle basic data types and `object`s
3745
- no path parameters (i.e. `in: path`)
3846
- no header parameters (i.e. `in: header`)
3947
- no cookie parameters (i.e. `in: cookie`)
4048
- honors only the first response content description
41-
- does not support special Spring types
4249
- MVC only, no WebFlux
4350
- there are probably more limitations ... ;-)
4451

@@ -98,6 +105,9 @@ it will create the endpoint like this:
98105
By default the OpenAPI `array` is mapped to a simple java array. It is possible to change that default
99106
mapping for example to `java.util.Collection` by adding a type mapping to the generator options.
100107

108+
The `SpringGeneratrOptions` object has a property `typeMapping` that takes either a file name to a yaml
109+
file (with extension `.yaml`) or an inline yaml.
110+
101111
Given the api:
102112

103113
/array-collection:
@@ -112,12 +122,12 @@ Given the api:
112122
type: string
113123
description: none
114124

115-
and adding `array` to the `typeMappings` property of the generatr options object like this (example
116-
in groovy notation):
125+
and the following yaml:
117126

118-
typeMappings = [
119-
'array': 'java.util.Collection'
120-
]
127+
maps:
128+
types:
129+
- from array
130+
to java.util.Collection
121131

122132
the generated code will change to:
123133

@@ -126,10 +136,12 @@ the generated code will change to:
126136

127137
using the `array`s `items` type as the generic parameter.
128138

129-
The generatr needs to know the given type to generate proper java code so we can't simply add a random
130-
collection type. The generatr does currently recognize the following types:
139+
The generatr needs to know the given collection type to generate proper java code so we can't simply
140+
add a random collection type. The generatr does currently recognize the following types:
131141

132-
- `java.util.Collection`
142+
- `java.util.Collection`
143+
- `java.util.List`
144+
- `java.util.Set`
133145

134146
#### `x-java-type`
135147

@@ -174,11 +186,13 @@ The generatr needs to know the given type to generate proper java code so we can
174186
## Endpoint Response
175187

176188
All generated endpoints have a [`ResponseEntity<>`][spring-responseentity] result. This allows an endpoint
177-
implementation full control of the response.
178-
189+
implementation full control of the response at the cost of having to provide a `ResponseEntity` even if
190+
it could just return its pojo result.
179191

180192
## Endpoint Parameters
181193

194+
todo
195+
182196
### Query Parameters
183197

184198
#### simple query parameters
@@ -207,6 +221,8 @@ will generate the following interface method:
207221

208222
#### object query parameter
209223

224+
> no longer supported, will be re-implemented using type mappings
225+
210226
In case multiple query parameters should be mapped into a single model object like in this description:
211227

212228
paths:
@@ -303,6 +319,7 @@ The structure looks like this:
303319

304320
my-new-test-case/
305321
openapi.yaml
322+
mapping.yaml
306323
generated/
307324
api/
308325
AnEndpointInterfaceApi.java
@@ -312,6 +329,8 @@ The structure looks like this:
312329
AnotherModelClass.java
313330
.. more model files ..
314331

332+
The `mapping.yaml` contains the type mapping information and is an optional file.
333+
315334
See the [existing integration tests][generatr-int-resources] for a couple of examples.
316335

317336

0 commit comments

Comments
 (0)