Skip to content

Commit c55727a

Browse files
committed
fix: smrepo/smservice: response body for post
1 parent a3f1727 commit c55727a

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

basyx.submodelrepository/basyx.submodelrepository-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositoryApiHTTPController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ public ResponseEntity<SubmodelElement> getSubmodelElementByPathSubmodelRepo(Base
178178
@Override
179179
public ResponseEntity<SubmodelElement> postSubmodelElementByPathSubmodelRepo(Base64UrlEncodedIdentifier submodelIdentifier, String idShortPath, @Valid SubmodelElement body, @Valid String level, @Valid String extent) {
180180
repository.createSubmodelElement(submodelIdentifier.getIdentifier(), idShortPath, body);
181-
return new ResponseEntity<SubmodelElement>(HttpStatus.CREATED);
181+
return new ResponseEntity<>(repository.getSubmodelElement(submodelIdentifier.getIdentifier(), idShortPath), HttpStatus.CREATED);
182182
}
183183

184184
@Override
185185
public ResponseEntity<SubmodelElement> postSubmodelElementSubmodelRepo(Base64UrlEncodedIdentifier submodelIdentifier, @Valid SubmodelElement body) {
186186
repository.createSubmodelElement(submodelIdentifier.getIdentifier(), body);
187-
return new ResponseEntity<SubmodelElement>(HttpStatus.CREATED);
187+
return new ResponseEntity<>(repository.getSubmodelElement(submodelIdentifier.getIdentifier(), body.getIdShort()), HttpStatus.CREATED);
188188
}
189189

190190
@Override

basyx.submodelservice/basyx.submodelservice-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceHTTPApiController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ public ResponseEntity<SubmodelElement> postSubmodelElement(@Parameter(in = Param
197197
@Parameter(in = ParameterIn.QUERY, description = "Determines the structural depth of the respective resource content", schema = @Schema(allowableValues = { "deep",
198198
"core" }, defaultValue = "deep")) @Valid @RequestParam(value = "level", required = false, defaultValue = "deep") String level) {
199199
service.createSubmodelElement(body);
200-
return new ResponseEntity<SubmodelElement>(HttpStatus.CREATED);
200+
return new ResponseEntity<>(service.getSubmodelElement(body.getIdShort()), HttpStatus.CREATED);
201201
}
202202

203203
@Override
204204
public ResponseEntity<SubmodelElement> postSubmodelElementByPath(
205205
@Parameter(in = ParameterIn.PATH, description = "IdShort path to the submodel element (dot-separated)", required = true, schema = @Schema()) @PathVariable("idShortPath") String idShortPath,
206206
@Parameter(in = ParameterIn.DEFAULT, description = "Requested submodel element", required = true, schema = @Schema()) @Valid @RequestBody SubmodelElement body) {
207207
service.createSubmodelElement(idShortPath, body);
208-
return new ResponseEntity<SubmodelElement>(HttpStatus.CREATED);
208+
return new ResponseEntity<>(service.getSubmodelElement(idShortPath), HttpStatus.CREATED);
209209
}
210210

211211
@Override

basyx.submodelservice/basyx.submodelservice-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceSubmodelElementsTestSuiteHTTP.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,8 @@ public void createSubmodelElement() throws FileNotFoundException, IOException, P
385385
String element = getJSONValueAsString("SubmodelElementNew.json");
386386
CloseableHttpResponse createdResponse = BaSyxHttpTestUtils.executePostOnURL(createSubmodelElementsURL(), element);
387387

388-
CloseableHttpResponse fetchedResponse = requestSubmodelElement("MaxRotationSpeedNew");
389388
assertEquals(HttpStatus.CREATED.value(), createdResponse.getCode());
390-
BaSyxHttpTestUtils.assertSameJSONContent(element, BaSyxHttpTestUtils.getResponseAsString(fetchedResponse));
389+
BaSyxHttpTestUtils.assertSameJSONContent(element, BaSyxHttpTestUtils.getResponseAsString(createdResponse));
391390
}
392391

393392
@Test

0 commit comments

Comments
 (0)