@kubb/plugin-faker / @kubb/plugin-ts — generate types and factories for inline object schemas, not only named $ref components #2592
vitorcamachoo
started this conversation in
Ideas
Replies: 1 comment
-
|
@vitorcamachoo We have types like this: https://github.com/kubb-labs/kubb/blob/main/examples/advanced/src/gen/models/ts/petController/FindPetsByStatus.ts. Not sure if this is what you are asking for as this should normally be generated by Kubb |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently @kubb/plugin-ts and @kubb/plugin-faker only generate TypeScript types and factory functions for schemas defined as named components ($ref: '#/components/schemas/...'). Inline object schemas defined directly in request/response bodies are skipped entirely — no type is generated and no factory is generated.
Example spec:
Current behaviour:
No TypeScript type is generated for the inline available_actions object — it resolves to { edit?: boolean; delete?: boolean } inlined into the parent type with no named export.
No factory is generated for the response schema or its nested available_actions object.
Tests must maintain manual types and factories that duplicate the shape from the spec and won't automatically reflect future API changes.
Expected behaviour:
Kubb should derive a name from the operation context and generate both a named TypeScript type and a factory for each inline object schema, e.g.:
Having both the type and the factory keeps test mocks type-safe and automatically in sync with spec changes.
Orval implements this behaviour as a reference.
Beta Was this translation helpful? Give feedback.
All reactions