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

This project could really use a CLI (feature request) #51

Closed
rafalkrupinski opened this issue Mar 22, 2023 · 2 comments
Closed

This project could really use a CLI (feature request) #51

rafalkrupinski opened this issue Mar 22, 2023 · 2 comments

Comments

@rafalkrupinski
Copy link

No description provided.

@kernwig
Copy link

kernwig commented Jun 1, 2023

Dropping this here for anyone who may find it useful. Minimally tested - I didn't end up using it.

'use strict';

const sourcePath = process.argv[2];
const targetPath = process.argv[3];
if (!sourcePath || !targetPath) {
  console.log("Usage:", process.argv[0], process.argv[1], "<openapi.json-input-file> <schema.json-output-path>")
}

const { openapiSchemaToJsonSchema: toJsonSchema } = require("@openapi-contrib/openapi-schema-to-json-schema");
const fs = require("node:fs");

const sourceContent = fs.readFileSync(sourcePath).toString();
console.log("sourceContent", sourceContent);
const schema = JSON.parse(sourceContent);
const convertedSchema = toJsonSchema(schema.components.schemas[0]);

fs.writeFileSync(targetPath, JSON.stringify(convertedSchema));

jonluca added a commit that referenced this issue Jul 11, 2023
…cli (#68)

* BREAKING CHANGE: #51 Bump versions, change build to only be cjs, add cli

* remove present

* add readme
@jonluca
Copy link
Member

jonluca commented Jul 11, 2023

Added one with npx "@openapi-contrib/openapi-schema-to-json-schema" --input openapi.json --output json-schema.json

@jonluca jonluca closed this as completed Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants