The code generator should handle json schema.
The way is to implement JSON Shema Parser.
Hello! Any updates now?
Thank you for your comment.
Sorry, I'm developing my other projects now. [[local-data-api](https://github.com/koxudaxi/local-data-api), [py-data-api](https://github.com/koxudaxi/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.
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.
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 :)
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馃槉
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 :)
Sry me, i was very busy in this week. I plan start work about it tomorrow.
I implemented the feature.
And I have released the version as 0.3.0
https://github.com/koxudaxi/datamodel-code-generator/pull/89
Most helpful comment
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 :)