You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/processor/package-names.adoc
+20-24Lines changed: 20 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,23 @@
1
1
include::partial$links.adoc[]
2
2
include::partial$vars.adoc[]
3
3
4
-
= package-names
4
+
= package-names from location
5
5
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.
9
7
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.
12
9
13
-
== package-names-from-path
10
+
== package-names:location
14
11
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.
16
13
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.
18
15
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:
24
17
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.
26
19
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.
# this must be a parent package of the target packages
39
-
package-name: io.openapiprocessor.samples # <2>
32
+
#package-name: io.openapiprocessor.openapi # <1>
40
33
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>
43
38
----
44
39
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.
47
45
48
46
=== OpenAPI and $refs
49
47
@@ -164,12 +162,10 @@ Having an idea now how the files are organized, it is possible to explain which
164
162
165
163
From the file tree above:
166
164
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.
168
166
169
167
It is possible to use `io.openapiprocessor` or even `io` as the *parent* package.
170
168
171
-
Important is that the *parent* package is shorter than the *target* package and that the *target* package starts with the *parent* package.
172
-
173
169
=== directory structure after processing
174
170
175
171
Assuming a Gradle build, the directory structure after processing is:
0 commit comments