Skip to content

Typing of deployment's payload field #178

Closed
@msw-kialo

Description

@msw-kialo

GitHub deployments API includes a payload field. That can be JSON payload (either as string or directly embedded).

It is currently documented as:

payload:
  oneOf:
    - type: object
      additionalProperties: true
    - type: string
      description: JSON payload with extra information about the deployment.
      default: ''

it is currently typed as

class ReposOwnerRepoDeploymentsPostBodyPropPayloadOneof0Type(TypedDict):
    """ReposOwnerRepoDeploymentsPostBodyPropPayloadOneof0"""


class WebhookDeploymentCreatedPropDeploymentPropPayloadOneof0(GitHubModel):
    """WebhookDeploymentCreatedPropDeploymentPropPayloadOneof0"""

Both represent the type: object aspect, but ignore additionalProperties: true. This makes the field useless (as they only allow to encode an empty json object).

For pydantic extra=allow is needed:

class WebhookDeploymentCreatedPropDeploymentPropPayloadOneof0(GitHubModel):
    """WebhookDeploymentCreatedPropDeploymentPropPayloadOneof0"""

	model_config = {"extra": "allow"}

I am not so sure about ReposOwnerRepoDeploymentsPostBodyPropPayloadOneof0Type. I think, it needs to be encoded as a normal dict[str, ...] as TypedDicts have currently no way to allow for extra keys.

(I can try to create a PR but I am not familiar with the code base at the moment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    WebHookbugSomething isn't workingschemaschema related

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions