Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][AsciiDoc] specDir weirdness #20996

Open
unexist opened this issue Mar 30, 2025 · 0 comments
Open

[BUG][AsciiDoc] specDir weirdness #20996

unexist opened this issue Mar 30, 2025 · 0 comments

Comments

@unexist
Copy link

unexist commented Mar 30, 2025

Description

I want to generate an asciidoc doc via openapi-generator-cli based on a working openapi v3.1.0 specification in a container (which validates properly at https://editor-next.swagger.io/) and also provide more information via the various includes in the generated index.

Just for reference, the containerfile is this: https://github.com/unexist/showcase-openapi-asciidoc/blob/master/infrastructure/Containerfile

According to the generated index, it seems all I have to set is the specDir property and this should allow the generator to include my files. My observations are when I set the specDir it is used to check at "buildtime" if the paths exists and the includes are either set if the spec can be found or otherwise they are commented out:

include::{specDir}intro.adoc[opts=optional]

// markup not found, no include::{specDir}intro.adoc[opts=optional]

This is a bit odd to me, since the opts=optional attribute already handles that in a sane way. Even worse, the path that has to be verifiable at "buildtime" is also used in the include directive.

So the actual problem is the specDir path must be valid at the times of build and include, which is difficult due to the nature of how include paths are resolved:

Image

To bypass this I have to create a symlink, otherwise the checks never succeed for me:

podman run --rm -v .:{{.MOUNT_PATH}} \ -it docker.io/unexist/{{.IMAGE_NAME}}:{{.IMAGE_VERSION}} \ sh -c "cd {{.MOUNT_PATH}} && **ln -s asciidoc/src/site/asciidoc/spec spec** \ && openapi-generator-cli generate -g asciidoc \ --input-spec=asciidoc/src/site/asciidoc/spec/openapi.json \ --output=asciidoc/src/site/asciidoc \ --additional-properties=specDir=spec/,useIntroduction=true \ && unlink spec"

So I might do something completely wrong, but is there a better way of doing it like disabling the check at the buildtime and pass the checks for the includes to asciidoc?

openapi-generator version

I believe the problem is related to the java code and not the CLI, but it is somehow difficult to see the actual version of openapi-generator used, so hopefully this helps:

$ openapi-generator-cli --version openapi-generator-cli 7.12.0 commit : afc27ef built : -999999999-01-01T00:00:00+18:00 source : https://github.com/openapitools/openapi-generator docs : https://openapi-generator.tech/

OpenAPI declaration file content or url

Spec: https://github.com/unexist/showcase-openapi-asciidoc/blob/master/asciidoc/src/site/asciidoc/spec/openapi.json

Generation Details

$ openapi-generator-cli generate -g asciidoc \ --input-spec=asciidoc/src/site/asciidoc/spec/openapi.json \ --output=asciidoc/src/site/asciidoc \ --additional-properties=specDir=spec/,useIntroduction=true

Steps to reproduce

The steps to reproduce are as following:

  1. $ task openapi
  2. $ task asciidoc

The Taskfile contains everything to check:

https://github.com/unexist/showcase-openapi-asciidoc/blob/master/Taskfile.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant