Skip to content
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

openapi to tsp converter doesn't like unions #4080

Closed
timotheeguerin opened this issue Aug 2, 2024 · 0 comments · Fixed by #4149
Closed

openapi to tsp converter doesn't like unions #4080

timotheeguerin opened this issue Aug 2, 2024 · 0 comments · Fixed by #4149
Assignees
Labels
openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter triaged:core

Comments

@timotheeguerin
Copy link
Member

openapi: 3.0.0
info:
  title: (title)
  version: 0.0.0
tags: []
paths: {}
components:
  schemas:
    Abc:
      type: object
      required:
        - name
      properties:
        name:
          type: string
    MyUnion:
      oneOf:
        - type: string
        - $ref: '#/components/schemas/Abc'

converts to

import "@typespec/http";
import "@typespec/openapi";
import "@typespec/openapi3";

using Http;
using OpenAPI;

@service({
  title: "(title)",
})
@info({
  version: "0.0.0",
})
namespace title;

model Abc {
  name: string;
}

@oneOf
model MyUnion {}
@timotheeguerin timotheeguerin added the openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter label Aug 2, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 12, 2024
…peSpec data types (#4149)

Fixes #4080  and #4088

This also fixes a few bugs/rough edges around generating TypeSpec types
from OpenAPI3 component schemas.

Still 2 things to follow up with that I'll create issues for:
1. Support `allOf` with more than 1 member. Likely this will result in
spreading all the members, except extending 1 if there is 1 that has a
discriminator. (#4152)
2. Place all component schemas under a `Schemas` namespace (and do
something similar for `Parameters`) to prevent name collisions.
(#4151)

---------

Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
sarangan12 pushed a commit to sarangan12/typespec that referenced this issue Sep 16, 2024
…peSpec data types (microsoft#4149)

Fixes microsoft#4080  and microsoft#4088

This also fixes a few bugs/rough edges around generating TypeSpec types
from OpenAPI3 component schemas.

Still 2 things to follow up with that I'll create issues for:
1. Support `allOf` with more than 1 member. Likely this will result in
spreading all the members, except extending 1 if there is 1 that has a
discriminator. (microsoft#4152)
2. Place all component schemas under a `Schemas` namespace (and do
something similar for `Parameters`) to prevent name collisions.
(microsoft#4151)

---------

Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter triaged:core
Projects
None yet
3 participants