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

Path grouping via a RegEx pattern #215

Closed
cascer1 opened this issue Dec 8, 2016 · 9 comments
Closed

Path grouping via a RegEx pattern #215

cascer1 opened this issue Dec 8, 2016 · 9 comments
Assignees
Milestone

Comments

@cascer1
Copy link
Contributor

cascer1 commented Dec 8, 2016

Hi!

I'm testing this tool using a large API spec (the Globalcollect S2S API, to be specific), and having just one list of endpoints isn't very useful.

Instead, it would be awesome if I could define (for example) a RegEx pattern for headers, which is then used for grouping paths.

For example: The Globalcollect API has endpoints in categories like payments, payouts and products:

  • POST {merchantId}/payments
  • GET {merchantId}/payments/{id}
  • POST {merchantId}/payments/{id}/approve
  • POST {merchantId}/payments/{id}/cancel
  • POST {merchantId}/payouts
  • GET {merchantId}/payouts/{id}
  • GET {merchantId}/products
  • POST {merchantId}/products
  • GET {merchantId}/products/{id}
  • etc. (You get the idea).

In another tool I'm developing, I added the ability to match endpoints to a RegEx, and assign them to a category if they match, the categories are generated based on the first capture groups in the patterns. Using the example above, I then match them with RegEx \/{merchantId}\/(\w+)$

This results in the categories payments, payouts and products being created. All paths are then put inside these categories. This results in the following structure (All paths have a description so they can get a pretty name):

image

A similar functionality in this tool would be awesome!

@RobWin
Copy link
Member

RobWin commented Dec 8, 2016

Hello,

wow, the API docs web site of Globalcollect S2S API is awesome :)
Swagger2Markup does support that already using Swagger tags.

See http://swagger2markup.github.io/spring-swagger2markup-demo/1.1.0/

and

https://github.com/Swagger2Markup/swagger2markup-maven-project-template/blob/master/src/docs/swagger/swagger_petstore.yaml#L21-L27

@RobWin RobWin added the question label Dec 8, 2016
@cascer1
Copy link
Contributor Author

cascer1 commented Dec 8, 2016

Hi,

The problem is that swagger tags require people to modify their API spec. I don't think globalcollect wants to pay someone to go through their entire spec and add tags to all paths. (Trust me, it's a large file) This would also allow for easy adjustment of headers to test different configurations too.

@RobWin
Copy link
Member

RobWin commented Dec 8, 2016

Do they have a Swagger Spec?

Would you like to create a PR and contribute?
I won't have time to implement that feature.

@cascer1
Copy link
Contributor Author

cascer1 commented Dec 8, 2016

I'll have a look around the source code and try to cook something up :)

@RobWin
Copy link
Member

RobWin commented Dec 8, 2016

👍 Thx

@cascer1
Copy link
Contributor Author

cascer1 commented Dec 12, 2016

@RobWin I've started working on this some more, could you have a look to see if I missed any methods required to make this work?

master...cascer1:feature/regex-path-grouping

Also, are there any unit tests for sorting? If so, I couldn't find them.

@RobWin
Copy link
Member

RobWin commented Dec 12, 2016

The commits look good so far. Thx

@RobWin RobWin changed the title Add support for nesting paths Path grouping via a RegEx pattern Dec 13, 2016
RobWin pushed a commit that referenced this issue Dec 13, 2016
* Begin working on #215

* Begin looking for methods that need to be modified for #215

* Begin working on #215

* Begin looking for methods that need to be modified for #215

* Work on implementing regex sorting

* Add regex ordering translations and unit test

* Improve Regex grouping

* Make regex sorting test more like a real-world example

* Remove unused imports
@RobWin RobWin modified the milestones: 1.0.1, 1.1.2 Dec 13, 2016
@cascer1
Copy link
Contributor Author

cascer1 commented Dec 15, 2016

I believe this was closed by #217

@RobWin RobWin closed this as completed Dec 16, 2016
RobWin pushed a commit that referenced this issue Dec 19, 2016
* Begin working on #215

* Begin looking for methods that need to be modified for #215

* Begin working on #215

* Begin looking for methods that need to be modified for #215

* Work on implementing regex sorting

* Add regex ordering translations and unit test

* Improve Regex grouping

* Make regex sorting test more like a real-world example

* Remove unused imports

* Improve code style consistency

* Improve code style consistency

* Remove empty statement

* Resolve some Codacy issues

* Remove empty constructors

* Remove unused fields

* Merge nested IF statements

* Improve method scopes

* Remove unused classes

* Remove unused imports

* Remove fixed TODO comment

* Fix codacy issues

* Fix codacy issues (reverted from commit 43f27e7)

* Improve code style consistency

* Resolve some Codacy issues

* Remove empty constructors

* Remove unused fields

* Merge nested IF statements

* Improve method scopes

* Remove unused classes

* Remove unused imports

* Remove fixed TODO comment

* Fix codacy issues
@RobWin RobWin modified the milestones: 1.2.0, 1.1.2 Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants