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

[Bug]: tsp-openapi3 crashes for requestBody with $ref #5485

Closed
4 tasks done
TomerAberbach opened this issue Jan 4, 2025 · 0 comments · Fixed by #5893
Closed
4 tasks done

[Bug]: tsp-openapi3 crashes for requestBody with $ref #5485

TomerAberbach opened this issue Jan 4, 2025 · 0 comments · Fixed by #5893
Assignees
Labels
bug Something isn't working openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter triaged:core

Comments

@TomerAberbach
Copy link
Contributor

Describe the bug

Referencing a requestBody via a $ref to #/components/requestBodies causes a crash in tsp-openapi3.

Reproduction

example.yml:

openapi: 3.0.0
info:
  title: (title)
  version: 0.0.0
paths:
  /thing:
    post:
      operationId: createThing
      requestBody:
        $ref: '#/components/requestBodies/RequestBody'
components:
  requestBodies:
    RequestBody:
      content:
        application/json:
           type: object
tsp-openapi3 example.yml --output-dir ./tsp-output

Result:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at transformRequestBodies (file:///Users/tomeraberbach/Downloads/test/node_modules/.pnpm/@[email protected]_patch_hash=qfvurrzg7d2mskofobmxri2twe_@[email protected]_@ty_y2vkd7p4rkeieiph4t7ptycfkm/node_modules/@typespec/openapi3/dist/src/cli/actions/convert/transforms/transform-paths.js:84:38)
    at transformPaths (file:///Users/tomeraberbach/Downloads/test/node_modules/.pnpm/@[email protected]_patch_hash=qfvurrzg7d2mskofobmxri2twe_@[email protected]_@ty_y2vkd7p4rkeieiph4t7ptycfkm/node_modules/@typespec/openapi3/dist/src/cli/actions/convert/transforms/transform-paths.js:40:32)
    at transform (file:///Users/tomeraberbach/Downloads/test/node_modules/.pnpm/@[email protected]_patch_hash=qfvurrzg7d2mskofobmxri2twe_@[email protected]_@ty_y2vkd7p4rkeieiph4t7ptycfkm/node_modules/@typespec/openapi3/dist/src/cli/actions/convert/transforms/transforms.js:9:24)
    at convertAction (file:///Users/tomeraberbach/Downloads/test/node_modules/.pnpm/@[email protected]_patch_hash=qfvurrzg7d2mskofobmxri2twe_@[email protected]_@ty_y2vkd7p4rkeieiph4t7ptycfkm/node_modules/@typespec/openapi3/dist/src/cli/actions/convert/convert-file.js:12:21)

Checklist

@TomerAberbach TomerAberbach added the bug Something isn't working label Jan 4, 2025
@TomerAberbach TomerAberbach changed the title [Bug]: tsp-openapi3 for requestBody with $ref [Bug]: tsp-openapi3 crashes for requestBody with $ref Jan 4, 2025
@markcowl markcowl added emitter:openapi3 Issues for @typespec/openapi3 emitter triaged:core labels Jan 7, 2025
@markcowl markcowl added this to the [2025] February milestone Jan 7, 2025
@chrisradek chrisradek added openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter and removed emitter:openapi3 Issues for @typespec/openapi3 emitter labels Jan 17, 2025
github-merge-queue bot pushed a commit that referenced this issue Feb 6, 2025
Fixes #5485

---------

Co-authored-by: Christopher Radek <[email protected]>
dmnorc pushed a commit to dmnorc/typespec that referenced this issue Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter triaged:core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants