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] - Generation Error in V.2.10.0 #758

Closed
kemotx90 opened this issue Mar 4, 2024 · 15 comments · May be fixed by #759
Closed

[BUG] - Generation Error in V.2.10.0 #758

kemotx90 opened this issue Mar 4, 2024 · 15 comments · May be fixed by #759
Assignees
Labels
bug Something isn't working

Comments

@kemotx90
Copy link

kemotx90 commented Mar 4, 2024

🐛 Bug Report:

The generation of file from this configuration has broken in V2.10.0 (but worked fine in V.2.9.0 or previous)

{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "7.2.0",
    "generators": {
      "my-application": {
        "generatorName": "typescript-angular",
        "output": "generated-sources/openapi",
        "inputSpec": "http://localhost:8080/***.yaml",
        "auth": "Authorization:*****",
        "typeMappings": {
          "DateTime": "Date"
        },
        "additionalProperties": {
          "supportsES6": true,
          "withInterfaces": true
        }
      }
    }
  }
}

When run from CLI

openapi-generator-cli generate --generator-key my-application

get this error

[[my-application] http://localhost:8080/***.yaml] La sintassi del nome del file, della directory o del volume non � corretta.
[[my-application] http://localhost:8080/***.yaml] C:\...\jdk-11.0.18/bin/java" -jar "D:\...\node_modules\@openapitools\openapi-generator-cli\versions\7.2.0.jar" generate --input-spec="ht
tp://localhost:8080/***.yaml" --generator-name="typescript-angular" --output="generated-sources/openapi" --auth="Authorization:***" --type-mappings="DateTime=Date" --additional-properties="
supportsES6=true,withInterfaces=true exited with code 1
[brd] http://localhost:8080/***.yaml
  C:\***\jdk-11.0.18/bin/java" -jar "D:\***\node_modules\@openapitools\openapi-generator-cli\versions\7.2.0.jar" generate --input-spec="http://localhost:8080/***.yaml" --gener
ator-name="typescript-angular" --output="generated-sources/openapi" --auth="***" --type-mappings="DateTime=Date" --additional-properties="supportsES6=true,withInterfaces=true

Code generation failed

Process finished with exit code 1

If i'm rollback to 2.9.0 all work fine

@kemotx90 kemotx90 added the bug Something isn't working label Mar 4, 2024
@hassmal
Copy link

hassmal commented Mar 5, 2024

Same problem here

@jase88
Copy link

jase88 commented Mar 5, 2024

Seems to be Windows specific?

@hassmal
Copy link

hassmal commented Mar 5, 2024

Seems to be Windows specific?

maybe, I'm also on windows

@kemotx90
Copy link
Author

kemotx90 commented Mar 5, 2024

I'm on windows too

@zakupower
Copy link

Same issue on Windows

@wing328
Copy link
Member

wing328 commented Mar 5, 2024

thanks for reporting the issue.

@mok-liee can you please take a look when you've time?

related PR: #756

@wing328
Copy link
Member

wing328 commented Mar 5, 2024

As a workaround, please rollback to 2.9.0 for the time being.

mok-liee added a commit to mok-liee/openapi-generator-cli that referenced this issue Mar 5, 2024
@mok-liee
Copy link
Contributor

mok-liee commented Mar 5, 2024

i can understand the problem but unfortunately i can't reproduce it in my windows environment.
but i think that using path.join should solve the problem. sorry for that

@mok-liee
Copy link
Contributor

mok-liee commented Mar 5, 2024

@kemotx90 can u give me please more information about your environment?
version of windows, node, npm/yarn, java and the output of echo %JAVA_HOME% would be helpful.

here is an output of mine with v2.10.0 with cmd. almost the same result with git-bash.

Microsoft Windows [Version 10.0.22631.3235]
(c) Microsoft Corporation. Alle Rechte vorbehalten.

C:\***\oa-demo>echo %JAVA_HOME%
C:\Program Files\Eclipse Adoptium\jdk-17.0.10.7-hotspot\

C:\***\oa-demo>node -v
v18.17.0

C:\***\oa-demo>npm -v
9.6.7

C:\***\oa-demo>npm init -y
Wrote to C:\***\oa-demo\package.json:

{
  "name": "oa-demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

C:\***\oa-demo>npm install @openapitools/openapi-generator-cli

added 112 packages, and audited 113 packages in 17s

23 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
// package.json
...
  "dependencies": {
    "@openapitools/openapi-generator-cli": "^2.10.0"
  }
...
C:\***\oa-demo>.\node_modules\.bin\openapi-generator-cli generate -g ruby -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o .\out\ruby
Download 7.3.0 ...                                                                                                          
Downloaded 7.3.0
Did set selected version to 7.3.0
[main] INFO  o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO  o.o.c.ignore.CodegenIgnoreProcessor - Output directory (C:\***\oa-demo\.\out\ruby) does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.
[main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: ruby (client)
[main] INFO  o.o.codegen.DefaultGenerator - Generator 'ruby' is considered stable.
[main] INFO  o.o.c.languages.AbstractRubyCodegen - Hint: Environment variable 'RUBY_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export RUBY_POST_PROCESS_FILE="/usr/local/bin/rubocop -a"' (Linux/Mac)
[main] INFO  o.o.codegen.InlineModelResolver - Inline schema created as updatePetWithForm_request. To have complete control of the model name, set the `title` field or use the modelNameMapping option (e.g. --model-name-mappings updatePetWithForm_request=NewModel,ModelA=NewModelA in CLI) or inlineSchemaNameMapping option (--inline-schema-name-mappings updatePetWithForm_request=NewModel,ModelA=NewModelA in CLI).
[main] INFO  o.o.codegen.InlineModelResolver - Inline schema created as uploadFile_request. To have complete control of the model name, set the `title` field or use the modelNameMapping option (e.g. --model-name-mappings uploadFile_request=NewModel,ModelA=NewModelA in CLI) or inlineSchemaNameMapping option (--inline-schema-name-mappings uploadFile_request=NewModel,ModelA=NewModelA in CLI).
[main] INFO  o.o.codegen.DefaultGenerator - Model updatePetWithForm_request not generated since it's marked as unused (due to form parameters) and `skipFormModel` (global property) set to true (default)
[main] INFO  o.o.codegen.DefaultGenerator - Model uploadFile_request not generated since it's marked as unused (due to form parameters) and `skipFormModel` (global property) set to true (default)
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\models\api_response.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\models\api_response_spec.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\docs\ApiResponse.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\models\category.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\models\category_spec.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\docs\Category.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\models\order.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\models\order_spec.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\docs\Order.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\models\pet.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\models\pet_spec.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\docs\Pet.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\models\tag.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\models\tag_spec.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\docs\Tag.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\models\user.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\models\user_spec.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\docs\User.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\api\pet_api.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\api\pet_api_spec.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\docs\PetApi.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\api\store_api.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\api\store_api_spec.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\docs\StoreApi.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\api\user_api.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\api\user_api_spec.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\docs\UserApi.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\api_error.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\version.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\README.md
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\git_push.sh
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\.gitignore
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\Rakefile
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\Gemfile
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\.rubocop.yml
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\.travis.yml
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\.gitlab-ci.yml
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\openapi_client.gemspec
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\configuration.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\lib\openapi_client\api_client.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\.rspec
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\spec\spec_helper.rb
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\.openapi-generator-ignore
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\.openapi-generator\VERSION
[main] INFO  o.o.codegen.TemplateManager - writing file C:\***\oa-demo\.\out\ruby\.openapi-generator\FILES
################################################################################
# Thanks for using OpenAPI Generator.                                          #
# Please consider donation to help us maintain this project ?                 #
# https://opencollective.com/openapi_generator/donate                          #
################################################################################

@mok-liee
Copy link
Contributor

mok-liee commented Mar 5, 2024

okay, i can reproduce it now. it seems to behave differently if you start the generation via the openapitools.json. i'll take a look at it.

@mok-liee
Copy link
Contributor

mok-liee commented Mar 5, 2024

to pinpoint it a little bit, i think that concurrently doesn't like how the command is passed

@mok-liee
Copy link
Contributor

mok-liee commented Mar 6, 2024

@wing328 I think without a windows build workflow it is difficult to determine whether it runs under windows.
except for one test, i have been able to recreate the build plan for windows.

branch:
https://github.com/mok-liee/openapi-generator-cli/tree/feature/add-windows-to-build
compare:
mok-liee/openapi-generator-cli@patch-2...mok-liee:openapi-generator-cli:feature/add-windows-to-build

also i have added a generate test with JAVA_HOME (it was the default) and now without.

i need an understanding of the following test:
npm run oa:generate && mkdir ./foo && cd ./foo && npm run oa:generate

the last npm run oa:generate, is it correct that the generate command must find the openapitools.json in the parent folder?
if this is the case, i unfortunately cannot find where this logic is located. can you help me?

here you can see (i hope) my last build https://github.com/mok-liee/openapi-generator-cli/actions/runs/8164577233/job/22320124191

windows does not seem to look in the parent folder.

i think this could be the last step to get this thing running.

@mok-liee
Copy link
Contributor

mok-liee commented Mar 6, 2024

i think i have it

public readonly cwd = process.env.PWD || process.env.INIT_CWD || process.cwd()

process.env.PWD returns on Unix the parent directory and under Windows nothing
process.env.INIT_CWD returns on both the foo directory
process.cwd() returns on both the parent directory

fix is in 15ac43e but because it is not enough there is another problem
https://github.com/mok-liee/openapi-generator-cli/actions/runs/8165673935/job/22323245537
i will continue the days

@wing328
Copy link
Member

wing328 commented Mar 6, 2024

thanks @mok-liee I'll revert the change for the time being.

@wing328
Copy link
Member

wing328 commented Mar 6, 2024

reverted, please install the latest release: https://github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.11.0

@wing328 wing328 closed this as completed Mar 6, 2024
mok-liee added a commit to mok-liee/openapi-generator-cli that referenced this issue Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants