You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a test case covering this. But for the life of me I don't remember where in the spec I saw that this is the correct behavior.
Reading it now, the JSON-Schema Spec is a bit ambiguous: a schema that omits properties is equivalent to TypeScript's any (in that, every value is valid), but it's unclear whether properties: {} is also equivalent to any, or if it should be strictly interpreted as "nothing matches".
Would love a second pair of eyes, if you can help sleuth through the various versions of the JSON-Schema Spec to dig up the correct behavior.
I suppose that a schema that omits properties is equivalent to TypeScript's any only if additionalProperties in schema resolved to true. Of course this is a very rare case. Here is the case: I have ajv validator in my json-rpc server pipeline. And it fails to validate request with any properties in args against the schema in my first message. But ts interface produced from this schema allows any properties. It's a bit inconsistent...
UPD: Also this should be consistent with another prop: unevaluatedProperties
Anyway, I've just fixed "the issue" in my code generation pipeline with dirty string replacement: export interface Params {} -> export type Params = Record<string,never>
Maybe we just should add some option to the converter? Something like exposeEmptySchemaObjectWithNoAdditionalPropertiesAllowedAs?
For now schema
will be converted to
This leads to any props allowed in autocomplete:
Also, if API uses validation based on JSON schema it expects params to be strictly empty object.
I believe it's better to convert to:
The text was updated successfully, but these errors were encountered: