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

openapi3.errors.SpecError: Expected components.schemas.Foobar.properties.foobar.default to be one of [<class 'float'>], got <class 'int'> #122

Open
luckydonald opened this issue Jun 26, 2024 · 2 comments

Comments

@luckydonald
Copy link

Based on https://demo.grocy.info/api/openapi/specification:

{
  "openapi": "3.1.0",
  "components": {
    "schemas": {
      "Product": {
        "type": "object",
        "properties": {
          "min_stock_amount": {
            "type": "number",
            "minimum": 0,
            "default": 0
          }
        },
        "example": {
          "min_stock_amount": "8"
        }
      }
    }
  }
}

Produces

openapi3.errors.SpecError: Expected components.schemas.Product.properties.min_stock_amount.default 
to be one of [<class 'float'>], got <class 'int'>
@luckydonald
Copy link
Author

luckydonald commented Jun 26, 2024

In my local testing around,

TYPE_LOOKUP = {
    "array": list,
    "integer": int,
    "object": dict,
    "string": str,
    "boolean": bool,
-   "number": float,
+   "number": [float, int],
}

made it work.

Pretty sure the kind of error is related to #29 and #30.

@luckydonald luckydonald mentioned this issue Jun 26, 2024
@luckydonald
Copy link
Author

luckydonald commented Jun 26, 2024

I did a bit of work for this on #123, but unfortunately I can't compile uvloop, hence I can't run any tests on it (or create any)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant