Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3d6e133
v4.0.11
jknack Nov 4, 2025
30fa9b3
prepare for next development cycle
jknack Nov 4, 2025
4edacc7
WIP: openapi: asciidoc output #3820
jknack Nov 25, 2025
f5b0a66
prepare for next development cycle
jknack Nov 26, 2025
0c46eff
Merge branch 'main' into 3820
jknack Nov 26, 2025
bc0ac2e
filter: curl
jknack Nov 27, 2025
db3bc07
openapi: asciidoc output
jknack Nov 30, 2025
2fb853d
openapi: asciidoc output #3820
jknack Dec 3, 2025
22ddb2a
openapi: asciidoc output #3820
jknack Dec 4, 2025
806f9b3
windows: attempt to find blank difference
jknack Dec 4, 2025
66c7594
- integrate ascii doc into openapi generator: maven/gradle plugin
jknack Dec 6, 2025
fa9664b
- better implementation for summary/description doc
jknack Dec 6, 2025
af49d46
- add POST, PUT,.., adoc operations
jknack Dec 6, 2025
620c75d
- add `path` filter with replace query and path paramters
jknack Dec 7, 2025
9842652
- enum doc: add field doc with custom implementation
jknack Dec 7, 2025
7ad2da4
pebble/ascii doc support: redo pebble function and filter
jknack Dec 13, 2025
43fd819
Merge branch 'main' into 3820
jknack Dec 13, 2025
15c3547
- implementation complete
jknack Dec 13, 2025
97d4e29
- cleanup, remove all implementation
jknack Dec 13, 2025
9ba72dc
- remove dead template files
jknack Dec 13, 2025
49088f1
- fix build #3820
jknack Dec 14, 2025
b3635f3
- build: fix new line on windows
jknack Dec 14, 2025
21d70bd
set default error response:
jknack Dec 14, 2025
567e7b4
statusCode: add way to display status code
jknack Dec 14, 2025
2e0e982
routes: add route summary
jknack Dec 14, 2025
ebd88ef
- code cleanup
jknack Dec 14, 2025
bbcf676
- implement dyamic display based on tags
jknack Dec 14, 2025
daf6090
link: add link to schema filter
jknack Dec 15, 2025
3daa475
open api: fix `type` vs `types` difference over `v30` vs `v31`
jknack Dec 15, 2025
afcdad3
- fix sample data/schema properties for array of basic types/as well …
jknack Dec 15, 2025
21711e4
- make schemas easier to navigate/iterate and display
jknack Dec 15, 2025
b506895
- add extensions to http request
jknack Dec 15, 2025
fd5e381
- document ascii doc support
jknack Dec 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
445 changes: 445 additions & 0 deletions docs/asciidoc/modules/openapi-ascii.adoc

Large diffs are not rendered by default.

157 changes: 106 additions & 51 deletions docs/asciidoc/modules/openapi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ This library supports:
<goals>
<goal>openapi</goal>
</goals>
<configuration>
<specVersion>...</specVersion>
<adoc>
<file>...</file>
</adoc>
</configuration>
</execution>
</executions>
</plugin>
Expand Down Expand Up @@ -193,7 +199,9 @@ class Pets {
The Maven plugin and Gradle task provide two filter properties `includes` and `excludes`. These
properties filter routes by their path pattern. The filter is a regular expression.

=== JavaDoc comments
=== Documenting your API

==== JavaDoc comments

JavaDoc comments are supported on Java in script and MVC routes.

Expand Down Expand Up @@ -384,6 +392,49 @@ Whitespaces (including new lines) are ignored. To introduce a new line, you must
|
|

|@securityScheme.name
|[x]
|
|
|

|@securityScheme.in
|[x]
|
|
|

|@securityScheme.paramName
|[x]
|
|
|

|@securityScheme.flows.implicit.authorizationUrl
|[x]
|
|
|

|@securityScheme.flows.implicit.scopes.name
|[x]
|
|
|

|@securityScheme.flows.implicit.scopes.description
|[x]
|
|
|

|@securityRequirement
|
|[x]
|[x]
|Name of the `securityScheme` and optionally scopes. Example: `myOauth2Security read:pets`


|@server.description
|[x]
|
Expand Down Expand Up @@ -443,7 +494,56 @@ Whitespaces (including new lines) are ignored. To introduce a new line, you must
This feature is only available for Java routes. Kotlin source code is not supported.


=== Annotations
==== Documentation Template

The OpenAPI output generates some default values for `info` and `server` section. It generates
the necessary to follow the specification and produces a valid output. These sections can be override
with better information/metadata.

To do so just write an `openapi.yaml` file inside the `conf` directory to use it as template.

.conf/openapi.yaml
[source, yaml]
----
openapi: 3.0.1
info:
title: My Super API
description: |
Nunc commodo ipsum vitae dignissim congue. Quisque convallis malesuada tortor, non
lacinia quam malesuada id. Curabitur nisi mi, lobortis non tempus vel, vestibulum et neque.

...
version: "1.0"
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
paths:
/api/pets:
get:
operationId: listPets
description: List and sort pets.
parameters:
name: page
descripton: Page number.

----

All sections from template file are merged into the final output.

The extension property: `x-merge-policy` controls how merge must be done:

- ignore: Silently ignore a path or operation present in template but not found in generated output. This is the default value.
- keep: Add a path or operation to final output. Must be valid path or operation.
- fail: Throw an error when path or operation is present in template but not found in generated output.

The extension property can be added at root/global level, paths, pathItem, operation or parameter level.

[NOTE]
====
Keep in mind that any section found here in the template overrides existing metadata.
====

=== Swagger Annotations

Optionally this plugin depends on some OpenAPI annotations. To use them, you need to add a dependency to your project:

Expand Down Expand Up @@ -679,56 +779,11 @@ You need the `ApiResponse` annotation:
})
----

=== Documentation Template

The OpenAPI output generates some default values for `info` and `server` section. It generates
the necessary to follow the specification and produces a valid output. These sections can be override
with better information/metadata.

To do so just write an `openapi.yaml` file inside the `conf` directory to use it as template.

.conf/openapi.yaml
[source, yaml]
----
openapi: 3.0.1
info:
title: My Super API
description: |
Nunc commodo ipsum vitae dignissim congue. Quisque convallis malesuada tortor, non
lacinia quam malesuada id. Curabitur nisi mi, lobortis non tempus vel, vestibulum et neque.

...
version: "1.0"
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
paths:
/api/pets:
get:
operationId: listPets
description: List and sort pets.
parameters:
name: page
descripton: Page number.

----

All sections from template file are merged into the final output.

The extension property: `x-merge-policy` controls how merge must be done:

- ignore: Silently ignore a path or operation present in template but not found in generated output. This is the default value.
- keep: Add a path or operation to final output. Must be valid path or operation.
- fail: Throw an error when path or operation is present in template but not found in generated output.

The extension property can be added at root/global level, paths, pathItem, operation or parameter level.
=== Output/Display

[NOTE]
====
Keep in mind that any section found here in the template overrides existing metadata.
====
include::modules/openapi-ascii.adoc[]

=== Swagger UI
==== Swagger UI

To use swagger-ui just add the dependency to your project:

Expand All @@ -737,7 +792,7 @@ To use swagger-ui just add the dependency to your project:

The swagger-ui application will be available at `/swagger`. To modify the default path, just call javadoc:OpenAPIModule[swaggerUI, java.lang.String]

=== Redoc
==== Redoc

To use redoc just add the dependency to your project:

Expand Down
48 changes: 24 additions & 24 deletions docs/src/main/java/io/jooby/adoc/DocGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,29 @@ public static void generate(Path basedir, boolean publish, boolean v1, boolean d
pb.step();

if (doAscii) {
Asciidoctor asciidoctor = Asciidoctor.Factory.create();

asciidoctor.convertFile(
asciidoc.resolve("index.adoc").toFile(),
createOptions(asciidoc, outdir, version, null, asciidoc.resolve("index.adoc")));
var index = outdir.resolve("index.html");
Files.writeString(index, hljs(Files.readString(index)));
pb.step();

Stream.of(treeDirs)
.forEach(
throwingConsumer(
name -> {
Path modules = outdir.resolve(name);
Files.createDirectories(modules);
Files.walk(asciidoc.resolve(name))
.filter(Files::isRegularFile)
.forEach(
module -> {
processModule(asciidoctor, asciidoc, module, outdir, name, version);
pb.step();
});
}));
try (var asciidoctor = Asciidoctor.Factory.create()) {
asciidoctor.convertFile(
asciidoc.resolve("index.adoc").toFile(),
createOptions(asciidoc, outdir, version, null, asciidoc.resolve("index.adoc")));
var index = outdir.resolve("index.html");
Files.writeString(index, hljs(Files.readString(index)));
pb.step();

Stream.of(treeDirs)
.forEach(
throwingConsumer(
name -> {
Path modules = outdir.resolve(name);
Files.createDirectories(modules);
Files.walk(asciidoc.resolve(name))
.filter(Files::isRegularFile)
.forEach(
module -> {
processModule(asciidoctor, asciidoc, module, outdir, name, version);
pb.step();
});
}));
}
}

// LICENSE
Expand Down Expand Up @@ -280,7 +280,7 @@ private static Options createOptions(Path basedir, Path outdir, String version,
attributes.attribute("date", DateTimeFormatter.ISO_INSTANT.format(Instant.now()));

OptionsBuilder options = Options.builder();
options.backend("html");
options.backend("html5");

options.attributes(attributes.build());
options.baseDir(basedir.toAbsolutePath().toFile());
Expand Down
Loading