oxidecomputer / oxidecomputer/progenitor

Handle enum values that contain meaningful non-alphanumeric characters

Open
#397 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1k
Forks
136
Avg merge
8h 36m
Merged PRs (30d)
14

Description

The GitHub API spec contains the following enum for sorting (truncated for clarity):

{
  "name": "sort",
  "description": "Sorts the results ...",
  "in": "query",
  "required": false,
  "schema": {
    "type": "string",
    "enum": [
      "reactions",
      "reactions-+1",
      "reactions--1",
      "reactions-smile"
    ]
  }
}

The enum generated for this results in duplicate variant names:

pub enum SearchIssuesAndPullRequestsSort {
    #[serde(rename = "reactions")]
    Reactions,
    #[serde(rename = "reactions-+1")]
    Reactions1,
    #[serde(rename = "reactions--1")]
    Reactions1,
    #[serde(rename = "reactions-smile")]
    ReactionsSmile,
}

I think this is fixable by updating the sanitize utility in typify to remove the -1 and +1 branches, and performing that conversion as a .replace("-1", "minus1"), etc in the catch all branch instead.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the sanitize utility in typify and inspect how enum values are converted into Rust variant names. Reproduce the GitHub API sort enum case, then verify that values containing -1 and +1 generate distinct variants without changing their serde renames.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.