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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JSON Schema 2019-09 deprecated value #156

Open
2 tasks done
DamienGarrido opened this issue Dec 3, 2021 · 4 comments
Open
2 tasks done

Support JSON Schema 2019-09 deprecated value #156

DamienGarrido opened this issue Dec 3, 2021 · 4 comments

Comments

@DamienGarrido
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

馃殌 Feature Proposal

Add support to deprecated values as stated in the JSON Schema 2019-09 paragraph.

Motivation

Be able to deprecate properties without raw().

Example

S.object().prop('myDeprecatedProperty', S.string()).deprecated();

Current workaround:

S.object().prop('myDeprecatedProperty', S.string()).raw({ deprecated: true });
@Eomm
Copy link
Member

Eomm commented Dec 3, 2021

Would you like to send a Pull Request to address this feature? Remember to add unit tests.

@aboutlo
Copy link
Collaborator

aboutlo commented Dec 3, 2021

the actual syntax: S.object().prop('myDeprecatedProperty', S.string().deprecated());

@victortosts
Copy link
Contributor

I tried to address it on #161 but I'm not sure about handling this property inheritance.

Should array properties with a single schema item inherit 'deprecated' property?

Which one should resolve?

expect(
    S.object()
      .prop('foo', S.string())
      .prop('bar', S
        .array()
        .items(S.number().deprecated())
      )
      .valueOf()
  ).toEqual({
    $schema: 'http://json-schema.org/draft-07/schema#',
    type: 'object',
    properties: {
      foo: { type: 'string' },
      bar: {
        type: 'array',
        deprecated: true,
        items: { type: 'number' }
      }
    },
  })

expect(
    S.object()
      .prop('foo', S.string())
      .prop('bar', S
        .array()
        .items(S.number().deprecated())
      )
      .valueOf()
  ).toEqual({
    $schema: 'http://json-schema.org/draft-07/schema#',
    type: 'object',
    properties: {
      foo: { type: 'string' },
      bar: {
        type: 'array',
        items: { type: 'number', deprecated: true, }
      }
    },
  })

Is the same valid for single property objects?
Any ideas on this?

@Eomm
Copy link
Member

Eomm commented Jan 14, 2022

Is the same valid for single property objects?

I think the latter is right and the former is not: items may contain an array and you may want to deprecate just one type.

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

No branches or pull requests

4 participants