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][TS-fetch] On macOS, the FILES file contains .openapi-generator-ignore in its list of files while on Linux this same FILES file doesn't contain .openapi-generator-ignore in its list of file #20218

Open
6 tasks done
jivanic-demystdata opened this issue Dec 2, 2024 · 4 comments

Comments

@jivanic-demystdata
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When we generate locally, on our macs, our TS SDK, the FILES file contains .openapi-generator-ignore in its list of files, while when we do the same thing in CI, on a Linux machine, the same file doesn't contain .openapi-generator-ignore in its list of files

openapi-generator version

7.10.0 (not yet released)

OpenAPI declaration file content or url

private. Can't share

Generation Details
java -jar openapi-generator-cli.jar generate \
  -i http://localhost:34567/docs/openapi/mydoc.json \
  -o "$1" \
  -g typescript-fetch \
  --additional-properties=disallowAdditionalPropertiesIfNotPresent=false,withInterfaces=false,supportsES6=true,stringEnums=true,npmName=myclient
@wing328
Copy link
Member

wing328 commented Dec 2, 2024

I just did a quick test with linux (ubuntu) and FILES contains .openapi-generator-list. First few lines shown below:

.gitignore
.openapi-generator-ignore
.php-cs-fixer.dist.php
.travis.yml
README.md
composer.json
docs/Api/PetApi.md

@jivanic-demystdata
Copy link
Author

jivanic-demystdata commented Dec 2, 2024

Well, the same command executed locally and in the CI doesn't give the same result

We use a CI step to validate that the committed TS SDK is up-to-date (we commit the generated code)
To validate this in the CI, we delete the generated code, re-generate it and compare the newly generated with the code present in git

The command to compare the re-generated code with the code in git:

if [[ `git status --porcelain generated` ]]; then
  git diff generated | cat
  echo ""
  echo "⚠️ The REST API has changed ⚠️"
  echo "You need to regenerate the TS SDK"
  echo "Please run './scripts/generate_ts_sdk.sh' and commit the changes"
  echo ""
  exit 1
fi

Result:

diff --git a/generated/ts_sdk/.openapi-generator/FILES b/generated/ts_sdk/.openapi-generator/FILES
--
  | index 95d308b..fc35184 100644
  | a/generated/ts_sdk/.openapi-generator/FILES | 0s
  | b/generated/ts_sdk/.openapi-generator/FILES | 1s
  | @@ -1,6 +1,5 @@
  | .gitignore
  | .npmignore
  | -.openapi-generator-ignore
  | README.md
  | package.json
  | src/apis/DefaultApi.ts
  |  
  | ⚠️ The REST API has changed ⚠️
  | You need to regenerate the TS SDK
  | Please run './scripts/generate_ts_sdk.sh' and commit the changes

I had to add this in my script to make it pass:

        # Add a new line with `.openapi-generator-ignore` after the `.npmignore` line in the `.openapi-generator/FILES`
        # because of: https://github.com/OpenAPITools/openapi-generator/issues/20218
        # command comes from: https://www.baeldung.com/linux/insert-line-specific-line-number#using-a-combination-of-head-and-tail
        { head -n 2 .openapi-generator/FILES; echo ".openapi-generator-ignore"; tail -n +3 .openapi-generator/FILES; } > TMP
        mv TMP .openapi-generator/FILES

@wing328
Copy link
Member

wing328 commented Dec 2, 2024

are you able to repeat the same issue in a local linux box?

@NoemieTav
Copy link

We have the same issue. We don't have macOS, and locally, we don't have .openapi-generator-ignore in FILES but in the CI we do.

We use the docker locally and the .jar from maven in the CI.

When using the .jar from maven on my computer, I have .openapi-generator-ignore in FILES.

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

3 participants