swagger-codegen-ts
swagger-codegen-ts copied to clipboard
readOnly writeOnly support
- check how is it implemented in
swagger-codegen
- see how can we implement it leveraging TS type-system (two different types, field modifiers, etc.)
- looks like we're able to track the source of type resolution (body params type, response type), so it's possible to generate different types (ones with writeOnly fields for requests, ones for readOnly fields for responses), need to investigate
@raveclassic, what do you think about this? that will allow us not to break existing types (that don't have readonly or writeonly fields). at the same time we can avoid checking if type has readonly or writeonly fields.
export type TypeBase = {
...not readOnly and not writeOnly types
};
type WriteOnly = {
...writeOnly types
};
type ReadOnly = {
...readonly types
};
export type TypeRead = TypeBase & TypeRead;
export type TypeWrite = TypeBase & TypeWrite;
export type Type = TypeRead | TypeWrite;
removing from milestone as it might require a lot of work when there's a simple and maintainable workaround available - just to split models by hand and use different references across the spec