Skip to content

Arrays referencing multiple schemas with oneOf are resolved as type unknown. #1148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
afohlmeister-smatch opened this issue May 26, 2023 · 3 comments
Closed
1 of 2 tasks
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library

Comments

@afohlmeister-smatch
Copy link

Description

When referencing multiple schemas within an array, the resulting typescript type is

Input

{
    "global.markets": {
        "items": {
            "$ref": "#/$defs/global.market"
        },
        "uniqueItems": true
    },
    "global.market": {
        "oneOf": [
            {
                "$ref": "#/$defs/global.region-code",
                "title": "Region"
            },
            {
                "$ref": "#/$defs/global.country-code",
                "title": "Country"
            }
        ]
    },
    "global.region-code": {
        "enum": [
            "northern_africa",
            "eastern_africa",
            "oceania"
        ]
    },
    "global.country-code": {
        "enum": [
            "ABW",
            "AFG",
            "AGO"
        ]
    }
}

Result:

 "global.market": components["schemas"]["global.region-code"] | components["schemas"]["global.country-code"];
 "global.markets": unknown;
Name Version
openapi-typescript 6.2.6
Node.js v19.6.0
OS + version macOS 13.0.1

Expected result

global.markets should be types as an array referencing global.market

Checklist

@afohlmeister-smatch afohlmeister-smatch added bug Something isn't working openapi-ts Relevant to the openapi-typescript library labels May 26, 2023
@afohlmeister-smatch
Copy link
Author

Hey there, because I'm idiot, I checked your issues regarding tuples, arrays and items and completely missed #1131 - this is probably a related issue.

@drwpow
Copy link
Contributor

drwpow commented Jul 7, 2023

The latest release fixes #1131, but I’ll leave this issue open to double-check; this may be a different bug.

@drwpow
Copy link
Contributor

drwpow commented Jul 25, 2023

Going to mark the issue as closed, because I believe the issue is resolved? But please let me know if updated versions didn’t address the issue.

@drwpow drwpow closed this as completed Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

No branches or pull requests

2 participants