-
-
Notifications
You must be signed in to change notification settings - Fork 464
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
Support patternProperties
in components.schemas
#754
Comments
Interesting. What would be the desired TypeScript generated types for this? |
Having an interface that allows fields with arbitrary keys but specifies types would be extremely helpful. For example, we have the following schema: MobilityData/gbfs-json-schema/gbfs.json. interface GbfsV2_3 {
//...
data: { [key: string]: unknown };
}; Instead of unknown we could have the following: interface GbfsV2_3 {
//...
data: {
[key: string]: {
//...
feeds?: {
//...
};
};
};
}; This will allow us extract the type of the type DataType = GbfsV2_3['data'];
type DataFieldType = DataType[keyof DataType]; If there are multiple patterns in the schema, |
Any update on this? Without this spec, it is not truly 3.1 compatible. |
I’d love to support patternProperties, but I’m not sure this would work as intended in static TypeScript types. Mixing static object keys with generic signatures like I’m not saying it’s necessarily impossible; I’m just saying I’d love a PoC that shows how this could be handled in TS and would welcome PRs adding this! |
This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed. |
This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem. |
Related: microsoft/TypeScript#41160 @drwpow I might take a stab at this. My idea is to completely ignore regexes and simply take the union type of all |
I have a
component.schema
of the following form:Of particular importance is the fact that I am utilizing
patternProperties
. This is a valid usage according to the following issue:Anyone know if this is something that would be expected to work right now? If not, any ideas on what it would take to support this?
The text was updated successfully, but these errors were encountered: