grape-swagger icon indicating copy to clipboard operation
grape-swagger copied to clipboard

Does Not Handle Rails Optional Path Segments

Open spaceraccoon opened this issue 2 years ago • 0 comments

Ruby on Rails supports optional path segments, such as:

get 'photos(/:id)'

would match both photos/:id and photos paths.

However, grape-swagger does not recognise these optional path segments. For example:

get 'photos(/:id)' 

would generate:

"paths": {
  "/api/v2/photos(/{id})": {
    "get": {
    ...
      "parameters": [
         {
           "in": "path", "name": "id"
           ...
  }
}

instead of the expected:

"paths": {
  "/api/v2/photos": {
    "get": {
    ...
  }
  ...
  "/api/v2/photos/{id}": {
    "get": {
    ...
      "parameters": [
         {
           "in": "path", "name": "id"
           ...
  }
}

grape-swagger should also handle Rails optional path segments in a predictable manner.

spaceraccoon avatar Nov 10 '22 09:11 spaceraccoon