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

Add JSON Schema Parser #28

Closed
koxudaxi opened this issue Jul 30, 2019 · 8 comments
Closed

Add JSON Schema Parser #28

koxudaxi opened this issue Jul 30, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@koxudaxi
Copy link
Owner

The code generator should handle json schema.
The way is to implement JSON Shema Parser.

@koxudaxi koxudaxi added the enhancement New feature or request label Jul 30, 2019
@prostomarkeloff
Copy link

Hello! Any updates now?

@koxudaxi
Copy link
Owner Author

koxudaxi commented Oct 7, 2019

Thank you for your comment.

Sorry, I'm developing my other projects now. [local-data-api, py-data-api]

However, This project is active. I'm going to develop the project this week again.
Also, I'm waiting to publish pydantic version 1 to use Field().

If you want to support JSON schema then, I change a priority of this issue to high.

@koxudaxi koxudaxi changed the title Add JSON Shema Parser Add JSON Schema Parser Oct 7, 2019
@prostomarkeloff
Copy link

Thanks for answer! I`m interesting in this project, i found it when search an any information about json schema parsers and code generators for pydantic. I will try to learn codebase and work about json schema parser.

@koxudaxi
Copy link
Owner Author

koxudaxi commented Oct 7, 2019

I guess the work may not hard, because of Json Schema, similar to OpenAPI.
I'm worried that this code is complex... I refactored the code. I feel the code is better than before refactoring :)

@prostomarkeloff
Copy link

Firstly, i think about $ref fields, without it, it is easy. I checked readme and saw information what $ref supported only in 1 file, we should to "fix" that😊

@joshbode
Copy link
Contributor

joshbode commented Oct 9, 2019

I'm using https://github.com/wework/json-schema-to-openapi-schema and I haven't had any issues yet, though I'm probably not using all the features of JSON Schema. I use this script to run it from the command line:

#! /usr/bin/env node

const fs = require('fs');
const minimist = require('minimist');
const path = require('path');
const toOpenApi = require('json-schema-to-openapi-schema');
const yaml = require('js-yaml');


function main(args) {
  var argv = minimist(args);

  try {
    var json_schema = JSON.parse(fs.readFileSync(path.resolve(argv.input)));
  }
  catch (e) {
    console.log(e);
    return 1;
  }
  console.log(`JSON Schema read from ${argv.input}`);

  const openapi = toOpenApi(json_schema);

  try {
    fs.writeFileSync(path.resolve(argv.output), yaml.dump(openapi));
  }
  catch (e) {
    console.log(e);
    return 1;
  }
  console.log(`OpenAPI written to ${argv.output}`);
  return 0;
}

process.exit(main(process.argv.slice(2)));

usage:

$ json-schema-to-openapi --input schema.json --output openapi.yaml

I haven't gotten around to submitting it yet :)

@prostomarkeloff
Copy link

Sry me, i was very busy in this week. I plan start work about it tomorrow.

@koxudaxi
Copy link
Owner Author

I implemented the feature.
And I have released the version as 0.3.0
#89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants