Skip to content

Commit 83c6c27

Browse files
committed
more documentation
1 parent 9ba82fb commit 83c6c27

File tree

8 files changed

+116
-18
lines changed

8 files changed

+116
-18
lines changed

docs/_sass/overrides.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@
2828

2929
border-left: 0.5em solid $yellow-000;
3030
}
31+
32+
.deprecated {
33+
margin-left: 1em;
34+
margin-right: 1em;
35+
padding: 0.8em;
36+
37+
border-left: 0.5em solid $red-000;
38+
}

docs/generatr/configuration.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
layout: default
3+
title: Configuration
4+
parent: The generatr
5+
nav_order: 4
6+
---
7+
8+
# Configuration
9+
10+
The configuration of the generatr is given in the `mapping.yaml`. It does contain some general options
11+
and the type mapping information.
12+
13+
14+
A mapping yaml looks like this
15+
16+
options:
17+
package-name: com.github.hauner.openapi
18+
bean-validation: true
19+
20+
map:
21+
# see link below
22+
23+
24+
## options:
25+
26+
- `package-name`: (**required**) the root package name of the generated interfaces & models. The package
27+
folder tree will be created inside the `targetDir` (see [using gradle][docs-gradle]).
28+
29+
Interfaces and models will be generated into the `api` and `model` subpackages of `package-name`.
30+
31+
- so the final package name of the generated interfaces will be `"${package-name}.api"`
32+
- and the final package name of the generated models will be `"${package-name}.model"`
33+
{: .mb-5 }
34+
35+
- `bean-validation` (**optional**, `true` or `false`) enables generation of bean validation annotations.
36+
Defaults to `false`. See [Bean Validation][bean-validation]{:target="_blank"}.
37+
38+
## map:
39+
40+
Using type mapping we can tell the generatr to map types (schemas) from an openapi.yaml description to
41+
a specific existing java type instead of generating a model class from the source OpenAPI type.
42+
43+
The type mapping is described in [java type mapping][docs-mapping].
44+
45+
46+
[docs-mapping]: /openapi-generatr-spring/mapping/
47+
[docs-gradle]: /openapi-generatr-spring/gradle.html
48+
[bean-validation]: https://beanvalidation.org/

docs/gradle-obsolete.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ nav_order: 10
77
# Using Gradle (obsolete)
88
{: .no_toc }
99

10-
Note: this page is out-of-date describing the previous version of the gradle plugin. See the latest
10+
**Deprecated**: this page is out-of-date, describing the previous version of the gradle plugin. See the latest
1111
documentation [here][docs-gradle].
12-
{: .note .info .mb-6}
12+
{: .note .deprecated .mb-6}
1313

1414
The [openapi-generatr-gradle][generatr-gradle] is currently the only way to run a **openapi-generatr.**
1515

docs/gradle.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,8 @@ block name.
6262

6363
spring {
6464
apiPath = "$projectDir/src/api/openapi.yaml"
65-
typeMappings = "$projectDir/openapi-mapping.yaml"
66-
6765
targetDir = "$projectDir/build/openapi"
68-
packageName = "com.github.hauner.openapi.sample"
69-
66+
mapping = "$projectDir/openapi-mapping.yaml"
7067
showWarnings = true
7168
}
7269

@@ -75,28 +72,42 @@ block name.
7572
- `apiPath`: (**required**) the path to the `openapi.yaml` file and the main input for the generatr. If
7673
set in the top level block it will be used for all configured generatrs.
7774

78-
- `typeMappings`: (**optional**) defines the type mapping if required. This is either a path to yaml
79-
file or a yaml string (i.e. the content of the yaml file). See [java type mapping][docs-mapping] for a
80-
description of the mapping yaml.
81-
8275
- `targetDir`: (**required**) the output folder for generating interfaces & models. This is the parent
8376
of the `packageName` folder tree. It is recommended to set this to a subfolder of gradle's standard `build`
8477
directory so it is cleared by the `clean` task and does not pollute the sources directory.
8578

8679
See [running the generatr][docs-running] how to include the `targetDir` in compilation & packing.
8780

81+
- `mapping`: (**required**, since 1.0.0.M6) provides the generatr mapping options. This is a path
82+
to yaml file. See [Configuration][docs-configuration] for a description of the mapping yaml. This replaces
83+
the `typeMappings` option.
84+
85+
- `showWarnings`: (**optional**) `true` to show warnings from the open api parser or `false` (default) to
86+
show no warnings.
87+
88+
89+
**Deprecated** the following options are deprecated starting with '1.0.0.M6'
90+
See [Configuration][docs-configuration].
91+
{: .note .deprecated .mb-6}
92+
93+
- `typeMappings`: (**optional**) defines the type mapping if required. This is either a path to yaml
94+
file or a yaml string (i.e. the content of the yaml file). See [java type mapping][docs-mapping] for a
95+
description of the mapping yaml.
96+
97+
starting with '1.0.0.M6' this is replaced by the `mapping` option.
98+
8899
- `packageName`: (**required**) the root package name of the generated interfaces & models. The package folder
89100
tree will be created inside `targetDir`.
90101

91102
Interfaces and models will be generated into the `api` and `model` subpackages of `packageName`.
92103

93104
- so the final package name of the generated interfaces will be `"${packageName}.api"`
94105
- and the final package name of the generated models will be `"${packageName}.model"`
95-
{: .mb-5 }
96-
97-
- `showWarnings`: (**optional**) `true` to show warnings from the open api parser or `false` (default) to
98-
show no warnings.
106+
{: .mb-5 }
99107

108+
starting with '1.0.0.M6' it is recommended to provide this in the mapping yaml. See
109+
[Configuration][docs-configuration].
110+
{: .mb-5 }
100111

101112
# running generatr-spring
102113

@@ -128,4 +139,5 @@ Adding automatic compilation in this way will also automatically include the gen
128139

129140
[generatr-gradle]: https://github.com/hauner/openapi-generatr-gradle
130141
[docs-mapping]: /openapi-generatr-spring/mapping/
142+
[docs-configuration]: /openapi-generatr-spring/generatr/configuration.html
131143
[docs-running]: #running-generatr-spring

docs/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ See the [release notes][generatr-releases]{:target="_blank"}.
6767

6868
- add additional parameters to an endpoint which are not defined in the OpenAPI description. For example to pass
6969
a `HttpServletRequest` to the endpoint implementation. <span class="label label-green">since 1.0.0.M6</span>
70+
71+
- supports bean validations. The constraints of the openapi description are mapped to java bean validation
72+
annotations. <span class="label label-green">since 1.0.0.M6</span>
73+
74+
- allows to exclude endpoints from generation. This is useful if the generatr does not create the correct code for
75+
an endpoint. That way the generatr can still be used for all the other endpoints.
76+
<span class="label label-green">since 1.0.0.M6</span>
7077

7178
- <span class="label label-yellow">planned</span> handle multiple responses by generating one endpoint method for
7279
each response content type.

docs/links.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ nav_order: 30
88

99
- [OpenAPI][openapi]{:target="_blank"}. Homepage of the OpenAPI Initiative.
1010
- [OpenAPI specification][openapi-spec]{:target="_blank"}. Github repository of the OpenAPI specification.
11-
- [OpenAPI tools:][openapi-tools]{:target="_blank"}. List of OpenAPI tools.
11+
- [OpenAPI tools][openapi-tools]{:target="_blank"}. List of OpenAPI tools.
1212
- "the" [OpenAPI generator][openapi-generator]{:target="_blank"}. Generate clients, servers and documentation from OpenAPI 2.0/3.x documents.
1313

1414
[openapi]: https://www.openapis.org/

docs/mapping/endpoint.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ be placed in the `map/paths` section as properties to an endpoint given by its p
3737

3838
# another path
3939
/foo2:
40+
# excluding an endpoint
41+
exclude: true
4042

4143
# list of path specific mappings
4244
types:
@@ -57,3 +59,21 @@ be placed in the `map/paths` section as properties to an endpoint given by its p
5759

5860
The mappings defined as properties of an endpoint will be used only for this endpoint. They don't
5961
have any effect on other endpoints.
62+
63+
## excluding endpoints
64+
65+
(Since 1.0.0.M6) It is possible to exclude endpoints from generation so it is possible to create a
66+
hand written interface for the excluded endpoint.
67+
68+
Excluding does not completely ignore the endpoint. Instead of generating it into the normal interface
69+
it is generated to a new interface with `Excluded` attached to its name. Type mappings still apply.
70+
71+
That way the the generated code is still available for reference but it can be skipped by not
72+
implementing the `Excluded` interface.
73+
74+
```yaml
75+
map:
76+
/foo:
77+
# excluding an endpoint
78+
exclude: true
79+
```

docs/mapping/structure.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ parent: Type Mapping
55
nav_order: 5
66
---
77

8-
# mapping.yaml structure
8+
# type mapping structure
99

10-
A type mapping yaml has multiple sections to define the different kinds of type mappings. All sections
11-
are optional.
10+
The type mapping is part of the mapping yaml (see [Configuration][docs-configuration]) and configured under
11+
the `map` key. The `map` key contains multiple sections to define the different kinds of type mappings.
12+
All sections are optional.
1213

1314
```yaml
1415
map:
@@ -50,3 +51,5 @@ A type mapping yaml has multiple sections to define the different kinds of type
5051
to: ..
5152

5253
```
54+
55+
[docs-configuration]: /openapi-generatr-spring/generatr/configuration.html

0 commit comments

Comments
 (0)