apache / apache/grails-core

Resource collection does not work as expected if the resource is within group

Open
#10,844 1 comment 1 reaction 1 assignee Claimed by @ilopmar View on GitHub
info: workaround available status: pr submitted
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Steps to Reproduce

1. Clone demo app
2. Run url-mapping-report command

### Expected Behaviour

The following url mapping add a URI directly below a resource using collection

```
group '/api', {
'/employees'(resources: 'employee') {
collection {
'/search'(controller: 'employee', action: 'search', method: 'GET')
}
}
}
```

Should generate the following result regarding the **search action**

```
Controller: employee
| GET | /api/employees/create | Action: create |
| GET | /api/employees/search | Action: search |
| GET | /api/employees/${id}/edit | Action: edit |
| POST | /api/employees | Action: save |
| GET | /api/employees | Action: index |
| DELETE | /api/employees/${id} | Action: delete |
| PATCH | /api/employees/${id} | Action: patch |
| PUT | /api/employees/${id} | Action: update |
| GET | /api/employees/${id} | Action: show |
```

### Actual Behaviour

```
Controller: employee
| GET | /api/employees/create | Action: create |
| GET | /api/employees/${id}/edit | Action: edit |
| GET | /api/employees/${employeeId}/search | Action: search |
| POST | /api/employees | Action: save |
| GET | /api/employees | Action: index |
| DELETE | /api/employees/${id} | Action: delete |
| PATCH | /api/employees/${id} | Action: patch |
| PUT | /api/employees/${id} | Action: update |
| GET | /api/employees/${id} | Action: show |
```

If I avoid using group the result of using collection within resource is the expected

```
'/api/employees'(resources: 'employee') {
collection {
'/search'(controller: 'employee', action: 'search', method: 'GET')
}
}
```
For the search action I get the following result

`/api/employees/search`

### Environment Information

- **Operating System**: ubuntu 16.04
- **Grails Version:** Using grails version 3.3.1
- **JDK Version:** Using java version 8u144-zulu

### Example Application

https://github.com/ilmoralito/url-mapping-report-demo

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.