Skip to content

Commit

Permalink
add description endpoint (#182)
Browse files Browse the repository at this point in the history
* add description endpoint
* add description integration test
  • Loading branch information
tbischoff2 authored Oct 17, 2024
1 parent dc420a2 commit 914e68a
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/source/api/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Please be aware, that HTTPS is used.
- api/v3.0/submodel-descriptors ![GET](https://img.shields.io/badge/GET-blue) ![POST](https://img.shields.io/badge/POST-brightgreen)
- api/v3.0/submodel-descriptors/{submodelIdentifier} ![GET](https://img.shields.io/badge/GET-blue) ![PUT](https://img.shields.io/badge/PUT-orange) ![DELETE](https://img.shields.io/badge/DELETE-red)

- Description Interface
- api/v3.0/description ![GET](https://img.shields.io/badge/GET-blue)

## Example

In the default configuration, the base URL for the API is e.g.:
Expand Down
1 change: 1 addition & 0 deletions docs/source/changelog/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**New Features & Major Changes**
- HTTP
- Added option to turn off SSL
- Added description endpoint

**Internal changes & bugfixes**
- General
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<properties>
<assertj.version>3.26.3</assertj.version>
<checkstyle.version>10.18.2</checkstyle.version>
<faaast.service.version>1.1.0</faaast.service.version>
<faaast.service.version>1.2.0-SNAPSHOT</faaast.service.version>
<h2.version>2.3.232</h2.version>
<hibernate.version>6.6.1.Final</hibernate.version>
<jackson.version>2.18.0</jackson.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige
* Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten
* Forschung e.V.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.fraunhofer.iosb.ilt.faaast.registry.service;

import de.fraunhofer.iosb.ilt.faaast.service.model.ServiceDescription;
import de.fraunhofer.iosb.ilt.faaast.service.model.ServiceSpecificationProfile;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
* REST controller for the description.
*/
@RestController
@RequestMapping("/api/v3.0/description")
public class DescriptionController {

/**
* Returns a description object containing the capabilities and supported features of the server.
*
* @return The description object.
*/
@GetMapping
public ServiceDescription getDescription() {
return ServiceDescription.builder()
.profile(ServiceSpecificationProfile.AAS_REGISTRY_FULL)
.profile(ServiceSpecificationProfile.SUBMODEL_REGISTRY_FULL)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import de.fraunhofer.iosb.ilt.faaast.service.dataformat.json.mixins.PageMixin;
import de.fraunhofer.iosb.ilt.faaast.service.dataformat.json.mixins.ServiceSpecificationProfileMixin;
import de.fraunhofer.iosb.ilt.faaast.service.model.ServiceSpecificationProfile;
import de.fraunhofer.iosb.ilt.faaast.service.model.api.paging.Page;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.deserialization.EnumDeserializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.serialization.EnumSerializer;
Expand Down Expand Up @@ -127,6 +129,7 @@ public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
.mixIn(Extension.class, ExtensionMixin.class)
.mixIn(Key.class, KeyMixin.class)
.mixIn(Reference.class, ReferenceMixin.class)
.mixIn(ServiceSpecificationProfile.class, ServiceSpecificationProfileMixin.class)
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.featuresToEnable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID)
.dateFormat(new StdDateFormat().withColonInTimeZone(true));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige
* Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten
* Forschung e.V.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.fraunhofer.iosb.ilt.faaast.registry.service;

import de.fraunhofer.iosb.ilt.faaast.service.model.ServiceDescription;
import de.fraunhofer.iosb.ilt.faaast.service.model.ServiceSpecificationProfile;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;


@RunWith(SpringRunner.class)
@SpringBootTest(classes = App.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestPropertySource(locations = "classpath:application-integrationtest.properties")
public class DescriptionControllerIT {

@LocalServerPort
private int port;

@Autowired
private TestRestTemplate restTemplate;

@Test
public void testDescription() {
ResponseEntity<ServiceDescription> response = restTemplate.exchange(createURLWithPort(""), HttpMethod.GET, null, ServiceDescription.class);
Assert.assertNotNull(response);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
Assert.assertNotNull(response.getBody());
ServiceDescription expected = ServiceDescription.builder()
.profile(ServiceSpecificationProfile.AAS_REGISTRY_FULL)
.profile(ServiceSpecificationProfile.SUBMODEL_REGISTRY_FULL)
.build();
Assert.assertEquals(expected, response.getBody());
}


private String createURLWithPort(String uri) {
return "http://localhost:" + port + "/api/v3.0/description" + uri;
}
}

0 comments on commit 914e68a

Please sign in to comment.