Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@juliendecharentenay
Copy link
Contributor

@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.

Closes #1228 Closes #1255

@juliendecharentenay juliendecharentenay marked this pull request as draft January 16, 2025 19:17
@juliendecharentenay
Copy link
Contributor 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!

@redactedontop
Copy link

@juhaku Heya! Would you mind merging this?

@IvanProg00
Copy link

I too!!!

Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, could you add new entry to utoipa-gen/CHANGELOG.md file under the Unreleased and Added title.

@juhaku
Copy link
Owner

juhaku commented May 21, 2025

@infiniteregrets @redactedontop @IvanProg00 Hey thanks for patience, this looks good to me 🥇 Just missing CHANGELOG entry and it can be merged.

@juhaku juhaku force-pushed the path-support-extension-1228 branch from 7cd1db9 to b54da7a Compare May 26, 2025 20:03
@juhaku juhaku merged commit d267907 into juhaku:master May 26, 2025
12 checks passed
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.

extension in utoipa::path response Feature: support extensions in utoipa::path macro

5 participants