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

Remove binding between path parameter in openapi and Laravel route declaration #186

Merged
merged 3 commits into from
Mar 8, 2024

Conversation

bastien-phi
Copy link
Collaborator

Before, having an openapi route like

    "/users/{id}": {
      "parameters": [
        {
          "schema": {
            "type": "string"
          },
          "name": "id",
          "in": "path",
          "required": true
        }
      ],
      ...

and a route declaration like

Route::get('users/{user}', ...);

was not possible because parameter names between the specification was used to get the parameter value in the Laravel world.

This PR adds a 'translation' step where we translate id into user (in this example).

I also changed the way that bindings are tested, in order to properly cover the test cases. SubstituteBindings middleware was missing.

Fixes #140

Copy link
Owner

@hotmeteor hotmeteor left a comment

Choose a reason for hiding this comment

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

🏆 🏆 🏆

Copy link

@ymhuang0808 ymhuang0808 left a comment

Choose a reason for hiding this comment

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

Hi @bastien-phi ,

Thanks for your PR. I've applied it in my project and encountered a situation.

src/Middleware.php Outdated Show resolved Hide resolved
@bastien-phi bastien-phi marked this pull request as draft February 29, 2024 07:38
@bastien-phi bastien-phi marked this pull request as ready for review March 2, 2024 21:10
@bastien-phi bastien-phi requested review from ymhuang0808 and hotmeteor and removed request for ymhuang0808 March 2, 2024 21:10
@ymhuang0808
Copy link

@bastien-phi 👍

@bastien-phi bastien-phi merged commit a1b8247 into master Mar 8, 2024
9 checks passed
@bastien-phi bastien-phi deleted the fix_route_binding_coupling branch March 8, 2024 07:45
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.

Route binding coupling
3 participants