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

Schema export consistency #335

Open
Makeshift opened this issue Nov 27, 2019 · 5 comments
Open

Schema export consistency #335

Makeshift opened this issue Nov 27, 2019 · 5 comments

Comments

@Makeshift
Copy link

Before I open a pull request for this, I was curious if there was a design reason for it.

I've noticed that the schema that is exported with getSchema and getSchemaString are not the same as the schema that was originally supplied to Convict. In particular, two transformations happen:

  1. The format name is made lowercase
  2. The JSON object is flattened (I assume to make a.b.c work without having to deal with walking through a nested object)

In my fork I've commented out the line that makes the format name lowercase, and introduced an unflattening function that is applied to getSchema and getSchemaString to obtain an output consistent with the schema you put in. I also output properties instead.

I was just wondering if there was a reason behind these design decisions before I opened a pull request to change them (although that would require a major version bump).

@A-312
Copy link
Contributor

A-312 commented Jan 6, 2020

In e3e5171 (#353), I removed the .toLowerCase() to have the same consistent.

@Makeshift unflatten does the same thing of coerce function, is not it ?

@xamgore
Copy link
Contributor

xamgore commented Apr 20, 2020

@A-312 did you hear about json-schema drafts? If there will be a way to generate schemas in that format, some can utilize json-schema-to-typescript package and get typescript definitions for free!

@A-312
Copy link
Contributor

A-312 commented Apr 20, 2020

The last week, I take 4-5 hours to work on that to thintk if should implement json-schema or not. I choose to:

@A-312
Copy link
Contributor

A-312 commented Apr 20, 2020

@Makeshift I saw in netwok, you always pushed the same commit

image

It seems to me:

Your commit State v6
New: Force coercion even for things that aren't strings Implemented
Consistent schema exporting Improved
Stopped format name from being made lowercase Done

@Makeshift
Copy link
Author

If that's the case, I'll take a look when I have a moment and close the issue if solved. Thanks!

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

3 participants