wy-z / requests-openapi

A lightweight but powerful and easy-to-use Python client library for OpenAPI v3.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

post body

laktak opened this issue · comments

Thanks for your project - I like the idea of dynamically generating the api instead of having to genereate the code in advance.

I ran into a bug while trying to specify a post body.

I'm trying to pass data as the post body to requests:

c.addLink(_data={"url": "test", "title": "test"})

But there appears to be a bug when you create the kwargs:

  File ".../site-packages/requests_openapi/core.py", line 115, in f
    for k in kwargs:
RuntimeError: dictionary keys changed during iteration

It would be nice if you could add native support for a request body:

        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Link"
              }
            }
          }
        },

Thanks!

Hi, @laktak. Thank you for the feedback.
May you try c.addLink(json={"url": "test", "title": "test"})?

Ah, yes, that works. Thank you!

@laktak

] = kwargs.pop(k)

This line of code is sloppy, I will fix it and enhance unit tests.
Thank you for the feedback again.