- Implemented OpenAPI definition of APIs for graphadmin module so that all Web Service requests and responses detailed specification will be specified
Issue-ID: AAI-4154
Change-Id: I55611f05dea3f95e18c5d82cc7e06143637d081c
Signed-off-by: atul.m.singh <atul.m.singh@accenture.com>
<parent>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-parent</artifactId>
- <version>1.16.0-SNAPSHOT</version>
+ <version>1.16.0</version>
</parent>
<groupId>org.onap.aai.graphadmin</groupId>
<artifactId>aai-graphadmin</artifactId>
<docker.push.registry>localhost:5000</docker.push.registry>
<aai.docker.version>1.0.0</aai.docker.version>
<aai.schema.service.version>1.12.7</aai.schema.service.version>
- <aai.common.version>1.16.0-SNAPSHOT</aai.common.version>
+ <aai.common.version>1.16.0</aai.common.version>
<aai.build.directory>${project.build.directory}/${project.artifactId}-${project.version}-build/
</aai.build.directory>
<aai.docker.namespace>onap</aai.docker.namespace>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.springdoc</groupId>
+ <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
+ <version>2.0.2</version>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
@Bean
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception{
httpSecurity.csrf(csrf -> csrf.disable())
- .authorizeHttpRequests(requests -> requests
- .requestMatchers(antMatcher("/util/echo"), antMatcher("/actuator/**"))
- .permitAll()
- .anyRequest()
- .authenticated())
- .httpBasic();
+ .authorizeHttpRequests(requests -> requests
+ .requestMatchers(antMatcher("/util/echo"), antMatcher("/actuator/**"), antMatcher("/graphadmin-api-docs/**"), antMatcher("/swagger-ui/**"), antMatcher("/swagger-ui.html"), antMatcher("/swagger-ui/index.html"))
+ .permitAll()
+ .anyRequest()
+ .authenticated())
+ .httpBasic();
return httpSecurity.build();
}
@Bean
InMemoryUserDetailsManager userDetailsService(AuthProperties userProperties) {
UserDetails[] users = userProperties.getUsers().stream()
- .map(user -> User.withDefaultPasswordEncoder()
- .username(user.getUsername())
- .password(user.getPassword())
- .roles("someRole")
- .build())
- .toArray(UserDetails[]::new);
+ .map(user -> User.withDefaultPasswordEncoder()
+ .username(user.getUsername())
+ .password(user.getPassword())
+ .roles("someRole")
+ .build())
+ .toArray(UserDetails[]::new);
return new InMemoryUserDetailsManager(users);
}
}
+
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.config;
+
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Contact;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.License;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class SwaggerConfig {
+
+ @Bean
+ public OpenAPI customOpenAPI() {
+ return new OpenAPI()
+ .info(new Info()
+ .title("Graphadmin API - Schema Job Status")
+ .description("This API provides operations related to the schema job status for Graphadmin. " +
+ "It allows users to check if the schema has been initialized and other related tasks.")
+ .version("v1.0"));
+ }
+
+}
\ No newline at end of file
aai.basic-auth.enabled=true
aai.basic-auth.users[0].username=AAI
aai.basic-auth.users[0].password=AAI
+
+# Configure the path for Swagger UI
+springdoc.swagger-ui.path=/index.html
+# Configure the path for API Docs
+springdoc.api-docs.path=/graphadmin-api-docs
\ No newline at end of file
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.config;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.web.servlet.MockMvc;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+@SpringBootTest
+@AutoConfigureMockMvc
+public class SwaggerConfigTest {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @Test
+ public void testSwaggerUiPageLoads() throws Exception {
+ mockMvc.perform(get("/swagger-ui/index.html"))
+ .andExpect(status().isOk()); // Should now be 200 if permitted
+ }
+
+ @Test
+ public void testOpenApiDocsAvailable() throws Exception {
+ mockMvc.perform(get("/graphadmin-api-docs"))
+ .andExpect(status().isOk())
+ .andExpect(content().contentType("application/json"));
+ }
+}
+
\ No newline at end of file