oxidecomputer / oxidecomputer/typify

default on enum can causes TypeError(InvalidValue)

Open
#207 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

naming
Dominant language
Rust
Stars
898
Forks
114
Avg merge
4h 18m
Merged PRs (30d)
14

Description

I have a failing input OAS being emitted from a https://github.com/tiangolo/fastapi service, which I've trimmed down to this sample

openapi: 3.0.2
info:
    title: FastAPI
    version: 0.1.0
paths: {}
components:
    schemas:
        A:
            properties:
                version:
                    title: Version
                    enum:
                        - foo
                    type: string
        B:
            properties:
                version:
                    title: Version
                    enum:
                        - bar
                    type: string
                    default: bar

This fails in progenitor with

gen fail: TypeError(InvalidValue)
Error: generation experienced errors

This fails at https://github.com/oxidecomputer/typify/blob/d579a52/typify-impl/src/defaults.rs#L82

Remove the default: bar and the error goes away.

Part of the cause is the title: Version being common on two different enums.

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

Run progenitor generation with the trimmed OpenAPI sample and then inspect typify-impl/src/defaults.rs at line 82. Compare the result with the sample after removing default: bar; done means the schemas with distinct enum values and the shared title no longer produce TypeError(InvalidValue).

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.