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

Enhancement: Include a command-line version to use json-schema-ref-parser via CLI #65

Closed
shreyas-agnihotri opened this issue Jan 5, 2018 · 9 comments

Comments

@shreyas-agnihotri
Copy link

shreyas-agnihotri commented Jan 5, 2018

Include a command-line version with the npm package so that json-schema-ref-parser can be simply used via CLI. This will make it easier to use this tool via CICD/build systems and also eliminate the need for writing a wrapper js script to consume this functionality.

Something like:

json-schema-ref-parser bundle --dereference {infile} {outfile}
@RazzM13
Copy link

RazzM13 commented Feb 28, 2018

Apparently, albeit a bit buggy with YAML, there is already a CLI version that can dereference and utilizes json-schema-ref-parser under the hood: json-dereference-cli.

However, as the name implies, it's functionality is limited to just dereferencing, it would be nice if it also had support for bundle as well as perhaps provide a list of all external references (i.e. $Refs.paths).

@JamesMessinger
Copy link
Member

JamesMessinger commented Feb 28, 2018

Yeah, I do have plans to create a CLI for this project eventually. I currently have a CLI that uses this project under the hood to do bundling, but it's tailored for Swagger, rather than any JSON Schema document

@RazzM13
Copy link

RazzM13 commented Mar 1, 2018

Thank you very much for providing us with swagger-cli. In terms of features, it is precisely what I need and I was already using it for dereferencing a swagger definition prior to having the need to inline the aforementioned into an AWS SAM file however, swagger-cli performs validation prior to deferencing and, I haven't seen an option of skipping that validation, therefore cannot be used to deference anything other than Swagger files.

@JamesMessinger
Copy link
Member

Yeah, Swagger-CLI will throw an error for anything other than Swagger 2.0 files. So I definitely need to create a more generic JSON Schema CLI that isn't specific to Swagger files.

@RazzM13
Copy link

RazzM13 commented Mar 1, 2018

Despite my limited experience with NodeJS, I would love to give you a hand with that, that is if you're willing and can provide some insight into how you'd envision it done; perhaps similar to swagger-cli without support for validation or with support for validation via JSON-Schema (e.g. ajv) and I believe it might be useful to provide a list of all external references (i.e. $Refs.paths).

@DanielHabenicht
Copy link

DanielHabenicht commented Oct 1, 2020

Although not using json-schema-ref-parser @redocly/openapi-cli just does what you wanted.

@philsturgeon
Copy link
Member

Between swagger-cli and openapi-cli most people should have a solution for their needs.

@dtheodor
Copy link

Both swagger-cli and opeapi-cli are swagger specific

@philsturgeon
Copy link
Member

@dtheodor despite the name so is this tool. It's not actually conforming to the JSON Schema $ref usage, its "JSON Schema as in OpenAPI Schema" so might as well have OpenAPI in the name.

If you'd like to contribute a CLI it would not be a huge amount of work, but in general new functionality is not being worked on so you'd need to code that up, or wrap this up in your own CLI code locally, or use something else.

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

6 participants