OpenAPITools / OpenAPITools/openapi-generator

[BUG][AsciiDoc] specDir weirdness

Open
#20,996 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Taskfile.yml and infrastructure/Containerfile, reproducing task openapi and task asciidoc with openapi-generator-cli 7.12.0. Inspect the AsciiDoc generator entry point handling specDir and the generated include directives. Done means determining whether the documented include behavior can work without the symlink while retaining optional includes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.