schema.py 314 B

1234567891011121314
  1. from ninja import Schema
  2. def to_camel(string: str) -> str:
  3. return "".join(
  4. word if i == 0 else word.capitalize()
  5. for i, word in enumerate(string.split("_"))
  6. )
  7. class CamelSchema(Schema):
  8. class Config(Schema.Config):
  9. alias_generator = to_camel
  10. populate_by_name = True