Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6376
Closed
Open
Issue created May 20, 2020 by Administrator@rootContributor1 of 5 checklist items completed1/5 checklist items

[BUG][Typescript] modeling anyOf vs oneOf

Created by: fantapop

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

I noticed there is a lack of support for the open api 3 anyOf operation in most of the typescript templates. There are quite a few implementations of oneOf using typescript unions. Based on my reading of the spec and understanding of typescript I would expected that anyOf would be implemented via a type union and oneOf would be something more complicated which doesn't have native syntax support for in typescript. I wanted to gather the thoughts of those who have worked on these implementations.

This paragraph indicates that oneOf should not be allowed to match more than one of the types listed.

I was expecting it to be implemented something more like an exclusive-or. Some google around turned up this informative blog post on the subject.

Is this differentiation useful to people? Would a change like this horribly break users of generated typescript libraries? Am I missing something here? Thanks for your time.

@petejohansonxo @eriktim @macjohnny @karismann @SAnDAnGE

To divulge a little about my interest in this, I've been using a typescript framework call TSOA which generates an open api spec using the typescript interfaces and annotations attached to the controllers of our api server. It's really a great project. We're then generating a typescript client for our admin tool using the typescript-fetch openapi generator. It's been an interesting experiment to see what typescript goes in and what comes out on the other end. We've come to a point where we need this union support working and so I've started to investigate an implementation.

Assignee
Assign to
Time tracking