Skip to content

Commit 185a7f0

Browse files
committed
Fixes #538
1 parent 99e26f2 commit 185a7f0

File tree

5 files changed

+58
-47
lines changed

5 files changed

+58
-47
lines changed

server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
<dependency>
228228
<groupId>org.springdoc</groupId>
229229
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
230-
<version>2.8.9</version>
230+
<version>2.8.14</version>
231231
</dependency>
232232
<dependency>
233233
<groupId>org.bouncycastle</groupId>

server/src/main/java/invite/api/DefaultErrorController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
4747
ErrorAttributeOptions.of(
4848
ErrorAttributeOptions.Include.EXCEPTION,
4949
ErrorAttributeOptions.Include.MESSAGE,
50+
ErrorAttributeOptions.Include.PATH,
51+
ErrorAttributeOptions.Include.ERROR,
5052
ErrorAttributeOptions.Include.BINDING_ERRORS)
5153
);
5254

server/src/main/java/invite/api/InvitationController.java

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -109,42 +109,46 @@ public InvitationController(MailBox mailBox,
109109

110110
@PostMapping("")
111111
@Operation(summary = "Invite member for existing Role",
112-
description = "Invite a member for an existing role. An invitation email will be sent. Do not forget to set guestRoleIncluded to true." +
113-
"At least one email must be either present in invites or invitations. When using the invitations you can also specify the " +
114-
"internalPlaceholderIdentifier, which will be used as the id in the SCIM POST to /User.",
112+
description = """
113+
Invite a member for an existing role. An invitation email will be sent. Do not forget to set guestRoleIncluded to true.
114+
At least one email must be either present in invites or invitations. When using the invitations you can also specify the
115+
internalPlaceholderIdentifier, which will be used as the id in the SCIM POST to /User.
116+
""",
115117
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
116118
required = true,
117119
content = {@Content(
118120
mediaType = "application/json",
119-
examples = {
120-
@ExampleObject(
121-
name = "Invitation example",
122-
summary = "Example invitation request",
123-
value = """
124-
{
125-
"intendedAuthority": "INVITER",
126-
"message": "Personal message included in the email",
127-
"language": "en",
128-
"guestRoleIncluded": true,
129-
"invites": [
130-
"admin@service.org"
131-
],
132-
"invitations": [{
133-
"email": "admin2@service.org"
134-
"internalPlaceholderIdentifier": "4EFF937F-EE78-4A54-9FD8-A214FD64D7E1",
135-
}],
136-
"roleIdentifiers": [
137-
99
138-
],
139-
"roleExpiryDate": 1760788376,
140-
"expiryDate": 1730461976
141-
}
142-
"""
143-
)})}
121+
schema = @Schema(implementation = InvitationRequest.class),
122+
examples = {@ExampleObject(value = """
123+
{
124+
"intendedAuthority": "INVITER",
125+
"message": "Personal message included in the email",
126+
"language": "en",
127+
"guestRoleIncluded": true,
128+
"invites": [
129+
"admin@service.org"
130+
],
131+
"invitesWithInternalPlaceholderIdentifiers": [
132+
{
133+
"email": "admin2@service.org",
134+
"internalPlaceholderIdentifier": "4EFF937F-EE78-4A54-9FD8-A214FD64D7E1"
135+
}
136+
],
137+
"roleIdentifiers": [
138+
99
139+
],
140+
"roleExpiryDate": 1760788376,
141+
"expiryDate": 1730461976
142+
}
143+
"""
144+
)}
145+
)}
144146
),
145147
responses = {
146148
@ApiResponse(responseCode = "201", description = "Created",
147-
content = {@Content(schema = @Schema(implementation = InvitationResponse.class),
149+
content = {@Content(
150+
mediaType = "application/json",
151+
schema = @Schema(implementation = InvitationResponse.class),
148152
examples = {@ExampleObject(value = """
149153
{
150154
"status": 201,
@@ -158,20 +162,25 @@ public InvitationController(MailBox mailBox,
158162
"""
159163
)})}),
160164
@ApiResponse(responseCode = "400", description = "BadRequest",
161-
content = {@Content(schema = @Schema(implementation = StatusResponse.class),
162-
examples = {@ExampleObject(value = """
163-
{
164-
"timestamp": 1717672263253,
165-
"status": 400,
166-
"error": "BadRequest",
167-
"exception": "access.exception.UserRestrictionException",
168-
"message": "No access to application",
169-
"path": "/api/internal/invite/invitations"
170-
}
171-
"""
172-
)})}),
165+
content = {@Content(
166+
mediaType = "application/json",
167+
schema = @Schema(implementation = StatusResponse.class),
168+
examples = {
169+
@ExampleObject(value = """
170+
{
171+
"timestamp": 1717672263253,
172+
"status": 400,
173+
"error": "BadRequest",
174+
"exception": "access.exception.UserRestrictionException",
175+
"message": "No access to application",
176+
"path": "/api/internal/invite/invitations"
177+
}
178+
"""
179+
)})}),
173180
@ApiResponse(responseCode = "404", description = "Role not found",
174-
content = {@Content(schema = @Schema(implementation = StatusResponse.class),
181+
content = {@Content(
182+
mediaType = "application/json",
183+
schema = @Schema(implementation = StatusResponse.class),
175184
examples = {@ExampleObject(value = """
176185
{
177186
"timestamp": 1717672263253,

server/src/main/java/invite/api/InvitationOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public ResponseEntity<InvitationResponse> sendInvitation(InvitationRequest invit
6666
invitationRequest.setRoleExpiryDate(Instant.now().plus(defaultExpiryDays, ChronoUnit.DAYS));
6767
}
6868
}
69-
List<Invite> invites = invitationRequest.getInvitations();
69+
List<Invite> invites = invitationRequest.getInvitesWithInternalPlaceholderIdentifiers();
7070
if (invites == null) {
7171
invites = new ArrayList<>();
7272
}

server/src/main/java/invite/model/InvitationRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class InvitationRequest implements Serializable {
3535

3636
private List<String> invites;
3737

38-
private List<Invite> invitations;
38+
private List<Invite> invitesWithInternalPlaceholderIdentifiers;
3939

4040
private List<Long> roleIdentifiers;
4141

@@ -47,8 +47,8 @@ public class InvitationRequest implements Serializable {
4747
private Instant expiryDate;
4848

4949
public void verify() {
50-
if (CollectionUtils.isEmpty(invitations) && CollectionUtils.isEmpty(invites)) {
51-
throw new InvalidInputException("Either at least one invitation or invite is required");
50+
if (CollectionUtils.isEmpty(invitesWithInternalPlaceholderIdentifiers) && CollectionUtils.isEmpty(invites)) {
51+
throw new InvalidInputException("Either at least one value for invitesWithInternalPlaceholderIdentifiers or invites is required");
5252
}
5353
}
5454
}

0 commit comments

Comments
 (0)