Skip to content

Commit 4b88252

Browse files
committed
improved docs
1 parent 1261ab5 commit 4b88252

16 files changed

Lines changed: 63 additions & 74 deletions

docs/modules/ROOT/pages/api.adoc

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/modules/ROOT/pages/gradle.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The following sections describe how to activate & configure **openapi-processor-
1111
1212
== adding the plugin
1313
14-
The [openapi-processor-gradle][oap-gradle] plugin is activated (like any other gradle plugin) in
15-
the `plugins` configuration:
14+
To [openapi-processor-gradle][oap-gradle] activate the plugin add it to (like any other gradle
15+
plugin) the `plugins` configuration:
1616
1717
[source,groovy]
1818
----
@@ -26,7 +26,7 @@ plugins {
2626
== configuring processor-spring
2727

2828
The plugin will add an `openapiProcessor` configuration block that is used to configure the processors.
29-
Configuration for a specific processor is placed inside it using the processor name as configuration
29+
Configuration for a specific processor belongs inside it with the processor name as configuration
3030
block name.
3131

3232
[source,groovy]
@@ -49,11 +49,11 @@ dependency to a configuration in the gradle `dependencies` block. It is given he
4949
un-wanted side effects on the build dependencies of the project.
5050

5151
* `apiPath`: (**required**) the path to the `openapi.yaml` file and the main input for the
52-
processor. If set in the top level block it will be used for all configured processors.
52+
processor. If set in the top-level block it will be used for all configured processors.
5353

5454
* `targetDir`: (**required**) the output folder for generating interfaces & models. This is the
5555
parent of the `packageName` folder tree. It is recommended to set this to a subfolder of gradle's
56-
standard `build` directory so it is cleared by the `clean` task and does not pollute the sources
56+
standard `build` directory, so it is cleared by the `clean` task and does not pollute the `sources`
5757
directory.
5858
+
5959
See <<running processor-spring>> how to include the `targetDir` in compilation & packing.
@@ -70,7 +70,7 @@ yaml. This replaces the `typeMappings` option.
7070

7171
The plugin will add a gradle task `processSpring` to run the processor.
7272

73-
To automatically generate & compile the processor output two additional configurations are required.
73+
To automatically generate & compile the processor output two additional configurations are necessary.
7474

7575
* the `sourceSets` are extended to include the processor output (assuming a java project):
7676
+
@@ -86,7 +86,7 @@ sourceSets {
8686
}
8787
----
8888

89-
* and the `compileJava` task gets a dependency on `processSpring` so it runs before compilation
89+
* and the `compileJava` task gets a dependency on `processSpring`, so it runs before compilation
9090
(again, assuming a java project):
9191
+
9292
[source,groovy]

docs/modules/ROOT/pages/howto/global-array-mapping.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
= map openapi array (globally) to a java collection type
22

3-
By default the OpenAPI `array` is mapped to a simple java array. That is probably the first thing
3+
By default, the OpenAPI `array` maps to a simple java array. That is probably the first thing
44
you want to change.
55

66
To change that default mapping for example to `java.util.Collection` a simple global type mapping
7-
is required in the xref:mapping/index.adoc[`mapping.yaml`].
7+
is necessary in the xref:mapping/index.adoc[`mapping.yaml`].
88

99
Given the following openapi.yaml fragment:
1010

docs/modules/ROOT/pages/howto/pageable-page-mapping.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= using Spring Pageable & Page
22

33
The given (lengthy) openapi yaml example describes a pageable api in two variations. The `/page`
4-
endpoint uses named objects and the second endpoint `/page-inline` uses inline objects to describe
4+
endpoint uses named objects, and the second endpoint `/page-inline` uses inline objects to describe
55
the paging parameters and the page response. We fill focus on the first variation.
66

77
[source,yaml]
@@ -91,14 +91,14 @@ components:
9191
----
9292

9393
<1> Describing the `Pageable` query parameters `page`, `size` etc in OpenAPI as an `object` lets us
94-
group the parameters. That tells someone reading the api that they belong together and we can avoid
94+
group the parameters. That tells a reader of the api that they belong together, and we can avoid
9595
confusion when there are more query parameters.
9696

9797
<2> Describing the `Page` result is a bit more complicated. OpenAPI does not have generic types
9898
which we would like to have to define what type is in the content list of the page.
9999
+
100100
The best OpenAPI way is to define two objects. The first one describes the common properties of the
101-
`Page` response and the second one the content list of the page. In this example the `StringContent`
101+
`Page` response, and the second one the content list of the page. In this example the `StringContent`
102102
with an array of `string`.
103103
+
104104
Using OpenAPIs `allOf` construct we join both objects to describe a complete response that
@@ -185,7 +185,7 @@ generic type of the page `content`.
185185

186186
<3> mapping for the inline version.
187187

188-
Usually you would use the first variation using named objects so they can be re-used on other
188+
Usually you would use the first variation using named objects, so they can be re-used on other
189189
endpoints.
190190

191191
Worth mentioning is that the processor will not generate model classes for the openapi types

docs/modules/ROOT/pages/mapping/endpoint.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ have any effect on other endpoints.
7373

7474
[.badge .badge-since]+since 1.0.0.M6+
7575

76-
It is possible to exclude endpoints from generation so it is possible to create a
77-
hand written interface for the excluded endpoint.
76+
It is possible to exclude endpoints from generation to make it easier to provide a hand written
77+
interface for the excluded endpoint.
7878

7979
Excluding does not completely ignore the endpoint. Instead of generating it into the normal
8080
interface it is generated to a new interface with `Excluded` attached to its name. Type mappings
8181
still apply.
8282

83-
That way the the generated code is still available for reference but it can be skipped by not
83+
That way the generated code is still available for reference, but it can be skipped by not
8484
implementing the `Excluded` interface.
8585

8686
[source,yaml]

docs/modules/ROOT/pages/mapping/global.adoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Global type mapping will replace **any** usage of an OpenAPI type in the api description to the
44
given java type.
55

6-
It is defined like below and it should be added to the `map/types` section in the `mapping.yaml`
6+
It is defined like below, and it should be added to the `map/types` section in the `mapping.yaml`
77
which is a list of global type mappings.
88

99
A single global mapping can have the following properties:
@@ -50,7 +50,7 @@ can be mapped to an existing `Book` java type/class by the following mapping:
5050
to: com.github.hauner.openapi.oap.Book
5151
----
5252

53-
It is also possible to use a predefined OpenAPI type as the `from` type of a type mapping:
53+
It is also possible to use a predefined OpenAPI type in the `from` type of the type mapping:
5454

5555
[source,yaml]
5656
----
@@ -60,7 +60,7 @@ It is also possible to use a predefined OpenAPI type as the `from` type of a typ
6060

6161
This tells the processor to us a `java.util.List` instead of the OpenAPI type `array`.
6262

63-
The **generics** parameter is not required in this special case. The processor knows `java.util.List`
63+
The **generics** parameter is unnecessary in this special case. The processor knows `java.util.List`
6464
and will automatically use the `items` property of the `array` as the generic type.
6565

6666
[CAUTION]
@@ -69,7 +69,7 @@ and will automatically use the `items` property of the `array` as the generic ty
6969
assumes that it is just a schema name and it will only match if there is a schema with the name
7070
"object".
7171
* global type mappings do work on OpenAPI inline schemas using the automatically generated name.
72-
This is not recommended as a small change to the api description could changes the inline name and
72+
This is not recommended as a small change to the api description could change the inline name and
7373
break the mapping.
7474
====
7575

@@ -89,16 +89,16 @@ to the **from** property value separated by a ':' like this:
8989
to: java.time.ZonedDateTime
9090
----
9191

92-
This maps the `string` type with `date-time` format from the default `java.time.OffsetDateTime` to
93-
`java.time.ZonedDateTime`. `string` without format or `string` with other formats are not affected
94-
by this mapping.
92+
This maps the `string` type with a `date-time` format from the default `java.time.OffsetDateTime` to
93+
`java.time.ZonedDateTime`. The mapping does not affect `string` without a format or `string` with
94+
other formats.
9595

9696
== mapping with generic types
9797

98-
Type mapping allows to use a target type that has generic parameters. The generic types are defined
98+
Type mapping allows to use a target type that has generic parameters. The generic types are given
9999
by the **generics** property of the mapping. **generics** is a list and can contain multiple types.
100100

101-
For example if a `StringPage` schema is defined in the OpenAPI that corresponds to
101+
For example if a `StringPage` schema in the OpenAPI corresponds to
102102
`org.springframework.data.domain.Page<java.lang.String>`, it can be mapped to the Spring type by:
103103

104104
[source,yaml]

docs/modules/ROOT/pages/mapping/parameter.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Global parameter mapping will replace any usage of an OpenAPI type in the api description based on
44
the parameters **name** to the given java type.
55

6-
It is defined like below and it should be added to the `map/parameters` section in the mapping.yaml
6+
It is defined like below, and it should be added to the `map/parameters` section in the mapping.yaml
77
which is a list of global parameter mappings.
88

99
A single global parameter mapping can have the following properties:
@@ -19,11 +19,11 @@ A single global parameter mapping can have the following properties:
1919

2020
* **name** and **to** are required.
2121
22-
* **name** is the name of an endpoint parameter used in the OpenAPI description that should be replaced
23-
by **to**.
22+
* **name** is the name of an endpoint parameter used in the OpenAPI description that should be
23+
replaced by **to**.
2424
2525
* **to** is the fully qualified class name of the java type that should be used for all endpoint
26-
parameters of name **name**.
26+
parameters of **name**.
2727
2828
* **generics** defines the list of types that should be used as generic type parameters to the
2929
java type given by **to**.

docs/modules/ROOT/pages/mapping/response.adoc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
= (global) Response mappings
22

3-
Global response mapping will replace the result type of an endpoint in the api description based on
3+
Global response mapping will replace the result type of the endpoint in the api description based on
44
its **content type** to the given java type.
55

6-
It is defined like below and it should be added to the `map/responses` section in the mapping.yaml
6+
It is defined like below, and it should be added to the `map/responses` section in the mapping.yaml
77
which is a list of global response mappings.
88

99
A single global response mapping can have the following properties:
@@ -19,7 +19,7 @@ A single global response mapping can have the following properties:
1919

2020
* **content** and **to** are required.
2121
22-
* **content** is the name of the content type of an endpoint response that should be replaced
22+
* **content** is the name of the content type of the endpoint response that should be replaced
2323
by **to**.
2424
2525
* **to** is the fully qualified class name of the java type that should be used for all endpoint
@@ -33,8 +33,8 @@ java type given by **to**.
3333
Since the processor will simply match the content type string take care that all responses of this
3434
content type should really use the same type!
3535
36-
This is probably only useful for vendor content types. Globally mapping the content type for example
37-
of `application/json` does not look like a good idea.
36+
This is probably only useful for a vendor content types. Globally mapping the content type for
37+
example of `application/json` does not look like a good idea.
3838
====
3939

4040
== Example
@@ -51,7 +51,8 @@ map:
5151
to: com.github.hauner.openapi.Something
5252
----
5353

54-
and an openapi.yaml with multiple endpoints returning their result as content type `application/vnd.something`
54+
and an openapi.yaml with multiple endpoints returning their result as content type
55+
`application/vnd.something`
5556

5657
[source,yaml]
5758
----

docs/modules/ROOT/pages/processor/configuration.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
= Configuration
22
include::partial$links.adoc[]
33

4-
The configuration of the processor is read from the (mandatory) `mapping.yaml` file. It does contain
4+
The processor reads the configuration from the (mandatory) `mapping.yaml` file. It does contain
55
some general options and the xref:mapping/index.adoc[mapping] type information.
66

7-
A mapping yaml looks like this
7+
A mapping yaml looks like this:
88

99
[source,yaml]
1010
----
@@ -24,11 +24,11 @@ package folder tree will be created inside the `targetDir` (see xref:gradle.ado
2424
+
2525
Interfaces and models will be generated into the `api` and `model` subpackages of `package-name`.
2626
+
27-
** so the final package name of the generated interfaces will be `"$\{package-name\}.api"`
27+
** so the final package name of the generated interfaces will be `"$\{package-name\}.api"`,
2828
** and the final package name of the generated models will be `"$\{package-name\}.model"`
2929

3030
* `bean-validation` (**optional**, `true` or `false`) enables generation of bean validation
31-
annotations. Defaults to `false`. See link:{bean-validation}[Bean Validation, window="_blank"].
31+
annotations. Default is `false`. See link:{bean-validation}[Bean Validation, window="_blank"].
3232

3333
== map:
3434

docs/modules/ROOT/pages/processor/endpoint-content.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A simple path of the OpenAPI description will usually produce a single endpoint
44
interface as described in the introduction.
55

66
OpenAPI allows us to define more complex apis that behave differently based on the request header.
7-
For example the following api definition can return its response in different format. As json or as
7+
For example the following api definition can return its response in different formats. As json or as
88
plain text:
99

1010
[source,yaml]
@@ -85,8 +85,8 @@ public interface Api {
8585
The apis normal response (status '200') can return the result as json or as plain text which leads
8686
to two methods for the same endpoint but with a different `produces` list in the mapping annotation.
8787

88-
One method which is called when json is requested and one when plain text is requested. Spring will
89-
take care of selecting the correct endpoint.
88+
One method when json gets requested and one when plain text gets requested. Spring will take care of
89+
selecting the correct endpoint.
9090

9191

9292
== multiple content types & default content type
@@ -116,7 +116,7 @@ public interface Api {
116116
}
117117
----
118118

119-
Both endpoints need to handle the success case (json or text) and the error (xml) case. So both
119+
Both endpoints need to handle the success case (json or text), and the error (xml) case. So both
120120
mappings contain the xml content type. To handle the multiple responses the return type is now
121121
`Object`.
122122

@@ -155,5 +155,5 @@ public interface Api {
155155
}
156156
----
157157

158-
The response type is now wrapped by a `ResponseEntity` and to handle the multiple response type the
158+
The response wraps the type by a `ResponseEntity` and to handle the multiple response types the
159159
generic parameter is the *unknown* type.

0 commit comments

Comments
 (0)