@@ -164,7 +164,7 @@ public List<Path> write(
164164
165165 private SpecVersion specVersion = SpecVersion .V30 ;
166166
167- private AsciiDocContext asciidoc ;
167+ private boolean javadoc = true ;
168168
169169 /** Default constructor. */
170170 public OpenAPIGenerator () {}
@@ -216,17 +216,15 @@ public OpenAPIGenerator() {}
216216 * @return Model.
217217 */
218218 public @ NonNull OpenAPI generate (@ NonNull String classname ) {
219- ClassLoader classLoader =
220- Optional .ofNullable (this .classLoader ).orElseGet (getClass ()::getClassLoader );
219+ var classLoader = Optional .ofNullable (this .classLoader ).orElseGet (getClass ()::getClassLoader );
221220
222- ClassSource source = new ClassSource (classLoader );
221+ var source = new ClassSource (classLoader );
223222
224223 /* Create OpenAPI from template and make sure min required information is present: */
225- OpenAPIExt openapi =
226- new OpenApiTemplate (specVersion ).fromTemplate (basedir , classLoader , templateName );
224+ var openapi = new OpenApiTemplate (specVersion ).fromTemplate (basedir , classLoader , templateName );
227225
228226 var mainType = TypeFactory .fromJavaName (classname );
229- var javadoc = new JavaDocParser (sources );
227+ var javadoc = this . javadoc ? new JavaDocParser (sources ) : JavaDocParser . NOOP ;
230228
231229 if (openapi .getInfo () == null ) {
232230 var info = new Info ();
@@ -249,14 +247,13 @@ public OpenAPIGenerator() {}
249247 });
250248 }
251249
252- RouteParser routes = new RouteParser ();
250+ var routes = new RouteParser ();
253251 var json = jsonMapper ();
254252 var yaml = yamlMapper ();
255- ParserContext ctx =
256- new ParserContext (specVersion , json , yaml , source , mainType , javadoc , debug );
257- List <OperationExt > operations = routes .parse (ctx , openapi );
253+ var ctx = new ParserContext (specVersion , json , yaml , source , mainType , javadoc , debug );
254+ var operations = routes .parse (ctx , openapi );
258255
259- String contextPath = ContextPathParser .parse (ctx );
256+ var contextPath = ContextPathParser .parse (ctx );
260257
261258 openapi .setSource (Optional .ofNullable (ctx .getMainClass ()).orElse (classname ));
262259
@@ -268,20 +265,20 @@ public OpenAPIGenerator() {}
268265 ctx .schemas ().forEach (schema -> openapi .schema (schema .getName (), schema ));
269266
270267 Map <String , Tag > globalTags = new LinkedHashMap <>();
271- Paths paths = new Paths ();
272- for (OperationExt operation : operations ) {
273- String pattern = operation .getPath ();
268+ var paths = new Paths ();
269+ for (var operation : operations ) {
270+ var pattern = operation .getPath ();
274271 if (!includes (pattern ) || excludes (pattern )) {
275272 log .debug ("skipping {}" , pattern );
276273 continue ;
277274 }
278- Map < String , String > regexMap = new HashMap <>();
275+ var regexMap = new HashMap <String , String >();
279276 Router .pathKeys (
280277 pattern , (key , value ) -> Optional .ofNullable (value ).ifPresent (v -> regexMap .put (key , v )));
281278 if (!regexMap .isEmpty ()) {
282- for (Map . Entry < String , String > e : regexMap .entrySet ()) {
283- String name = e .getKey ();
284- String regex = e .getValue ();
279+ for (var e : regexMap .entrySet ()) {
280+ var name = e .getKey ();
281+ var regex = e .getValue ();
285282 operation
286283 .getParameter (name )
287284 .ifPresent (parameter -> parameter .getSchema ().setPattern (regex ));
@@ -296,7 +293,7 @@ public OpenAPIGenerator() {}
296293 }
297294 }
298295 }
299- PathItem pathItem = paths .computeIfAbsent (pattern , k -> new PathItem ());
296+ var pathItem = paths .computeIfAbsent (pattern , k -> new PathItem ());
300297 pathItem .operation (PathItem .HttpMethod .valueOf (operation .getMethod ()), operation );
301298 Optional .ofNullable (operation .getPathSummary ()).ifPresent (pathItem ::setSummary );
302299 Optional .ofNullable (operation .getPathDescription ()).ifPresent (pathItem ::setDescription );
@@ -345,12 +342,12 @@ private Optional<Boolean> pattern(String pattern, String value) {
345342 }
346343
347344 private void defaults (String classname , String contextPath , OpenAPIExt openapi ) {
348- Info info = openapi .getInfo ();
345+ var info = openapi .getInfo ();
349346 if (info == null ) {
350347 info = new Info ();
351348 openapi .info (info );
352349 }
353- String appname = appname (classname );
350+ var appname = appname (classname );
354351 info .setTitle (Optional .ofNullable (info .getTitle ()).orElse (appname + " API" ));
355352 info .setDescription (
356353 Optional .ofNullable (info .getDescription ()).orElse (appname + " API description" ));
@@ -561,7 +558,25 @@ public void setSpecVersion(String version) {
561558 }
562559 }
563560
564- protected AsciiDocContext createAsciidoc (Path basedir , OpenAPIExt openapi ) {
561+ /**
562+ * True/On to enabled.
563+ *
564+ * @param javadoc True/On to enabled.
565+ */
566+ public void setJavadoc (String javadoc ) {
567+ this .javadoc = Boolean .parseBoolean (javadoc ) || "on" .equalsIgnoreCase (javadoc );
568+ }
569+
570+ /**
571+ * True/On to enabled.
572+ *
573+ * @return True/On to enabled.
574+ */
575+ public boolean getJavadoc () {
576+ return javadoc ;
577+ }
578+
579+ private AsciiDocContext createAsciidoc (Path basedir , OpenAPIExt openapi ) {
565580 return new AsciiDocContext (basedir , jsonMapper (), yamlMapper (), openapi );
566581 }
567582
0 commit comments