Closed smeijer closed 6 months ago
Library version: 1.7.2
JSON schema version: draft-04, draft-06, draft-07, 2019-09, 2020-12
Throws when a property contains a hyphen:
import { schema2typebox } from "schema2typebox"; const schema = JSON.stringify({ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "car-brand": { // < troubling "type": "string" } } }); await schema2typebox({ input: schema });
It's prettier that throws when formatting. This lib should just quote the property name, so it's:
Type.Object({ 'car-brand': Type.String(), })
This lib generates invalid code by naming writing something like { car-brand: Type.String() }, which prettier rightfully throws upon.
{ car-brand: Type.String() }
Library version: 1.7.2
JSON schema version: draft-04, draft-06, draft-07, 2019-09, 2020-12
The current behavior
Throws when a property contains a hyphen:
The expected behavior
It's prettier that throws when formatting. This lib should just quote the property name, so it's:
Why does it happen? What/How to fix the issue?
This lib generates invalid code by naming writing something like
{ car-brand: Type.String() }
, which prettier rightfully throws upon.Content of minimal json schema file which causes the problem
Click to expand/collapse
```json { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "car-brand": { "type": "string" } } } ```