Skip to content

Commit d06d12c

Browse files
committed
1 parent f3c7d7b commit d06d12c

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

docs/modules/ROOT/pages/processor/package-names.adoc

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
include::partial$links.adoc[]
22
include::partial$vars.adoc[]
33

4-
= package-names
4+
= package-names from location
55

6-
[WARNING]
7-
====
8-
This is still a bit experimental and may not behave nicely if the expected configuration requirements are not met.
6+
The *package-names from location* feature allows the processor to create package names based on the file location of $ref'erenced parts of the OpenAPI description.
97

10-
It also works *only* with the `INTERNAL` OpenAPI parser, which is the default OpenAPI parser.
11-
====
8+
This gets enabled by setting the `package-names:location` option.
129

13-
== package-names-from-path
10+
== package-names:location
1411

15-
The `package-name-from-path` option enables the creation of package names based on the file location of $ref'erenced parts of the OpenAPI description.
12+
`package-names:location` is the *parent* package for location based package names.
1613

17-
Enabling this has a few requirements:
14+
Only (OpenAPI) file locations below the parent package will be generated with a location based package name. Any other (OpenAPI) file location will use `package-names.base` (or `package-name`) as the package name.
1815

19-
- `package-name` must match a specific *parent* package name of the target package in the production code.
20-
+
21-
The *parent* package should be shorter than the *target* package, and the *target* package should start with the *parent* package.
22-
+
23-
See the example below.
16+
Enabling this has a few conditions:
2417

25-
- to create an interface or resource with a specific package, its OpenAPI description has to be in the *target* package and must be reachable from the root OpenAPI description.
18+
- to create an interface or resource in a specific package, its OpenAPI description has to be in the target package and must be reachable from the root OpenAPI description.
2619

27-
- it is only supported with the `INTERNAL` OpenAPI parser (it is the default parser). It will not work with the `SWAGGER` OpenAPI parser.
20+
- it only works with the `INTERNAL` OpenAPI parser (it is the default parser). It will not work with the `SWAGGER` OpenAPI parser.
2821

2922
=== mapping.yaml
3023

@@ -36,14 +29,19 @@ openapi-processor-mapping: {var-mapping-version}
3629
3730
options:
3831
# this must be a parent package of the target packages
39-
package-name: io.openapiprocessor.samples # <2>
32+
#package-name: io.openapiprocessor.openapi # <1>
4033
41-
# this enables package generation from the endpoint $ref file location
42-
package-name-from-path: true # <1>
34+
package-names:
35+
base: io.openapiprocessor.openapi # <2>
36+
# this enables package generation from the endpoint $ref file location
37+
location: io.openapiprocessor.samples # <3>
4338
----
4439

45-
<1> this enables the package-name feature. Default is `false`.
46-
<2> the `package-name`, this *must* be a *parent* package name of the project's *target* packages.
40+
<1> the shortcut for setting `package-names.base`. If location based packages should be used, setting `package-names.base` is preferred.
41+
42+
<2> this is the base package for all generated code. This is identical to the current behaviour (i.e. `package-name`). Any file the is not below `package-names.location` will be generated with this as the base package.
43+
44+
<3> `package-name.location` is the *parent* package name of the project's *target* packages. If the processor finds a file ref'erenced from the main OpenAPI in a subpackage of `package-name.location` the generated sources will be generated with that package.
4745

4846
=== OpenAPI and $refs
4947

@@ -164,12 +162,10 @@ Having an idea now how the files are organized, it is possible to explain which
164162

165163
From the file tree above:
166164

167-
The package name of the `foo` endpoint files is `io.openapiprocessor.samples.foo` and the nearest *parent* package is `io.openapiprocessor.samples`. This is then the `package-name` option value.
165+
The package name of the `foo` endpoint files is `io.openapiprocessor.samples.foo` and the nearest *parent* package is `io.openapiprocessor.samples`. This is then the `package-names.location` option value.
168166

169167
It is possible to use `io.openapiprocessor` or even `io` as the *parent* package.
170168

171-
Important is that the *parent* package is shorter than the *target* package and that the *target* package starts with the *parent* package.
172-
173169
=== directory structure after processing
174170

175171
Assuming a Gradle build, the directory structure after processing is:

0 commit comments

Comments
 (0)