Closed greinerb closed 2 months ago
@greinerb Thanks for reporting this. I have been reworking the file handling logic to make the the code more compact and easier to maintain and extend. Although there is a large test suite, it seems that something has slipped through.
I ll try to reproduce it and fix it as soon as possible.
Would you mind sharing the command with the parameters that triggered the error? So I can reproduce it.
Here is the command that is executed.
openapi-format $file -o filtered/$file --filterFile filter.json;
$file is the file that was changed in our repo that we are validating the change.
hi @greinerb
I tried to reproduce it but i was unable to do so:
Example:
openapi-format ../openapi.yml --output filtered.yaml --filterFile customFilter.json
output:
Which OS are you using?
can you increase the verbose output? This will output the underlying error.
Example:
openapi-format ../openapi.yml --output filtered.yaml --filterFile customFilter.json --verbose 2
We are using the docker image node:19.5-bullseye, that contains debian:11, 11.6.
Here is the output from the verbose command.
SyntaxError: Unexpected token 's', "stripFlags"... is not valid JSON at JSON.parse (<anonymous>) at Object.parseFile (/usr/local/lib/node_modules/openapi-format/utils/file.js:30:14) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Command.run (/usr/local/lib/node_modules/openapi-format/bin/cli.js:105:33)
The contents of that file is the following.
stripFlags: ['x-internal']
I have tried to remove the single quotes and still the same output. Did the requirements change for stripFlags?
@greinerb The fileFile has a JSON extension?
Does the content looks like this like this JSON structure or YAML
{
"stripFlags": [
"x-internal"
]
}
stripFlags: ['x-internal']
Is is as the 2nd even though the file extension is json. So does it require it to be in json format only if the file extension is json? I am going to run a few different tests with json format and different file extensions.
We load the file content and parse it from json or yaml based on the file extension.
@greinerb Did you get it to work by changing the extension to YAML or convert the content to JSON?
@greinerb Going to close this item, since it should be solved when applying the correct extension.
With the latest version, 1.15.4, using the --filterFile parameter, it produces the following error. "Filter file error - no such file or directory" We have tried it both with the relative path and an absolute path to the file within our CI pipeline with the same results. The contents of our file (named filter.json) is the following and have verified that it exists and has the output below. stripFlags: ['x-internal'] We altered our CI pipeline to install the prior version (and not pull the latest) and that solves it currently. `npm install -g openapi-format@1.15.3