ScottLogic / openapi-forge

⚒️🔥 Effortlessly create OpenAPI clients, in a range of languages, from the fiery furnace of our forge
8 stars 7 forks source link

Support absolute paths to generators in the forge command #171

Open ms14981 opened 1 year ago

ms14981 commented 1 year ago

Tried to run the following command (on Git Bash):

openapi-forge forge <schema> C:\dev\open-api-forge\openapi-forge-java-initial

It gives the error:

<path>\openapi-forge\src\common\generatorResolver.js:36
    throw new Error(
          ^

Error: Generator URL C:devopen-api-forgeopenapi-forge-java-initial does not end with ".git", check that the URL points to a valid generator

There are a couple of things to consider here:

gkocak-scottlogic commented 1 year ago

Absolute paths works fine on unix environments.

node src/index.js forge <schema> /home/X/repos/openapi-forge-java-initial/ -o ...

runs without issues.

About the windows side of things, my guess is fs.existsSync on windows native directories in git-bash doesn't get validated correctly maybe. For the git error part, the path is still validated as an URL which triggers that as a git repo automatically to be fetched with git.

ms14981 commented 1 year ago

Testing the schema argument, looks like that doesn't work with absolute paths either:

openapi-forge forge C:/dev/open-api-forge/openapi-forge-java-initial/features/schema.json  https://github.com/ScottLogic/openapi-forge-typescript.git

We get this error (from node-fetch?): "Only absolute URLs are supported"