Parquery / swagger-to

Generate server and client code from Swagger (OpenAPI 2.0) specification.
MIT License
57 stars 14 forks source link

ValueError: Expected the value in a schema to be a string, but got: <class 'swagger_to.swagger.RawDict'> #132

Closed stevenxuwoss closed 1 year ago

stevenxuwoss commented 3 years ago

if definitions properties has name with description, will cause this issue

  DeviceDefineInfoRes:
    type: object
    discriminator: ''
    properties:
      createPerson:
        type: string
      createTime:
        type: string
      description:
        type: string
      id:
        type: string
      manufacturer:
        type: string
      name:
        type: string
      number:
        type: string
      productTypeCode:
        type: integer
        format: int32
      updatePerson:
        type: string
      updateTime:
        type: string
    description: ''
20211027104911

(@mristin, 2021-10-27: added markers for multi-line code)

mristin commented 3 years ago

Thanks! I'll try to have a look at the issue this weekend.

mristin commented 2 years ago

@stevenxuwoss I just realized I haven't looked at this issue; please apologize. Is it still critical to you?

nicolasassi commented 2 years ago

@mristin I had the same problem sadly.

mristin commented 2 years ago

@nicolasassi thanks for letting me know! I'll try to have a look at this tomorrow (Monday).

mristin commented 2 years ago

Hi @nicolasassi , Unfortunately, I got swamped with work & mixed in holidays, so I didn't have time to look into this problem. At the moment, I do not have time to fix this issue.

However, if you'd like to make a pull request, I'd be more than glad to support you, introduce you to the code and review your changes.

salmanee commented 2 years ago

Also running into the same issue

mristin commented 2 years ago

@salmanee could you please post a minimal schema that causes the error?

salmanee commented 2 years ago

@mristin This is a small snippet.


"definitions": {
    "definition_one": {
           "type": "object",
            "properties": {
                   "description": {
                            "type": "string",
                             "description": "......"
                     },
              .......

The three last lines is where I get this error. It seems like it's only expecting string for descriptions.

AkuPython commented 1 year ago

@mristin Apologies for the mess above, it's my first PR. Next time I won't include the Issue # in my Fork commits...

Essentially, the {}["description"]: value is str... (If required) should be below the other checks. The schema validation accurately analyses if "description" must be a string, and errors as required. Here, checking if the "description" value is a string only appears to be needed to trigger .strip() for documentation, not to determine the validity of the "description" values type.

mristin commented 1 year ago

@AkuPython thanks a lot again for your fix! I merged it in and released the patch version 5.0.1.

Please re-open if the issue re-surfaces.