-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
I have a Schema Object
{
"Obj": {
"description": "Obj",
"required": [
"id",
"foo"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[0-9a-f]{32}$"
},
"foo": {
"type": "string",
"pattern": "^[0-9a-f]{32}$"
},
"bar": {
"type": "string",
"pattern": "^[0-9a-f]{32}$"
}
}
}
}
With this ShemaObject, a type generates perfectly fine.
/**
* Obj
*/
export type Obj = {
/**
* @pattern ^[0-9a-f]{32}$
*/
id: string;
/**
* @pattern ^[0-9a-f]{32}$
*/
foo: string;
/**
* @pattern ^[0-9a-f]{32}$
*/
bar?: string;
};
But if I move/distribute required to properties like this
{
"Obj": {
"description": "Obj",
"properties": {
"id": {
"type": "string",
"pattern": "^[0-9a-f]{32}$",
"required": true
},
"foo": {
"type": "string",
"pattern": "^[0-9a-f]{32}$",
"required": true
},
"bar": {
"type": "string",
"pattern": "^[0-9a-f]{32}$"
}
}
}
}
It generates this:
/**
* Obj
*/
export type Obj = {
/**
* @pattern ^[0-9a-f]{32}$
*/
id?: string;
/**
* @pattern ^[0-9a-f]{32}$
*/
foo?: string;
/**
* @pattern ^[0-9a-f]{32}$
*/
bar?: string;
};
Conclusion:
It ignores this approach of requiring fields if the required is set at the property level. Is it a bug? Is it possible to set up this approach?
Metadata
Metadata
Assignees
Labels
No labels