From 2aad6d681dcbea5564425648375f7ddca2080940 Mon Sep 17 00:00:00 2001 From: xg353y Date: Fri, 18 May 2018 17:59:06 +0200 Subject: Generate API documents Adding maven plugins to scan Clamp code automatically and generate swagger.json, html and pdf documents with the exposed Clamp API information. Issue-ID: CLAMP-169 Change-Id: Ia46cd2aa7000251b30c9eaaa040f1f8d9246af45 Signed-off-by: xg353y --- .../onap/clamp/clds/service/JaxrsApplication.java | 39 - src/main/resources/META-INF/resources/swagger.html | 2515 ++++++++++++++++++++ src/main/resources/asciidoc/swagger.adoc | 4 + 3 files changed, 2519 insertions(+), 39 deletions(-) create mode 100644 src/main/resources/META-INF/resources/swagger.html create mode 100644 src/main/resources/asciidoc/swagger.adoc (limited to 'src/main') diff --git a/src/main/java/org/onap/clamp/clds/service/JaxrsApplication.java b/src/main/java/org/onap/clamp/clds/service/JaxrsApplication.java index 3f9db33a8..56fbca8da 100644 --- a/src/main/java/org/onap/clamp/clds/service/JaxrsApplication.java +++ b/src/main/java/org/onap/clamp/clds/service/JaxrsApplication.java @@ -23,51 +23,12 @@ package org.onap.clamp.clds.service; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; - import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; -import org.springframework.core.type.filter.AnnotationTypeFilter; import org.springframework.stereotype.Component; - @Component @ApplicationPath("/restservices/clds/v1") public class JaxrsApplication extends Application { - private static final EELFLogger logger = EELFManager.getInstance().getLogger(JaxrsApplication.class); - private Function>> beanDefinitionToClass = b -> { - try { - return Optional.of(Class.forName(b.getBeanClassName())); - } catch (ClassNotFoundException e) { - logger.error("Could not get class annotated with @Path for swagger documentation generation", e); - return Optional.empty(); - } - }; - - @Override - public Set> getClasses() { - Set> resources = new HashSet<>(); - resources.add(JacksonObjectMapperProvider.class); - resources.add(io.swagger.v3.jaxrs2.integration.resources.OpenApiResource.class); - resources.addAll(scan()); - return resources; - } - - private List> scan() { - ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false); - scanner.addIncludeFilter(new AnnotationTypeFilter(javax.ws.rs.Path.class)); - return scanner.findCandidateComponents("org.onap.clamp.clds").stream().map(beanDefinitionToClass) - .filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()); - } } \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/swagger.html b/src/main/resources/META-INF/resources/swagger.html new file mode 100644 index 000000000..184a46a91 --- /dev/null +++ b/src/main/resources/META-INF/resources/swagger.html @@ -0,0 +1,2515 @@ + + + + + + + +clamp + + + + + +
+
+

1. Overview

+
+
+

1.1. Version information

+
+

Version : 2.0.0-SNAPSHOT

+
+
+
+

1.2. URI scheme

+
+

BasePath : /clamp/restservices/clds/v1
+Schemes : HTTP

+
+
+
+
+
+

2. Paths

+
+
+

2.1. PUT /clds/action/{action}/{modelName}

+
+

2.1.1. Description

+
+

REST service that saves and processes an action for a CLDS model by name.

+
+
+
+

2.1.2. Parameters

+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeNameSchema

Path

action
+required

string

Path

modelName
+required

string

Query

test
+required

string

Body

body
+required

CldsModel

+
+
+

2.1.3. Responses

+ +++++ + + + + + + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

CldsModel

500

Internal Server Error

CldsModel

+
+
+

2.1.4. Consumes

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+

2.1.5. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.2. GET /clds/cldsDetails

+
+

2.2.1. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

< CldsMonitoringDetails > array

+
+
+

2.2.2. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.3. GET /clds/cldsInfo

+
+

2.3.1. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

CldsInfo

+
+
+

2.3.2. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.4. POST /clds/dcae/event

+
+

2.4.1. Description

+
+

REST service that accepts events for a model.

+
+
+
+

2.4.2. Parameters

+ +++++ + + + + + + + + + + + + + + + + + + + +
TypeNameSchema

Query

test
+required

string

Body

body
+required

DcaeEvent

+
+
+

2.4.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

string

+
+
+

2.4.4. Consumes

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+

2.4.5. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.5. PUT /clds/deploy/{modelName}

+
+

2.5.1. Parameters

+ +++++ + + + + + + + + + + + + + + + + + + + +
TypeNameSchema

Path

modelName
+required

string

Body

body
+required

CldsModel

+
+
+

2.5.2. Responses

+ +++++ + + + + + + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

CldsModel

500

Internal Server Error

CldsModel

+
+
+

2.5.3. Consumes

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+

2.5.4. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.6. GET /clds/healthcheck

+
+

2.6.1. Description

+
+

REST service that retrieves clds healthcheck information.

+
+
+
+

2.6.2. Responses

+ +++++ + + + + + + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

CldsHealthCheck

500

Internal Server Error

CldsHealthCheck

+
+
+

2.6.3. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.7. GET /clds/model-names

+
+

2.7.1. Description

+
+

REST service that retrieves a list of CLDS model names.

+
+
+
+

2.7.2. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

< ValueItem > array

+
+
+

2.7.3. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.8. GET /clds/model/bpmn/{modelName}

+
+

2.8.1. Description

+
+

REST service that retrieves BPMN for a CLDS model name from the database.
+ This is subset of the json getModel. This is only expected to be used for
+ testing purposes, not by the UI.

+
+
+
+

2.8.2. Parameters

+ +++++ + + + + + + + + + + + + + + +
TypeNameSchema

Path

modelName
+required

string

+
+
+

2.8.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

string

+
+
+

2.8.4. Produces

+
+
    +
  • +

    text/xml

    +
  • +
+
+
+
+
+

2.9. GET /clds/model/image/{modelName}

+
+

2.9.1. Description

+
+

REST service that retrieves image for a CLDS model name from the
+ database. This is subset of the json getModel. This is only expected to
+ be used for testing purposes, not by the UI.

+
+
+
+

2.9.2. Parameters

+ +++++ + + + + + + + + + + + + + + +
TypeNameSchema

Path

modelName
+required

string

+
+
+

2.9.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

string

+
+
+

2.9.4. Produces

+
+
    +
  • +

    text/xml

    +
  • +
+
+
+
+
+

2.10. GET /clds/model/{modelName}

+
+

2.10.1. Description

+
+

REST service that retrieves a CLDS model by name from the database.

+
+
+
+

2.10.2. Parameters

+ +++++ + + + + + + + + + + + + + + +
TypeNameSchema

Path

modelName
+required

string

+
+
+

2.10.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

CldsModel

+
+
+

2.10.4. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.11. PUT /clds/model/{modelName}

+
+

2.11.1. Description

+
+

REST service that saves a CLDS model by name in the database.

+
+
+
+

2.11.2. Parameters

+ +++++ + + + + + + + + + + + + + + + + + + + +
TypeNameSchema

Path

modelName
+required

string

Body

body
+required

CldsModel

+
+
+

2.11.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

CldsModel

+
+
+

2.11.4. Consumes

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+

2.11.5. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.12. GET /clds/properties

+
+

2.12.1. Description

+
+

REST service that retrieves total properties required by UI

+
+
+
+

2.12.2. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

string

+
+
+

2.12.3. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.13. GET /clds/properties/{serviceInvariantUUID}

+
+

2.13.1. Description

+
+

REST service that retrieves total properties by using invariantUUID based
+ on refresh and non refresh

+
+
+
+

2.13.2. Parameters

+ ++++++ + + + + + + + + + + + + + + + + + + + + + + +
TypeNameSchemaDefault

Path

serviceInvariantUUID
+required

string

Query

refresh
+optional

boolean

"false"

+
+
+

2.13.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

string

+
+
+

2.13.4. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.14. GET /clds/sdc/services

+
+

2.14.1. Description

+
+

REST service that retrieves sdc services

+
+
+
+

2.14.2. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

string

+
+
+

2.14.3. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.15. PUT /clds/undeploy/{modelName}

+
+

2.15.1. Parameters

+ +++++ + + + + + + + + + + + + + + + + + + + +
TypeNameSchema

Path

modelName
+required

string

Body

body
+required

CldsModel

+
+
+

2.15.2. Responses

+ +++++ + + + + + + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

CldsModel

500

Internal Server Error

CldsModel

+
+
+

2.15.3. Consumes

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+

2.15.4. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.16. GET /cldsTempate/template-names

+
+

2.16.1. Description

+
+

REST service that retrieves a list of CLDS template names.

+
+
+
+

2.16.2. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

< ValueItem > array

+
+
+

2.16.3. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.17. GET /cldsTempate/template/bpmn/{templateName}

+
+

2.17.1. Description

+
+

REST service that retrieves BPMN for a CLDS template name from the
+ database. This is subset of the json getModel. This is only expected to
+ be used for testing purposes, not by the UI.

+
+
+
+

2.17.2. Parameters

+ +++++ + + + + + + + + + + + + + + +
TypeNameSchema

Path

templateName
+required

string

+
+
+

2.17.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

string

+
+
+

2.17.4. Produces

+
+
    +
  • +

    text/xml

    +
  • +
+
+
+
+
+

2.18. GET /cldsTempate/template/image/{templateName}

+
+

2.18.1. Description

+
+

REST service that retrieves image for a CLDS template name from the
+ database. This is subset of the json getModel. This is only expected to
+ be used for testing purposes, not by the UI.

+
+
+
+

2.18.2. Parameters

+ +++++ + + + + + + + + + + + + + + +
TypeNameSchema

Path

templateName
+required

string

+
+
+

2.18.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

string

+
+
+

2.18.4. Produces

+
+
    +
  • +

    text/xml

    +
  • +
+
+
+
+
+

2.19. GET /cldsTempate/template/{templateName}

+
+

2.19.1. Description

+
+

REST service that retrieves a CLDS template by name from the database.

+
+
+
+

2.19.2. Parameters

+ +++++ + + + + + + + + + + + + + + +
TypeNameSchema

Path

templateName
+required

string

+
+
+

2.19.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

CldsTemplate

+
+
+

2.19.4. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.20. PUT /cldsTempate/template/{templateName}

+
+

2.20.1. Description

+
+

REST service that saves a CLDS template by name in the database.

+
+
+
+

2.20.2. Parameters

+ +++++ + + + + + + + + + + + + + + + + + + + +
TypeNameSchema

Path

templateName
+required

string

Body

body
+required

CldsTemplate

+
+
+

2.20.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

CldsTemplate

+
+
+

2.20.4. Consumes

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+

2.20.5. Produces

+
+
    +
  • +

    application/json

    +
  • +
+
+
+
+
+

2.21. GET /user/{userName}

+
+

2.21.1. Description

+
+

REST service that returns the username.

+
+
+
+

2.21.2. Parameters

+ +++++ + + + + + + + + + + + + + + +
TypeNameSchema

Path

userName
+required

string

+
+
+

2.21.3. Responses

+ +++++ + + + + + + + + + + + + + + +
HTTP CodeDescriptionSchema

200

OK

string

+
+
+

2.21.4. Produces

+
+
    +
  • +

    text/plain

    +
  • +
+
+
+
+
+
+
+

3. Definitions

+
+
+

3.1. CldsEvent

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSchema

actionAndStateCd
+optional

boolean

actionCd
+optional

boolean

actionStateCd
+optional

boolean

id
+optional

string

processInstanceId
+optional

string

userid
+optional

string

+
+
+

3.2. CldsHealthCheck

+ ++++ + + + + + + + + + + + + + + + + + + + + +
NameSchema

description
+optional

string

healthCheckComponent
+optional

string

healthCheckStatus
+optional

string

+
+
+

3.3. CldsInfo

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSchema

cldsVersion
+optional

string

permissionReadCl
+optional

boolean

permissionReadTemplate
+optional

boolean

permissionUpdateCl
+optional

boolean

permissionUpdateTemplate
+optional

boolean

userName
+optional

string

+
+
+

3.4. CldsModel

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSchema

blueprintText
+optional

string

bpmnText
+optional

string

cldsModelInstanceList
+optional

< CldsModelInstance > array

controlName
+optional

string

controlNamePrefix
+optional

string

controlNameUuid
+optional

string

deploymentId
+optional

string

docText
+optional

string

event
+optional

CldsEvent

id
+optional

string

imageText
+optional

string

name
+optional

string

permittedActionCd
+optional

< string > array

propText
+optional

string

status
+optional

string

templateId
+optional

string

templateName
+optional

string

typeId
+optional

string

typeName
+optional

string

+
+
+

3.5. CldsModelInstance

+ ++++ + + + + + + + + + + + + + + + + + + + + +
NameSchema

location
+optional

string

modelInstanceId
+optional

string

vmName
+optional

string

+
+
+

3.6. CldsMonitoringDetails

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSchema

action
+optional

string

closeloopName
+optional

string

deploymentId
+optional

string

modelName
+optional

string

serviceTypeId
+optional

string

templateName
+optional

string

timestamp
+optional

string

userid
+optional

string

+
+
+

3.7. CldsTemplate

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSchema

bpmnId
+optional

string

bpmnText
+optional

string

bpmnUserid
+optional

string

controlNamePrefix
+optional

string

controlNameUuid
+optional

string

id
+optional

string

imageId
+optional

string

imageText
+optional

string

imageUserid
+optional

string

name
+optional

string

propId
+optional

string

propText
+optional

string

propUserid
+optional

string

userAuthorizedToUpdate
+optional

boolean

+
+
+

3.8. DcaeEvent

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSchema

artifactName
+optional

string

cldsActionCd
+optional

string

controlName
+optional

string

event
+optional

string

instances
+optional

< CldsModelInstance > array

resourceUUID
+optional

string

serviceUUID
+optional

string

+
+
+

3.9. ValueItem

+ ++++ + + + + + + + + + + + + +
NameSchema

value
+optional

string

+
+
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/asciidoc/swagger.adoc b/src/main/resources/asciidoc/swagger.adoc new file mode 100644 index 000000000..6896747fd --- /dev/null +++ b/src/main/resources/asciidoc/swagger.adoc @@ -0,0 +1,4 @@ +include::{generated}/overview.adoc[] +include::{generated}/paths.adoc[] +include::{generated}/security.adoc[] +include::{generated}/definitions.adoc[] \ No newline at end of file -- cgit 1.2.3-korg