From 7a09fbb9eeb282cf89b88d5b38e75f483be15350 Mon Sep 17 00:00:00 2001 From: elinuxhenrik Date: Fri, 4 Dec 2020 16:51:19 +0100 Subject: [PATCH] Add generation of API yaml file Change-Id: I893e4ecb0c89b92d5c5cdecd2dc72a603d5340bb Issue-ID: NONRTRIC-354 Signed-off-by: elinuxhenrik --- .gitignore | 2 + docs/api-docs.rst | 6 +- docs/conf.py | 2 +- .../api}/ecs-api.json | 4 +- enrichment-coordinator-service/api/ecs-api.yaml | 827 +++++++++++++++++++++ enrichment-coordinator-service/pom.xml | 22 + .../org/oransc/enrichment/ApplicationTest.java | 2 +- 7 files changed, 858 insertions(+), 7 deletions(-) rename {docs/offeredapis/swagger => enrichment-coordinator-service/api}/ecs-api.json (99%) create mode 100644 enrichment-coordinator-service/api/ecs-api.yaml diff --git a/.gitignore b/.gitignore index 26c6731d..02f4f986 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ .tox docs/_build/ .DS_STORE +.swagger* +docs/offeredapis/swagger/README.md # Eclipse .checkstyle diff --git a/docs/api-docs.rst b/docs/api-docs.rst index ed0cc79a..0f179363 100644 --- a/docs/api-docs.rst +++ b/docs/api-docs.rst @@ -37,10 +37,10 @@ Enrichment Coordinator Service See `ECS API <./ecs-api.html>`_ for how to use the API. .. csv-table:: - :header: "API name", "|swagger-icon|" - :widths: 10,5 + :header: "API name", "|swagger-icon|", "|yaml-icon|" + :widths: 10,5,5 - "ECS API", ":download:`link <./offeredapis/swagger/ecs-api.json>`" + "ECS API", ":download:`link <../enrichment-coordinator-service/api/ecs-api.json>`", ":download:`link <../enrichment-coordinator-service/api/ecs-api.yaml>`" rAPP Catalogue diff --git a/docs/conf.py b/docs/conf.py index 09eeb378..85721c6a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,7 +24,7 @@ redoc = [ { 'name': 'ECS API', 'page': 'ecs-api', - 'spec': './offeredapis/swagger/ecs-api.json', + 'spec': '../enrichment-coordinator-service/api/ecs-api.json', 'embed': True, } ] diff --git a/docs/offeredapis/swagger/ecs-api.json b/enrichment-coordinator-service/api/ecs-api.json similarity index 99% rename from docs/offeredapis/swagger/ecs-api.json rename to enrichment-coordinator-service/api/ecs-api.json index 3684c0ee..a27be461 100644 --- a/docs/offeredapis/swagger/ecs-api.json +++ b/enrichment-coordinator-service/api/ecs-api.json @@ -508,7 +508,7 @@ "tags": ["A1-EI (enrichment information)"] }} }, - "host": "localhost:34053", + "host": "localhost:38585", "definitions": { "producer_ei_job_request": { "description": "The body of the EI producer callbacks for EI job creation and deletion", @@ -742,4 +742,4 @@ "description": "Status Controller" } ] -} +} \ No newline at end of file diff --git a/enrichment-coordinator-service/api/ecs-api.yaml b/enrichment-coordinator-service/api/ecs-api.yaml new file mode 100644 index 00000000..e317541f --- /dev/null +++ b/enrichment-coordinator-service/api/ecs-api.yaml @@ -0,0 +1,827 @@ +openapi: 3.0.1 +info: + title: Enrichment Data service + description: This page lists all the rest apis for the service. + version: "1.0" +servers: +- url: //localhost:38585/ +tags: +- name: A1-EI (enrichment information) + description: Consumer Controller +- name: Consumer Callbacks + description: Consumer Simulator Controller +- name: Enrichment Data Producer API + description: Producer Controller +- name: Producer Callbacks + description: Producer Simulator Controller +- name: Service status + description: Status Controller +paths: + /producer_simulator/ei_job: + post: + tags: + - Producer Callbacks + summary: Callback for EI job creation + operationId: jobCreatedCallbackUsingPOST + requestBody: + description: request + content: + application/json: + schema: + $ref: '#/components/schemas/producer_ei_job_request' + required: true + responses: + 200: + description: OK + content: {} + 201: + description: Created + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /A1-EI/v1/eitypes/{eiTypeId}: + get: + tags: + - A1-EI (enrichment information) + summary: Individual EI type + operationId: getEiTypeUsingGET + parameters: + - name: eiTypeId + in: path + description: eiTypeId + required: true + schema: + type: string + responses: + 200: + description: EI type + content: + application/json: + schema: + $ref: '#/components/schemas/EiTypeObject' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information type is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /consumer_simulator/eijobs/{eiJobId}/status: + post: + tags: + - Consumer Callbacks + summary: Callback for EI job status + operationId: jobStatusCallbackUsingPOST + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + requestBody: + description: status + content: + application/json: + schema: + $ref: '#/components/schemas/EiJobStatusObject' + required: true + responses: + 200: + description: OK + content: {} + 201: + description: Created + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /ei-producer/v1/eitypes: + get: + tags: + - Enrichment Data Producer API + summary: EI type identifiers + operationId: getEiTypeIdentifiersUsingGET_1 + responses: + 200: + description: EI type identifiers + content: + application/json: + schema: + type: array + items: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /A1-EI/v1/eitypes: + get: + tags: + - A1-EI (enrichment information) + summary: EI type identifiers + operationId: getEiTypeIdentifiersUsingGET + responses: + 200: + description: EI type identifiers + content: + application/json: + schema: + type: array + items: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /ei-producer/v1/eiproducers/{eiProducerId}/status: + get: + tags: + - Enrichment Data Producer API + summary: EI producer status + operationId: getEiProducerStatusUsingGET + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + responses: + 200: + description: EI jobs + content: + application/json: + schema: + $ref: '#/components/schemas/producer_status' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /producer_simulator/ei_job/{eiJobId}: + delete: + tags: + - Producer Callbacks + summary: Callback for EI job deletion + operationId: jobDeletedCallbackUsingDELETE + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + responses: + 200: + description: OK + content: {} + 204: + description: No Content + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + deprecated: false + /ei-producer/v1/eiproducers: + get: + tags: + - Enrichment Data Producer API + summary: EI producer identifiers + operationId: getEiProducerIdentifiersUsingGET + responses: + 200: + description: EI producer identifiers + content: + application/json: + schema: + type: array + items: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /ei-producer/v1/eitypes/{eiTypeId}: + get: + tags: + - Enrichment Data Producer API + summary: Individual EI type + operationId: getEiTypeUsingGET_1 + parameters: + - name: eiTypeId + in: path + description: eiTypeId + required: true + schema: + type: string + responses: + 200: + description: EI type + content: + application/json: + schema: + $ref: '#/components/schemas/producer_ei_type_info' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information type is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /status: + get: + tags: + - Service status + summary: Returns status and statistics of this service + operationId: getStatusUsingGET + responses: + 200: + description: Service is living + content: + application/json: + schema: + $ref: '#/components/schemas/status_info' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /A1-EI/v1/eijobs/{eiJobId}: + get: + tags: + - A1-EI (enrichment information) + summary: Individual EI job + operationId: getIndividualEiJobUsingGET + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + responses: + 200: + description: EI job + content: + application/json: + schema: + $ref: '#/components/schemas/EiJobObject' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information job is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + put: + tags: + - A1-EI (enrichment information) + summary: Individual EI job + operationId: putIndividualEiJobUsingPUT + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + requestBody: + description: eiJobObject + content: + application/json: + schema: + $ref: '#/components/schemas/EiJobObject' + required: true + responses: + 200: + description: Job updated + content: {} + 201: + description: Job created + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information type is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + delete: + tags: + - A1-EI (enrichment information) + summary: Individual EI job + operationId: deleteIndividualEiJobUsingDELETE + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + responses: + 200: + description: Not used + content: {} + 204: + description: Job deleted + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information job is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /ei-producer/v1/eiproducers/{eiProducerId}: + get: + tags: + - Enrichment Data Producer API + summary: Individual EI producer + operationId: getEiProducerUsingGET + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + responses: + 200: + description: EI jobs + content: + application/json: + schema: + $ref: '#/components/schemas/producer_registration_info' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + put: + tags: + - Enrichment Data Producer API + summary: Individual EI producer + operationId: putEiProducerUsingPUT + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + requestBody: + description: registrationInfo + content: + application/json: + schema: + $ref: '#/components/schemas/producer_registration_info' + required: true + responses: + 200: + description: Producer updated + content: {} + 201: + description: Producer created + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + delete: + tags: + - Enrichment Data Producer API + summary: Individual EI producer + operationId: deleteEiProducerUsingDELETE + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + responses: + 200: + description: Not used + content: {} + 204: + description: Producer deleted + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /producer_simulator/health_check: + get: + tags: + - Producer Callbacks + summary: Producer supervision + operationId: producerSupervisionUsingGET + responses: + 200: + description: OK + content: + application/json: + schema: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /ei-producer/v1/eiproducers/{eiProducerId}/eijobs: + get: + tags: + - Enrichment Data Producer API + summary: EI job definitions + description: EI job definitions for one EI producer + operationId: getEiProducerJobsUsingGET + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + responses: + 200: + description: EI jobs + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/producer_ei_job_request' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /A1-EI/v1/eijobs: + get: + tags: + - A1-EI (enrichment information) + summary: EI job identifiers + description: query for EI job identifiers + operationId: getEiJobIdsUsingGET + parameters: + - name: eiTypeId + in: query + description: selects EI jobs of matching EI type + allowEmptyValue: false + schema: + type: string + - name: owner + in: query + description: selects EI jobs for one EI job owner + allowEmptyValue: false + schema: + type: string + responses: + 200: + description: EI job identifiers + content: + application/json: + schema: + type: array + items: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information type is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /A1-EI/v1/eijobs/{eiJobId}/status: + get: + tags: + - A1-EI (enrichment information) + summary: EI job status + operationId: getEiJobStatusUsingGET + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + responses: + 200: + description: EI job status + content: + application/json: + schema: + $ref: '#/components/schemas/EiJobStatusObject' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information job is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false +components: + schemas: + producer_ei_job_request: + title: producer_ei_job_request + required: + - ei_job_identity + type: object + properties: + owner: + type: string + description: The owner of the job + ei_job_identity: + type: string + description: Idenitity of the EI job + ei_job_data: + type: object + properties: {} + description: Json for the job data + target_uri: + type: string + description: URI for the target of the EI + ei_type_identity: + type: string + description: Type idenitity for the job + description: The body of the EI producer callbacks for EI job creation and deletion + EiTypeObject: + title: EiTypeObject + type: object + description: Information for an EI type + producer_ei_type_registration_info: + title: producer_ei_type_registration_info + required: + - ei_type_identity + type: object + properties: + ei_type_identity: + type: string + description: EI type identity + ei_job_data_schema: + type: object + properties: {} + description: Json schema for the job data + description: Information for an EI type + status_info: + title: status_info + type: object + properties: + no_of_producers: + type: integer + description: Number of EI producers + format: int32 + no_of_jobs: + type: integer + description: Number of EI jobs + format: int32 + no_of_types: + type: integer + description: Number of EI types + format: int32 + status: + type: string + description: status text + Mono«ResponseEntity«object»»: + title: Mono«ResponseEntity«object»» + type: object + producer_ei_type_info: + title: producer_ei_type_info + type: object + properties: + ei_producer_ids: + type: array + description: Registered producers + items: + type: string + ei_job_data_schema: + type: object + properties: {} + description: Json schema for the job data + description: Information for an EI type + producer_registration_info: + title: producer_registration_info + required: + - ei_job_callback_url + - ei_producer_supervision_callback_url + - supported_ei_types + type: object + properties: + supported_ei_types: + type: array + description: Supported EI types + items: + $ref: '#/components/schemas/producer_ei_type_registration_info' + ei_producer_supervision_callback_url: + type: string + description: callback for producer supervision + ei_job_callback_url: + type: string + description: callback for EI job + description: Information for an EI producer + producer_status: + title: producer_status + required: + - operational_state + type: object + properties: + operational_state: + type: string + description: |- + Operational state, values: + ENABLED: TBD + DISABLED: TBD. + enum: + - ENABLED + - DISABLED + description: Status for an EI Producer + ProblemDetails: + title: ProblemDetails + type: object + properties: + detail: + type: string + description: A human-readable explanation specific to this occurrence of + the problem. + example: EI job type not found + status: + type: integer + description: The HTTP status code generated by the origin server for this + occurrence of the problem. + format: int32 + example: 404 + description: A problem detail to carry details in a HTTP response according + to RFC 7807 + Void: + title: Void + type: object + description: Void/empty + EiJobStatusObject: + title: EiJobStatusObject + required: + - eiJobStatus + type: object + properties: + eiJobStatus: + type: string + description: |- + values: + ENABLED: the A1-EI producer is able to deliver EI result for the EI job + DISABLED: the A1-EI producer is unable to deliver EI result for the EI job + enum: + - ENABLED + - DISABLED + description: Status for an EI job + EiJobObject: + title: EiJobObject + required: + - eiTypeId + - jobDefinition + - jobOwner + - jobResultUri + type: object + properties: + eiTypeId: + type: string + description: EI type Idenitifier of the EI job + jobResultUri: + type: string + description: The target URI of the EI data + jobOwner: + type: string + description: Identity of the owner of the job + jobStatusNotificationUri: + type: string + description: The target of EI job status notifications + jobDefinition: + type: object + properties: {} + description: EI type specific job data + description: Information for an Enrichment Information Job diff --git a/enrichment-coordinator-service/pom.xml b/enrichment-coordinator-service/pom.xml index d34c9a6b..2a653150 100644 --- a/enrichment-coordinator-service/pom.xml +++ b/enrichment-coordinator-service/pom.xml @@ -56,6 +56,7 @@ 3.8.0 2.12.2 1.24.3 + 3.0.11 0.30.0 1.1.11 2.1.1 @@ -280,6 +281,27 @@ + + io.swagger.codegen.v3 + swagger-codegen-maven-plugin + ${swagger-codegen-maven-plugin.version} + + + test + + generate + + + ${project.basedir}/api/ecs-api.json + openapi-yaml + ${project.basedir}/api + + ecs-api.yaml + + + + + io.fabric8 docker-maven-plugin diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java index c5ee82aa..51d0ee16 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java @@ -162,7 +162,7 @@ class ApplicationTest { assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); String indented = (new JSONObject(resp.getBody())).toString(4); - try (PrintStream out = new PrintStream(new FileOutputStream("../docs/offeredapis/swagger/ecs-api.json"))) { + try (PrintStream out = new PrintStream(new FileOutputStream("api/ecs-api.json"))) { out.print(indented); } } -- 2.16.6