JSON schema keywords getting lost
- Dominant language
- TypeScript
- Stars
- 447
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
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:
```javascript
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:
```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:
```yaml
testType:
properties:
name:
type: string
minLength: 5
maxLength: 10
creationDate:
type: string
format: date-time
required:
- name
- creationDate
type: object
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.