Skip to content

Commit

Permalink
Update generator to handle pydantic v2
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-groundlight committed Sep 30, 2024
1 parent deca1ee commit aac8014
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ generate: install-generator ## Generate the SDK from our public openapi spec
-o ./generated \
--additional-properties=packageName=groundlight_openapi_client
# strict-nullable makes nullable fields Optional in the generated Pydantic classes: https://github.com/koxudaxi/datamodel-code-generator/issues/327
poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py --strict-nullable --use-schema-description
poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py --strict-nullable --use-schema-description --output-model-type pydantic_v2.BaseModel
poetry run black .

PYTEST=poetry run pytest -v
Expand Down
8 changes: 4 additions & 4 deletions generated/model.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# generated by datamodel-codegen:
# filename: public-api.yaml
# timestamp: 2024-09-30T16:56:30+00:00
# timestamp: 2024-09-30T16:59:30+00:00

from __future__ import annotations

from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Union

from pydantic import AnyUrl, BaseModel, Field, confloat, conint, constr
from pydantic import AnyUrl, BaseModel, Field, RootModel, confloat, conint, constr


class AnnotationsRequestedEnum(Enum):
Expand Down Expand Up @@ -184,8 +184,8 @@ class Action(BaseModel):
include_image: bool


class ActionList(BaseModel):
__root__: List[Action]
class ActionList(RootModel[List[Action]]):
root: List[Action]


class AllNotes(BaseModel):
Expand Down

0 comments on commit aac8014

Please sign in to comment.