Schema export consistency
Makeshift opened this issue · 5 comments
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:
- The format name is made lowercase
- 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).
In e3e5171 (#353), I removed the .toLowerCase()
to have the same consistent.
@Makeshift unflatten
does the same thing of coerce function, is not it ?
@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!
The last week, I take 4-5 hours to work on that to thintk if should implement json-schema or not. I choose to:
- Adapt type/format of json-schema (with property, min, max, length...), this will be compatible (convict 6) ;
- I will not add all their features because I found some of their choice not to good and a little be complicated ;
- I will add some support for dynamic properties/keynames support, to make a better support for: https://blueconfig.js.org/tutorial-custom-formats-children.html & https://blueconfig.js.org/tutorial-custom-formats-object-arr.html
@Makeshift I saw in netwok, you always pushed the same commit
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 |
If that's the case, I'll take a look when I have a moment and close the issue if solved. Thanks!