<logback.version>1.4.14</logback.version>
<logstash.logback.encoder.version>6.6</logstash.logback.encoder.version>
<slf4j.api.version>2.0.9</slf4j.api.version>
+ <swagger.version>2.2.35</swagger.version>
</properties>
<profiles>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-jaxrs2-jakarta</artifactId>
+ <version>${swagger.version}</version>
+ </dependency>
</dependencies>
<build>
<plugins>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-maven-plugin-jakarta</artifactId>
+ <version>${swagger.version}</version>
+ <executions>
+ <execution>
+ <id>generate-openapi</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>resolve</goal>
+ </goals>
+ <configuration>
+ <attachSwaggerArtifact>false</attachSwaggerArtifact>
+ <outputPath>${project.build.directory}/generated-swagger-docs</outputPath>
+ <outputFileName>openapi</outputFileName>
+ <outputFormat>JSON</outputFormat>
+ <resourcePackages>
+ <resourcePackage>org.onap.aai.babel</resourcePackage>
+ </resourcePackages>
+ <prettyPrint>true</prettyPrint>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
<!-- end removable sonar config, note the additional exclusion for babel above -->
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
+import io.swagger.v3.oas.annotations.OpenAPIDefinition;
+import io.swagger.v3.oas.annotations.info.Info;
+
@SpringBootApplication
@ImportResource("classpath:babel-beans.xml")
@ComponentScan(basePackages = {
"org.onap.aai.aaf",
"org.onap.aai.babel"
})
+@OpenAPIDefinition(
+ info = @Info(
+ title = "ONAP AAI Babel APIs",
+ description = "Generates AAI model XML from SDC TOSCA artifacts",
+ version = "1.0.0"
+ )
+)
public class BabelApplication extends SpringBootServletInitializer {
private static ConfigurableApplicationContext context;
import org.onap.aai.auth.AAIAuthException;
import org.onap.aai.babel.service.data.BabelRequest;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.tags.Tag;
+
/** Generate artifacts from the specified request content */
@Path("/app")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@FunctionalInterface
+@Tag(name = "Babel Services", description = "APIs for generating artifacts from TOSCA models in AAI Babel")
public interface GenerateArtifactsController {
@POST
@Path("/generateArtifacts")
- Response generateArtifacts(BabelRequest babelRequest) throws AAIAuthException;
+ @Operation(summary = "Generate artifacts", description = "Takes a BabelRequest containing TOSCA service model artifacts and generates AAI-compatible artifacts.", responses = {
+ @ApiResponse(responseCode = "200", description = "Artifacts generated successfully", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Response.class))),
+ @ApiResponse(responseCode = "400", description = "Invalid request or malformed input"),
+ @ApiResponse(responseCode = "401", description = "Unauthorized (authentication failure)"),
+ @ApiResponse(responseCode = "500", description = "Internal server error during artifact generation")
+ })
+ Response generateArtifacts(
+ @RequestBody(required = true, description = "The BabelRequest containing TOSCA service model artifacts.", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = BabelRequest.class))) BabelRequest babelRequest)
+ throws AAIAuthException;
}
import jakarta.ws.rs.QueryParam;
import org.springframework.stereotype.Service;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+
/**
- * Information service for the micro-service. Return status details to the caller.
+ * Information service for the micro-service. Return status details to the
+ * caller.
*
* @exclude
*/
@Path("/core/core-service")
@Service
+@Tag(name = "Babel Info Service", description = "Provides uptime and status information for the Babel micro-service.")
public class InfoService {
private Clock clock = Clock.systemDefaultZone();
@GET
@Path("/info")
@Produces("text/plain")
+ @Operation(summary = "Get Babel service status", description = "Returns uptime, start time, and request count information for the Babel micro-service.")
public String getInfo(@DefaultValue("text") @QueryParam("format") String format) {
return "Status: Up\n" + statusReport(clock) + "\n";
}