When working with the gitea API, I've ran into the issue that the CommitStatusState object is converted into the following class:
class CommitStatusState(BaseModel):
"""
None model
CommitStatusState holds the state of a CommitStatus
It can be "pending", "success", "error", "failure", and "warning"
"""
from the following openapi.json:
"CommitStatusState" : {
"description" : "CommitStatusState holds the state of a CommitStatus\nIt can be \"pending\", \"success\", \"error\", \"failure\", and \"warning\"",
"type" : "string",
"x-go-package" : "code.gitea.io/gitea/modules/structs"
},
The problem is, that it actually should be a string. In practice this causes for instance the /repos/{owner}/{repo}/statuses/{sha} to not be usable, as openapi-python-generator creates the following api method:
class CreateStatusOption(BaseModel):
"""
None model
CreateStatusOption holds the information needed to create a new CommitStatus for a Commit
"""
context: Optional[str] = Field(alias="context", default=None)
description: Optional[str] = Field(alias="description", default=None)
state: Optional[CommitStatusState] = Field(alias="state", default=None)
target_url: Optional[str] = Field(alias="target_url", default=None)
poetry run openapi-python-generator --library aiohttp openapi.json gitea/
inspect the generated files gitea/services/async_repository_service.py, gitea/models/CreateStatusOption.py and gitea/models/CommitStatusState.py
Expected behavior
The state attribute in CreateStatusOption should have the type Optional[str] and not CommitStatusState or CommitStatusState should be an alias for str.
Describe the bug
When working with the gitea API, I've ran into the issue that the
CommitStatusState
object is converted into the following class:from the following
openapi.json
:The problem is, that it actually should be a string. In practice this causes for instance the
/repos/{owner}/{repo}/statuses/{sha}
to not be usable, as openapi-python-generator creates the following api method:where
CreateStatusOption
is the following class:Now when you try to call it as follows:
where
ci_state
is some string, you'll receive the following validation error:To Reproduce Steps to reproduce the behavior:
podman run --pull=always --rm -v (pwd):/local:Z openapitools/openapi-generator-cli generate -i https://gitea.opensuse.org/swagger.v1.json -g openapi -o /local/
poetry run openapi-python-generator --library aiohttp openapi.json gitea/
gitea/services/async_repository_service.py
,gitea/models/CreateStatusOption.py
andgitea/models/CommitStatusState.py
Expected behavior
The
state
attribute inCreateStatusOption
should have the typeOptional[str]
and notCommitStatusState
orCommitStatusState
should be an alias forstr
.