Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for constant values #263

Closed
nicojs opened this issue Oct 21, 2019 · 2 comments
Closed

Support for constant values #263

nicojs opened this issue Oct 21, 2019 · 2 comments

Comments

@nicojs
Copy link
Contributor

nicojs commented Oct 21, 2019

Support const values (new in v6). https://json-schema.org/understanding-json-schema/reference/generic.html#constant-values

Input

{
  "$id": "https://api.nn-group.com/t/nn-nl/2/json_schemas/forwardcache_notify_participation",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Foo",
  "required": ["bar"],
  "additionalProperties": false,
  "properties": {
    "bar": {
      "const": true
    }
  }
}

Expected output:

export interface Foo {
  bar: true;
}

Current output:

export interface Foo {
  bar: {
    [k: string]: any;
  };
}

This feature was mentioned in #120 but as the scope of that is a bit too big for beginning contributors I thought I would split this feature out.

Any hints for json-schema-to-typescript newbies would be much appreciated.

@djbeaumont
Copy link

I've been hoping someone would give this a try for about a year now and I've finally had a chance to give this a go in the PR above #264

@bcherny
Copy link
Owner

bcherny commented Jan 4, 2021

Fixed in #290, published in v10.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants