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

huma.Operation.Callbacks usage is unclear #653

Closed
wttw opened this issue Nov 19, 2024 · 1 comment · Fixed by #665
Closed

huma.Operation.Callbacks usage is unclear #653

wttw opened this issue Nov 19, 2024 · 1 comment · Fixed by #665
Labels
bug Something isn't working

Comments

@wttw
Copy link

wttw commented Nov 19, 2024

I'm unsure how to add a path to a callback entry.

I'm expecting the generated schema to look something like:

paths:
  /create:
    post:
      callbacks:
        myEvent:
          "{$request.body#/callbackUrl}":
            post:
              requestBody: # Contents of the callback message
                …

But huma.Operation.Callbacks is a map[string]*huma.PathItem and I don't see any way to include a path.

I get something like this, instead:

paths:
  /create:
    post:
      callbacks:
        myEvent:
          post:
            requestBody: # Contents of the callback message
              …

I couldn't find any sample or test code using Callbacks or Webhooks, so I'm not sure whether this is broken or whether I'm holding it wrong.

@danielgtaylor
Copy link
Owner

@wttw you are right, this is a bug. It should be map[string]map[string]*huma.PathItem.

https://spec.openapis.org/oas/v3.1.1.html#callback-object
https://www.speakeasy.com/post/openapi-tips-webhooks-callbacks#creating-a-callback-in-openapi

Thanks for pointing this out, I totally missed that. The original spec explanation is a bit confusing and didn't provide an example 😞

@danielgtaylor danielgtaylor added the bug Something isn't working label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants