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

add headers as properties to our DPG models #1991

Open
iscai-msft opened this issue Jun 29, 2023 · 2 comments
Open

add headers as properties to our DPG models #1991

iscai-msft opened this issue Jun 29, 2023 · 2 comments
Labels
models need-design needs coding design p1

Comments

@iscai-msft
Copy link
Contributor

Right now, a DPG response model only represents a response body. If TypeSpec defines a response model as including response headers as well (think BlobProperties in storage), we want to include that information in our DPG response model.

We've thought of a few ways of including this on our response model. For all of these ways we've decided not to include the header properties on the dictionary representation of the model, so the header properties will all be attribute only, and will not show up in dict-syntax.

  1. Have header properties as top-level attributes, i.e. my_model.my_header_attribute
  2. Have a .headers attribute on these models, i.e. my_model.headers.my_header_attribute
  3. Have a .get_headers() attribute on these models, i.e. my_model.get_headers().my_header_attribute
@iscai-msft iscai-msft added the DPG label Jun 29, 2023
@msyyc
Copy link
Member

msyyc commented Jul 4, 2023

For all of these ways we've decided not to include the header properties on the dictionary representation of the model
-> I am curious why we don't include header properties on the dictionary representation

@iscai-msft
Copy link
Contributor Author

Logically speaking the dictionary representation is reserved for just the body. The main reason for maintaining this is it would be a large logical shift if we had the dictionary representation include headers as well. For example: as the dictionary response is just a body, users can immediately pass in the returned dictionary in our model-less generations as body input to another operation. If we include header in the dictionary response, then we are opening users up to service errors / weird behavior. If we only include headers in attribute syntax, we can filter those out before sending to the service.

For all of these ways we've decided not to include the header properties on the dictionary representation of the model -> I am curious why we don't include header properties on the dictionary representation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
models need-design needs coding design p1
Projects
None yet
Development

No branches or pull requests

2 participants