clientele icon indicating copy to clipboard operation
clientele copied to clipboard

`number` should be rendered as type `float`, not `int`

Open pradishb opened this issue 1 year ago • 0 comments

Django-ninja sets the type of float data type as number in openapi and clientene renders number as int which causes pydantic validation error.

openapi.json

{
  "openapi": "3.1.0",
  "info": {
    "title": "NinjaAPI",
    "version": "1.0.0",
    "description": ""
  },
  "paths": {},
  "components": {
    "schemas": {
      "Pet": {
        "properties": {
          "age": {
            "type": "number"
          }
        },
        "required": [],
        "title": "Pet",
        "type": "object"
      }
    }
  }
}

Output:

class Pet(pydantic.BaseModel):
    age: int

Expected:

class Pet(pydantic.BaseModel):
    age: float

pradishb avatar Sep 25 '24 14:09 pradishb