Skip to content
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

readOnly writeOnly support #16

Open
scink opened this issue Jan 10, 2019 · 3 comments
Open

readOnly writeOnly support #16

scink opened this issue Jan 10, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@scink
Copy link
Contributor

scink commented Jan 10, 2019

No description provided.

@scink scink added the enhancement New feature or request label Jan 10, 2019
@raveclassic
Copy link
Contributor

raveclassic commented Jan 10, 2019

  • 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

@scink
Copy link
Contributor Author

scink commented Jan 11, 2019

@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;

@raveclassic raveclassic added this to the 2.0 milestone Oct 22, 2019
@raveclassic
Copy link
Contributor

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

@raveclassic raveclassic removed this from the 2.0 milestone Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants