-
Notifications
You must be signed in to change notification settings - Fork 422
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
Codegen: Generate attributes on endpoints for any specification extensions defined on path or operation objects #3599
Codegen: Generate attributes on endpoints for any specification extensions defined on path or operation objects #3599
Conversation
fc32b5f
to
cde47d7
Compare
Thank you. Technically this should work, but I'm a bit concerned about using |
Maybe we could generate a single typed attribute |
Thanks for the comments. The type of the key should've been the right type for the value as specified (rather than always being |
95709e1
to
bee2ad3
Compare
openapi-codegen/core/src/main/scala/sttp/tapir/codegen/BasicGenerator.scala
Outdated
Show resolved
Hide resolved
I've pushed up a change that I think would be more in line with how attributes are designed (although see other comment - I need to improve the type logic in the conflict check). Let me know if this looks like the right path |
Marked as draft for now, shoulda done that earlier, sorry |
bee2ad3
to
faf1012
Compare
I've updated the logic around the keys; we should now construct and use a single attribute key with the correct LUB parent type for each specification extension key. Let me know what you guys think. |
I could add a parameterised case class here for wrapping the type, maybe? Something like |
Sounds good to me :) |
OK let's try this. Let me know. |
Nice idea with type aliases. Isn't it enough to have just one level then, without the generic wrapper? |
Yeah I prefer it with the single layer too tbh, just thought it was worth trying it out to see how it feels. I'll revert the last pr. |
This reverts commit e5e0f1c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @hughsimpson!
The OpenApi spec permits defining Specification Extensions on a large number of components. Not all of those have any kind of obvious mapping into the tapir model; however it feels natural to map extensions on path and operation definitions into
.attribute
declarations on generated endpoints, thus making this metadata accessible at runtime for $variousSundryPurposesFor context, this would enable me to implement some specific authorization guards cleanly at the implementation layer without having to hack around with tags. I don't think tapir would currently emit any specification extensions when generating the openapi from an endpoint with attributes, so I guess there's a break in idempotency there? But since we currently ignore extensions anyway I don't consider that a new issue and think this should be ok... Happy to engage in alternatives to solve the same problem! But I do think this is the most sensible route