Skip to content

Commit 4647400

Browse files
committed
open-api: disable javadoc parsing by default
- fix #3841 - allow to set option from maven/gradle
1 parent 37a2510 commit 4647400

File tree

4 files changed

+85
-9
lines changed

4 files changed

+85
-9
lines changed

docs/asciidoc/modules/openapi.adoc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,25 @@ To avoid this behaviour you can specify maven build phase which suits your needs
108108
| `${project.dir}`
109109
|Set base directory used it for loading openAPI template file name.
110110

111+
|`excludes`
112+
|
113+
|Regular expression used to excludes route. Example: `/web`.
114+
111115
|`includes`
112116
|
113117
|Regular expression used to includes/keep route. Example: `/api/.*`.
114118

115-
|`excludes`
116-
|
117-
|Regular expression used to excludes route. Example: `/web`.
119+
|`javadoc`
120+
|`on/true`
121+
|Turn on/off javadoc generation from Java source files. Set to `off` or `false` to turn it off.
118122

119123
|`specVersion`
120124
|`3.0`
121-
|Set the desired spec output
125+
|Set the desired spec output. Possible values: `3.0` or `3.1`
122126

123127
|`templateName`
124128
|`openapi.yaml`
125-
|Set openAPI template file name.
129+
|Set openAPI template file path.
126130

127131
|===
128132

@@ -191,7 +195,7 @@ You will find the files in the output build directory. If your application is `b
191195
This is the main difference with previous version. We moved from runtime to build time generation. This way we:
192196
193197
- Are able to get our OpenAPI files at build time (of course)
194-
- At runtime we don't waste resources (CPU, memory) while analyze and build the OpenAPI model
198+
- At runtime, we don't waste resources (CPU, memory) while analyze and build the OpenAPI model
195199
- We keep bootstrap as fast as possible
196200
====
197201

@@ -254,7 +258,7 @@ Full/complete example available https://github.com/jooby-project/library-demo[he
254258

255259
==== JavaDoc comments
256260

257-
JavaDoc comments are supported on Java in script and MVC routes.
261+
JavaDoc comments are supported for script and MVC routes on Java code base. They are enable by default, to turn them off set `javadoc: off` or `javadoc: false` in your maven/gradle plugin.
258262

259263
.Script routes
260264
[source,java, role="primary"]

modules/jooby-gradle-plugin/src/main/java/io/jooby/gradle/OpenAPITask.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public class OpenAPITask extends BaseTask {
4242

4343
private List<File> adoc;
4444

45+
private String javadoc;
46+
4547
/**
4648
* Creates an OpenAPI task.
4749
*/
@@ -85,6 +87,9 @@ public void generate() throws Throwable {
8587
}
8688
trim(includes).ifPresent(tool::setIncludes);
8789
trim(excludes).ifPresent(tool::setExcludes);
90+
if (javadoc != null && !javadoc.trim().isEmpty()) {
91+
tool.setJavadoc(javadoc.trim());
92+
}
8893

8994
OpenAPI result = tool.generate(mainClass);
9095

@@ -195,6 +200,29 @@ public void setSpecVersion(String specVersion) {
195200
this.specVersion = specVersion;
196201
}
197202

203+
/**
204+
* True/On to enabled javadoc output. Default is: <code>on</code>.
205+
*
206+
* @return True/On to enabled javadoc output. Default is: <code>on</code>.
207+
*/
208+
@Input
209+
@org.gradle.api.tasks.Optional
210+
public String getJavadoc() {
211+
return javadoc;
212+
}
213+
214+
215+
/**
216+
* Enabled or disabled javadoc generation. Set to off/false to turn it off.
217+
* Default is: <code>on</code>.
218+
*
219+
* @param javadoc Enabled or disabled javadoc generation. Set to off/false to turn it off.
220+
* Default is: <code>on</code>.
221+
*/
222+
public void setJavadoc(String javadoc) {
223+
this.javadoc = javadoc;
224+
}
225+
198226
/**
199227
* Optionally generates adoc output.
200228
*

modules/jooby-maven-plugin/src/main/java/io/jooby/maven/OpenAPIMojo.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class OpenAPIMojo extends BaseMojo {
4949
@Parameter(property = "openAPI.specVersion")
5050
private String specVersion;
5151

52+
@Parameter(property = "openAPI.javadoc")
53+
private String javadoc;
54+
5255
@Parameter private List<File> adoc;
5356

5457
@Override
@@ -76,6 +79,9 @@ protected void doExecute(@NonNull List<MavenProject> projects, @NonNull String m
7679
tool.setSources(sources);
7780
trim(includes).ifPresent(tool::setIncludes);
7881
trim(excludes).ifPresent(tool::setExcludes);
82+
if (javadoc != null && !javadoc.trim().isEmpty()) {
83+
tool.setJavadoc(javadoc.trim());
84+
}
7985

8086
var result = tool.generate(mainClass);
8187

@@ -129,19 +135,57 @@ public void setExcludes(@Nullable String excludes) {
129135
this.excludes = excludes;
130136
}
131137

138+
/**
139+
* Spec version. Default is <code>3.0</code>.
140+
*
141+
* @return Spec version. Default is <code>3.0</code>.
142+
*/
132143
public String getSpecVersion() {
133144
return specVersion;
134145
}
135146

147+
/**
148+
* Set the desired spec output. Default is <code>3.0</code>.
149+
*
150+
* @param specVersion One of <code>3.0</code> or <code>3.0</code>.
151+
*/
136152
public void setSpecVersion(String specVersion) {
137153
this.specVersion = specVersion;
138154
}
139155

156+
/**
157+
* List of asciidoc files to generate documentation.
158+
*
159+
* @return List of asciidoc files to generate documentation.
160+
*/
140161
public List<File> getAdoc() {
141162
return adoc;
142163
}
143164

165+
/**
166+
* List of asciidoc files to generate documentation.
167+
*
168+
* @param adoc List of asciidoc files to generate documentation.
169+
*/
144170
public void setAdoc(List<File> adoc) {
145171
this.adoc = adoc;
146172
}
173+
174+
/**
175+
* True/On to enabled. By default is: <code>on</code>.
176+
*
177+
* @param javadoc True/On to enabled.
178+
*/
179+
public void setJavadoc(String javadoc) {
180+
this.javadoc = javadoc;
181+
}
182+
183+
/**
184+
* True/On to enabled.
185+
*
186+
* @return True/On to enabled.
187+
*/
188+
public String getJavadoc() {
189+
return javadoc;
190+
}
147191
}

modules/jooby-openapi/src/main/java/io/jooby/openapi/OpenAPIGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ public void setOutputDir(@NonNull Path outputDir) {
531531
}
532532

533533
/**
534-
* Set the desired spec output. Default is <code>3.1</code>.
534+
* Set the desired spec output. Default is <code>3.0</code>.
535535
*
536-
* @param specVersion One of <code>3.0</code> or <code>3.1</code>.
536+
* @param specVersion One of <code>3.0</code> or <code>3.0</code>.
537537
*/
538538
private void setSpecVersion(SpecVersion specVersion) {
539539
this.specVersion = specVersion;

0 commit comments

Comments
 (0)