Content-Type support other than application/json#49
Content-Type support other than application/json#49mission-liao merged 1 commit intopyopenapi:masterfrom
Conversation
There was a problem hiding this comment.
Here is tricky, I don't sure how to handle it in a better way. Actually, I find prim_factory and mime_codec have some similar work. I'm now just leave prim_factory unchanged.
|
This commit is still a draft, I'll add test case after review feedback. |
|
Yep, there is no way for users to send/receive in MIME format other than 'application/json'. To make it works, lots of things need to be done. Here is my review and suggestion of your works:
pet_Tom=dict(id=1, name='Tom', photoUrls=['http://test'])
req, resp = op(body=pet_Tom)
# [0] my sending format, [1] my preferred response format in response
req.mime = ('application/xml', 'application/json')
client.request((req, resp),)
|
|
I would stay away from internet for a few days, if you have any PR, I will review them next Friday (or later). |
|
Got it, thanks for telling me this. |
4171f80 to
b508a8c
Compare
|
Pull request is updated.
|
|
Thanks for your works. The relation between formats of data types: The correct procedure of unmarshal should be: However, I didn’t follow this “expected” design and just make pyprim accept json as string-buffer. Therefore, it works in pyswagger.io.SwaggerResponse.apply_with, because pyprim accept json string. But it’s not a correct design. Here is the right design:
it seems really messy in io-related code, and I can’t predict what would go wrong when reworking. So these are the follow-up options:
What do you think? and thanks for your work again. |
|
Thanks for your feedback. I would prefer option#2, since I just start learning Python and I need some practice :) |
|
Ok, let's fulfill missing pieces of this project. |
|
Hi, here is an issue related to this PR, I would start fix that issue next Monday, if you have any progress on this case, please let me know. |
|
Sorry for the late response, a series of things happened and I'm on vacation now, will update the pull request around Feb. 2. |
|
Hi, I'm very appreciate for your work, it's really nice to see things still going on. Before you proceeding, make sure to rebase to current code base (maybe resubmit a PR if possible) |
b052f8d to
8dafbd9
Compare
|
Hi liao, I've updated the pull request (PR is reused since the update is base on original code change), please help to review. |
There was a problem hiding this comment.
use StringIO instead of text in case the response is binary format, e.g. protobuf
|
Hi, it looks great at the first sight, I will review it more carefully later today, well done and thanks. |
| self._codecs = {} | ||
| self.register('text/plain', PlainCodec()) | ||
| jsonCodec = JsonCodec() | ||
| for _type in ['application', 'text']: |
There was a problem hiding this comment.
IMO, keywords are better kept in one string than separated into parts. Could you rewrite this part in this form?
self.register('application/json', jsonCodec)
self.register('text/json', jsonCodec)In this form, it's easier to trace code for new comers.
|
fairly reasonable, code is updated. |
|
Hey, I saw Taiwan earthquake news today, hope everything goes well with you. |
Content-Type support other than application/json
|
For the encoding problem, I have to confess that I take the easiest way to deal with it. And it should be a good timing to take care of it now. I''ll open an issue for discussion and a proposal for dealing this later. |
- customised codec: pyopenapi/pyswagger#49 - support for no SSL certificate pyopenapi/pyswagger#60 - renders failed on windows pyopenapi/pyswagger#63
pyswagger requires swagger operation consume and produce in application/json format. To support other content-type (application/xml, application/x-protobuf, etc.), I draft a commit.
Here is my usage: