Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

1.0.0

Compare
Choose a tag to compare
@postatum postatum released this 23 Sep 09:29
· 45 commits to master since this release

This release improves ramldt2jsonschema by adding several new features, and by addressing a number of issues. This became possible, in great part, thanks to switching to the new official RAML parser: webapi-parser.

Changes

  • The dt2js and js2dt functions are now both asynchronous (using async/await);
  • The setBasePath() function was removed in favor of the basePath argument. See this section of the README for more details;
  • Each converters' list of limitations has also changed. See this other section of the README for an up-to-date list;
  • A new --draft option was added to dt2js CLI. It allows specifying the output JSON Schema draft version. Supported values are: 04, 06 and 07 (default).

Note that the output of both dt2js and js2dt has changed (more details below).

Old vs new dt2js output comparison

- old
+ new

Structural differences

- draft-06 schema
+ draft-07 schema (or 04, 06)

- super-flat json, bubbling `anyOf` from unions to the very top of the schema
+ transforms unions using `anyOf` and keeps it at the original depth/place

- schema defined in the root of json document
+ defines schema in `definitions` and uses `$ref`

Low-level differences

- all types of dates converted to string with long patterns
+ all types of dates converted to string with "format"

- number with "format: int32" not changed
+ number with "format: int32" converted to type: integer

- object property's "facets" converted
+ object property's "facets" not converted

- converted union of arrays incorrectly
+ converts union of arrays correctly
(see Cat.properties.proscons)

- converted example "displayName" to "title"
+ keeps the "displayName" property

- pattern regex kept as is
+ pattern regex wrapped in `^...$`

Old vs new js2dt comparison

- old
+ new

Structural differences

None.

Low-level differences

- did not convert properties: minProperties, maxProperties, discriminator, items, uniqueItems, maxItems, minItems, enum, format (in numbers), xml, default, example, multipleOf
+ does convert mentioned properties

- optional properties were marked with a trailing "?"
+ optional properties are marked with "required: false"

- used types' names to specify property type
+ always uses "type:" keyword and inline type declaration

- converted dates with a "pattern" property to specific RAML dates types (e.g. datetime-only)
+ converts dates to strings with "pattern" property

- converted string with "media" to "type: file"
+ converts it incorrectly (stays a string)