how to force a field to be a specific type?
See original GitHub issueI am trying to do something like:
/**
* How to force a Widget to be encoded as number?
*
* @type number
*/
export interface Widget {}
export interface House {
name: string;
mainWidget: Widget;
otherWidgets: Widget[];
}
So that the mainWidget
field is encoded as a regular “number”, and also otherWidgets
will be an array of numbers.
In other words I would like to get the following schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"name": {
"type": "string"
},
"mainWidget": {
"type": "number"
},
"otherWidgets": {
"items": {
"type": "number"
},
"type": "array"
}
},
"required": [
"name",
"mainWidget",
"otherWidgets"
],
"type": "object"
}
thank you
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Force a field to be an object type - Stack Overflow
I'm using datatypes to filter numeric vs categorical - all fields are numeric. I'll be dropping and adding columns pretty often so a...
Read more >Solved: Forcing a field type - Designer - Alteryx Community
Solved: Hi, Is it possible to force a field type for a particular column in an excel input file? I have a use...
Read more >Forcing specific formatting in an input field
Solved: I have an input field that needs to take a costing string, depending on an earlier quesion the format will either be...
Read more >How to force Input field to enter numbers only using JavaScript
Now forcing input field type=”text” to accept numeric values only by using Javascript or jQuery. You can also set type=”tel” attribute in the ......
Read more >Change the Custom Field Type - Salesforce Help
From the management settings for the field's object go to Fields.For fields on Salesforce Knowledge article types from Setup enter Knowledge Article Types...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The issue is that we try to infer types and defintions and overriding properties can have weird effects. I added some code so it works for types but I’m not convinced that it’s a good idea in general to let users override properties.
I’m not familiar with typescript-json-schema source code, but maybe in a few days I’ll have time to try to figure this out