-
Notifications
You must be signed in to change notification settings - Fork 34
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
Improved handling of generic media types #471
Comments
Hi @thompson-tomo I'd say this description is not specific enough. From what it describes, it'd mean I could also send it an image, YAML, etc... Which I'm pretty sure the API would be unhappy with. We don't have any plans to add any "compatibility" mechanism, allowing users to say "map star/star to application/json during the generation", it'd be a slippery slope. |
My use-case is different but is excluded by the lack of this functionality. I am working with an API where you can attach files/images/etc. to a request and in it’s documentation it says it supports / so by extensions when you call /attachment/{sys_id}/file it can return nearly any content type. |
Here is the documentation for reference: https://www.servicenow.com/docs/bundle/xanadu-api-reference/page/integrate/inbound-rest/concept/c_AttachmentAPI.html The section in question is: Attachment - GET /now/attachment/{sys_id}/file |
Agree @michaeldcanady use case is deeply connected to this. For me what would be most beneficial is if not otherwise specified it is expected that the api will return the same content type as the request for instance posting json is expected to return json unless the api or developer specifies otherwise. |
Thank you for the additional information. Can you both expand on the use cases here please? I'm still struggling to understand why/what's needed here. |
@baywet to expand on it further/restate - hopefully more clearly. Service-Now has a API endpoint that returns the raw data of an uploaded file (can be any content type). For example take an image. Since Kiota requires a parse node factory for all serialization, if I want to get the raw data of any And while I limited it to only images, a user could upload a JSON file, HTML file, etc. (any content type) and I need to be able to get the raw byte data - which as I understand it - you have to register a parse node factory for each content type. The idea would be, the same as the ErrorMapping system, where it checks for an exact match first, then search for a fuzzy match, before defaulting to |
Thank you for the additional information. I think this might be where the disconnect is. Parse node factories are only required for content... that needs to be parsed (e.g. JSON to a model, text to a scalar value, etc...)
For things that cannot be parsed/don't result in models, kiota will project a Stream in the fluent API, which allows you to access the response body directly. Same logic applies for request bodies. So now, either:
I hope that clarifies the confusion. Let us know if you have any additional comments or questions. |
Would you mind writing an example of how the content is streamed? Looking at the |
As in the generated code? (download a user's profile picture) To call it people write something like using var photoStream = await client.Users["jane"].Photo.Content.GetAsync();
//do something with the stream Let us know if you have any additional comments or questions. |
Thank you for the example! I went to see how the implementation was done in the go variation (since that's what I've been working with) and I have a question:
|
Although it might be confusing, the name of the method has to do with the return type, not the request body type. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
Within the openapi spec i am using (https://api.parkassist.com/docs/index.html) it is using generic media types for requests due to supporting both json & xml.
The above is generating the following method
which is valid, however if the full media type is specified in the openapi, the below method is generated which is easy for a user to use.
What would be helpful is if the media type is defined as one of the below:
where star = *
The below method is generated, and it uses application/json
And it also generates which would is expecting "application/json" and if not matched, results in a failure.
When #342 is implemented that also becomes a supported media type to be passed in.
The text was updated successfully, but these errors were encountered: