oxidecomputer / oxidecomputer/progenitor

Collision between property title and sub schema

Open
#333 2 comments 1 reaction 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

In my OpenAPI schema I use the word "Category" as title for validated string properties as well as name and title for an object schema.

The code generation completes without error and the generated API client builds fine but when calling an API client function that has a response (such as GET /api/v1/camera-group/{}/product) which includes a category string I get a runtime error.

Invalid Response Payload: error decoding response body: invalid type: string "food.main.chicken.potatoes", expected struct Category at line 1 column 235

To me this looks like the API client is using the wrong struct for de-serializing the response due to the the two structs sharing a name.

I already found out that as a work around I can change the title of the category string but since the schema is generated as well this would be rather inconvenient.

          "category": {
            "title": "Category Name",
            "maxLength": 255,
            "pattern": "^([a-z\u00e4\u00f6\u00fc0-9_&\u00df]+)(\\.[a-z\u00e4\u00f6\u00fc0-9_&\u00df]+)*$",
            "type": "string"
          }

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

Reproduce the collision with the linked OpenAPI schema and the GET /api/v1/camera-group/{}/product response, then trace how the generator assigns names to the string property and object schema both titled Category. Done means the generated client decodes the category string while still using the object schema correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, rust
Domain
api, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.