interagent / interagent/committee

Matching paths with parameters does not recognize due to failing to split on extension `.`

Open
#261 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Ruby
Stars
955
Forks
145
Avg merge
5d 4h
Merged PRs (30d)
6

Description

Foremost, thanks for the great Gem.

I am applying this Gem retroactively to a project to add an OAS3 specification to its API. The API in question explicitly requires the response format as part of the URL, instead of a MIME type. I believe Committee cannot recognize this at the moment, thus I'm leaving an issue here. I'm happy to help fix, but given that is my first issue, I wanted to reach out first.

Here's the issue: for my project, if I want to update an object called a Fribble, with the ID parameter 123, I would call:

PUT /v1/fribble/123.json

... to invoke the API. In my OAS3 document, it looks like this:

paths:
  /v1/fribble/{id}.json:
    put:
      # and so on

Expected behavior: path matches, and my request/response is validated by Committee.
Actual behavior: path does not match, and nothing is validated.

Upon investigation, I noticed that OpenAPIParser::PathItemFinder splits path names on the / character when trying to infer path parameters in matching_paths_with_params.
Doing so leaves my actual parameter -- 123 -- mixed in with .json, which does not match the parameter type of integer (at least, I am assuming this is why it does not match), and thus, I assume that the request remains unmatched.

I locally can "fix" the problem by changing the split('/') method to instead split on forward slashes or periods: split(/[\/\.]/), however I feel that that may have adverse effects as well if paths had periods in them (which is totally valid).

I could attempt to fix this by only splitting on the . when it is at the end of the request path (e.g. there is no trailing / afterward).

If I am merely "holding it wrong", I sincerely apologize for raising the issue; I do understand that the API spec I am trying to model is quite odd in its interpretation, but that is precisely why I want to use this tool to improve it :)

Thanks in advance for your time.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with OpenAPIParser::PathItemFinder and its matching_paths_with_params method, then reproduce the reported PUT /v1/fribble/123.json case against the /v1/fribble/{id}.json path. Determine how extension-bearing paths should be matched without breaking valid periods in paths; done means the request matches and Committee validates it.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.