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
The only existing examples for customizing quicktype are a bit overwhelming, especially if your use case is much simpler. For more simple substitutions, is there a better way?
Currently, my schema input matches this type definition:
typeRawSchema={[key: string]: RawSchema|null;};// for brevity, I've created some aliases:typeSomeType=Cypress.Chainable<JQuery<HTMLElement>>;typeSomeOtherType<T>=(text: string)=>T&Cypress.Chainable<JQuery<HTMLElement>>;
I am running quicktype algorithmically. In the interface output, anywhere the schema had null, I want to replace that with SomeType
For this first part, I could do this, but it feels hacky:
Additionally, when there's a rows.row.x property, I want to modify the output to insert an extra with property, which contains the same keys as rows.row but different types. (Basically, for any x in rows.row.x, I want to output a rows.with.x with type (text: string) => SomeOtherType<SomeRowType >)
The net goal is that both topLevel.apple.banana.rows.row.name and topLevel.apple.banana.rows.with.name('foo').id would both be valid for IntelliSense.
Additionally, since there are multiple keys with row as name, the generated interfaces end up with weird/arbitrary names like PurpleRow and FluffyRow as opposed to something like BananaRow. I'd like to use the parent interface name as a prefix rather than a random string.
The aforementioned customization example shows how to override inheritance and set default properties, but it's a fairly complex example that doesn't even match my use case. Unfortunately, I haven't been able to figure out which functions I need to override to get this behavior. Closest guess I've had thus far is overriding emitPropertyTable or sourceFor, or maybe emitClassBlockBody. That's as far as I've managed, though.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The only existing examples for customizing quicktype are a bit overwhelming, especially if your use case is much simpler. For more simple substitutions, is there a better way?
Currently, my schema input matches this type definition:
I am running quicktype algorithmically. In the interface output, anywhere the schema had
null
, I want to replace that withSomeType
For this first part, I could do this, but it feels hacky:
Additionally, when there's a
rows.row.x
property, I want to modify the output to insert an extrawith
property, which contains the same keys asrows.row
but different types. (Basically, for anyx
inrows.row.x
, I want to output arows.with.x
with type(text: string) => SomeOtherType<SomeRowType >
)For example, I would like this:
to output something along these lines:
The net goal is that both
topLevel.apple.banana.rows.row.name
andtopLevel.apple.banana.rows.with.name('foo').id
would both be valid for IntelliSense.Additionally, since there are multiple keys with
row
as name, the generated interfaces end up with weird/arbitrary names likePurpleRow
andFluffyRow
as opposed to something likeBananaRow
. I'd like to use the parent interface name as a prefix rather than a random string.The aforementioned customization example shows how to override inheritance and set default properties, but it's a fairly complex example that doesn't even match my use case. Unfortunately, I haven't been able to figure out which functions I need to override to get this behavior. Closest guess I've had thus far is overriding
emitPropertyTable
orsourceFor
, or maybeemitClassBlockBody
. That's as far as I've managed, though.Thank you!
Beta Was this translation helpful? Give feedback.
All reactions