Description
It seems that Starlite will return the non-alias field names for pydantic models in a response, but will generate the OpenAPI documentation based on the field aliases.
Take this code for example:
from humps import camelize
from pydantic import BaseModel
from starlite import Starlite, get
class User(BaseModel):
user_id: str = "A1"
user_name: str = "Starlite User"
class Config:
alias_generator = camelize
allow_population_by_field_name = True
@get("/")
def get_user() -> User:
return User()
app = Starlite(route_handlers=[get_user])
The expected response of the get_user route is:
{"userId":"A1","userName":"Starlite User"}
Instead, Starlite returns:
{"user_id":"A1","user_name":"Starlite User"}
The OpenAPI docs correctly interpret the alias.
"User": {
"properties": {
"userId": {
"type": "string",
"title": "Userid",
"default": "A1"
},
"userName": {
"type": "string",
"title": "Username",
"default": "Starlite User"
}
},
"type": "object",
"title": "User"
}
URL to code causing the issue
No response
MCVE
No response
Steps to reproduce
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
Screenshots
No response
Logs
No response
Starlite Version
1.5.9
Platform
Description
It seems that Starlite will return the non-alias field names for pydantic models in a response, but will generate the OpenAPI documentation based on the field aliases.
Take this code for example:
The expected response of the get_user route is:
{"userId":"A1","userName":"Starlite User"}Instead, Starlite returns:
{"user_id":"A1","user_name":"Starlite User"}The OpenAPI docs correctly interpret the alias.
URL to code causing the issue
No response
MCVE
No response
Steps to reproduce
Screenshots
No response
Logs
No response
Starlite Version
1.5.9
Platform