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

Issue #1228 - Feature: support extensions in utoipa::path macro #1292

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

juliendecharentenay
Copy link

@juliendecharentenay juliendecharentenay commented Jan 15, 2025

Hi,
This is a first attempt at implementing extensions within the utoipa::path macro. Read the PR in conjunction with the issue #1228 .

The extensions is implemented for the following parts of the utoipa::path macro:

  • At operation level;
  • Operation > Params > ParamItem
  • Operation > Responses
  • Operation > Responses > ContentType
  • Operation > RequestBody
  • Operation > RequestBody > ContentType

The implementation uses the form (as discussed in the issue):

("x-my-extension" = json!({"key": "value"}))

The parsing and building of the token stream is done in a struct Extensions - which I located under components/features/attributes. I decided to split it into its own file that is loaded in attributes.rs as attributes.rs is already quite long. But not sure (a) if it makes sense as a child of attributes and (b) if ok to split into its own separate file.

Also, I used use super::*; at the top of the extensions.rs. Happy to modify to just what is needed if this is the recommended approach.

What is included:

  • Tests [for the happy path]
  • An example. The example is showing both macro and Modify trait approaches [this was a way for me to check which one were replaceable] - but having both there may be too much.

@juliendecharentenay juliendecharentenay marked this pull request as draft January 16, 2025 19:17
@juliendecharentenay
Copy link
Author

Convert to draft as I noticed the PR test suite is not passing - and also have a couple of tweaks I thought of.

@juliendecharentenay juliendecharentenay marked this pull request as ready for review January 16, 2025 20:26
@infiniteregrets
Copy link

hi @juhaku, friendly ping - just checking in if there's any chance you'd be able to get to review this soon. no worries if not!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants