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

[Typescript] Kiota fails when generating code for oneOfs #4434

Closed
andreaTP opened this issue Apr 2, 2024 · 5 comments
Closed

[Typescript] Kiota fails when generating code for oneOfs #4434

andreaTP opened this issue Apr 2, 2024 · 5 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request TypeScript Pull requests that update Javascript code
Milestone

Comments

@andreaTP
Copy link
Contributor

andreaTP commented Apr 2, 2024

Provided an OpenAPI using oneOf and discriminators like this:

openapi: 3.0.0
info:
  title: "Discriminator API"
  version: "1.0.0"
servers:
  - url: https://mytodos.doesnotexist/
paths:
  /discriminateme:
    get:
      description: Return something
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/Object1"
                  - $ref: "#/components/schemas/Object2"
                discriminator:
                  propertyName: objectType
                  mapping:
                    obj1: "#/components/schemas/Object1"
                    obj2: "#/components/schemas/Object2"
components:
  schemas:
    Object1:
      type: object
      required:
        - objectType
      properties:
        objectType:
          type: string
        one:
          type: string
    Object2:
      type: object
      required:
        - objectType
      properties:
        objectType:
          type: string
        two:
          type: string

using a command:

kiota generate -l typescript -n client -d openapi.yaml -o ./tmp --clean-output

You get the error message:

crit: Kiota.Builder.KiotaBuilder[0]
      error generating the client: Unable to find factory method for Object1

and the generation fails.

Found in the context of #4433

@andrueastman andrueastman added the type:bug A broken experience label Apr 5, 2024
@andrueastman andrueastman added this to the Kiota v1.14 milestone Apr 5, 2024
@andrueastman
Copy link
Member

@andreaTP Any chance you'll be able to take a look at this similar to #4433?

@baywet
Copy link
Member

baywet commented Apr 15, 2024

expected as #1812 is not implemented yet.
Closing

@baywet baywet closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2024
@baywet baywet added duplicate This issue or pull request already exists enhancement New feature or request TypeScript Pull requests that update Javascript code and removed type:bug A broken experience labels Apr 15, 2024
@baywet baywet modified the milestones: Kiota v1.14, Backlog Apr 15, 2024
@andreaTP
Copy link
Contributor Author

Are we closing as duplicate?

@baywet
Copy link
Member

baywet commented Apr 15, 2024

That was my idea unless I missed something?

@andreaTP
Copy link
Contributor Author

That's fine by me as soon as we cover this use-case 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request TypeScript Pull requests that update Javascript code
Projects
Archived in project
Development

No branches or pull requests

3 participants