Option to control behaviour of `allOf`?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start by tracing the allOf and anyOf generation paths that produce PullRequestClosedPullRequest, then review the PullRequestEvent extraction boilerplate described in the issue. Compare the generated types with the linked schema and define a concrete configurable behavior with tests showing how consumers access shared pull_request fields; done requires an agreed API and regression coverage.
Written by the indexing model from the issue text.
Description
Consider the following schema:
https://unpkg.com/@octokit/webhooks-schemas@7.3.1/schema.json
it contains a definition:
"pull_request$closed": {
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"required": ["action", "number", "pull_request", "repository", "sender"],
"properties": {
"action": { "type": "string", "enum": ["closed"] },
"number": {
"type": "integer",
"description": "The pull request number."
},
"pull_request": {
"allOf": [
{ "$ref": "#/definitions/pull-request" },
{
"type": "object",
"required": ["state", "closed_at", "merged"],
"properties": {
"state": {
"type": "string",
"enum": ["closed"],
"description": "State of this Pull Request. Either `open` or `closed`."
},
"closed_at": { "type": "string", "format": "date-time" },
"merged": { "type": "boolean" }
},
"tsAdditionalProperties": false
}
]
},
"repository": { "$ref": "#/definitions/repository" },
"installation": { "$ref": "#/definitions/installation-lite" },
"organization": { "$ref": "#/definitions/organization" },
"sender": { "$ref": "#/definitions/user" }
},
"additionalProperties": false,
"title": "pull_request closed event"
},
allOf inside pull_request would result of generation of type PullRequestClosedPullRequest which is almost the same as normal PullRequest but has one extra field. This creates a problem for consuming those types: let's say you need a field from inside pull_request -- you would have to account for all of the variations of it.
In languages like TS this would be solved by structural subtyping; in rust, while there's nothing like that built-in, perhaps there's a way to adjust behaviour of anyOf to generate some code that would be able to return common parts? e. g. via a generated trait for example. Right now this needs a lot of boilerplate code, for example to extract any pull_request field form PullRequestEvent
- Dominant language
- Rust
- Stars
- 898
- Forks
- 114
- Avg merge
- 4h 18m
- Merged PRs (30d)
- 14
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from oxidecomputer/typify
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
oxidecomputer/typify#1077 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
oxidecomputer/typify#1075 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 50/100
oxidecomputer/typify#1060 ·
-
Difficulty 5/5 Over a week Newbie friendliness 48/100
oxidecomputer/typify#1059 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
oxidecomputer/typify#1022 · 1 comment ·
All issues in oxidecomputer/typify
Similar issues
-
bug github_actions
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
registrystack/registry-stack#1393 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
longbridge/gpui-kit#3223 ·
-
bug engine
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rocky-data/rocky#2181 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
oasisprotocol/oasis-sdk#2523 ·
-
[indexer] [QA] Add a focused test for the new NonRetryableError / assertSocketAlive() behavior. Openbot:ai-assisted component:indexer QA-roadmap status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
midnightntwrk/midnight-indexer#1557 ·