Open Schereo opened 3 years ago
I'm trying to convert JSON schema to Open Api. During the conversion keywords like minLenght, maxLength and format are getting lost and are not present in my final Open Api conversion. Here is my testcode:
minLenght
maxLength
format
const test = { "type": "object", "properties": { "name": { "minLength": 5, "maxLength": 10, "type": "string" }, "creationDate": { "format": "date-time", "type": "string" } }, "required": ["name", "creationDate"] } const schemas = { "definitions": { "testType": test } }; const converter = async () => { const reader = getJsonSchemaReader(); const writer = getOpenApiWriter({ format: 'yaml', title: 'Testconverter', version: 'v1', schemaVersion: '3.0.0' }); const { convert } = makeConverter(reader, writer); await convert({ 'data': JSON.stringify(schemas) }, { filename: 'test.yaml' }) } converter()
which produces this open api yaml:
openapi: 3.0.0 info: title: Testconverter version: v1 paths: {} $id: test.yaml $comment: >- Generated by core-types-json-schema (https://github.com/grantila/core-types-json-schema) on behalf of typeconv (https://github.com/grantila/typeconv) components: schemas: testType: properties: name: type: string creationDate: type: string required: - name - creationDate type: object
which is missing the previous mentioned keyword. The correct (shortend) schme should look like this:
testType: properties: name: type: string minLength: 5 maxLength: 10 creationDate: type: string format: date-time required: - name - creationDate type: object
I'm trying to convert JSON schema to Open Api. During the conversion keywords like
minLenght
,maxLength
andformat
are getting lost and are not present in my final Open Api conversion. Here is my testcode:which produces this open api yaml:
which is missing the previous mentioned keyword. The correct (shortend) schme should look like this: