Skip to content

Commit 7a682a3

Browse files
authored
Feature/generate open api spec (#19)
1 parent d0bc8a4 commit 7a682a3

26 files changed

+1348
-452
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
~ Copyright (c) 2022 Robert Bosch Manufacturing Solutions GmbH
3+
~
4+
~ See the AUTHORS file(s) distributed with this work for
5+
~ additional information regarding authorship.
6+
~
7+
~ This Source Code Form is subject to the terms of the Mozilla Public
8+
~ License, v. 2.0. If a copy of the MPL was not distributed with this
9+
~ file, You can obtain one at https://mozilla.org/MPL/2.0/.
10+
~
11+
~ SPDX-License-Identifier: MPL-2.0
12+
-->
13+
14+
<!doctype html>
15+
<html lang="en">
16+
<head>
17+
<title>Test Documentation</title>
18+
</head>
19+
<body></body>
20+
</html>
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"openapi": "3.0.3",
3+
"info": {
4+
"title": "AspectDefault",
5+
"version": "v1"
6+
},
7+
"servers": [
8+
{
9+
"url": "https://example.com/api/v1",
10+
"variables": {
11+
"api-version": {
12+
"default": "v1"
13+
}
14+
}
15+
}
16+
],
17+
"paths": {
18+
"/{tenant-id}/aspect-default": {
19+
"get": {
20+
"tags": [
21+
"AspectDefault"
22+
],
23+
"operationId": "getAspectDefault",
24+
"parameters": [
25+
{
26+
"name": "tenant-id",
27+
"in": "path",
28+
"description": "The ID of the tenant owning the requested Twin.",
29+
"required": true,
30+
"schema": {
31+
"type": "string",
32+
"format": "uuid"
33+
}
34+
}
35+
],
36+
"responses": {
37+
"200": {
38+
"$ref": "#/components/responses/AspectDefault"
39+
},
40+
"401": {
41+
"$ref": "#/components/responses/ClientError"
42+
},
43+
"402": {
44+
"$ref": "#/components/responses/Unauthorized"
45+
},
46+
"403": {
47+
"$ref": "#/components/responses/Forbidden"
48+
},
49+
"404": {
50+
"$ref": "#/components/responses/NotFoundError"
51+
}
52+
}
53+
}
54+
}
55+
},
56+
"components": {
57+
"schemas": {
58+
"ErrorResponse": {
59+
"type": "object",
60+
"required": [
61+
"error"
62+
],
63+
"properties": {
64+
"error": {
65+
"$ref": "#/components/schemas/Error"
66+
}
67+
}
68+
},
69+
"Error": {
70+
"type": "object",
71+
"required": [
72+
"details"
73+
],
74+
"properties": {
75+
"message": {
76+
"type": "string",
77+
"minLength": 1
78+
},
79+
"path": {
80+
"type": "string",
81+
"minLength": 1
82+
},
83+
"details": {
84+
"type": "object",
85+
"minLength": 1,
86+
"additionalProperties": {
87+
"type": "object"
88+
}
89+
},
90+
"code": {
91+
"type": "string",
92+
"nullable": true
93+
}
94+
}
95+
},
96+
"urn_bamm_io.openmanufacturing.digitaltwin_1.0.0_Characteristic1": {
97+
"type": "string"
98+
},
99+
"AspectDefault": {
100+
"type": "object",
101+
"properties": {
102+
"property1": {
103+
"$ref": "#/components/schemas/urn_bamm_io.openmanufacturing.digitaltwin_1.0.0_Characteristic1"
104+
}
105+
},
106+
"required": [
107+
"property1"
108+
]
109+
}
110+
},
111+
"responses": {
112+
"Unauthorized": {
113+
"description": "The requesting user or client is not authenticated."
114+
},
115+
"Forbidden": {
116+
"description": "The requesting user or client is not authorized to access resources for the given tenant."
117+
},
118+
"NotFoundError": {
119+
"description": "The requested Twin has not been found."
120+
},
121+
"ClientError": {
122+
"description": "Payload or user input is invalid. See error details in the payload for more.",
123+
"content": {
124+
"application/json": {
125+
"schema": {
126+
"$ref": "#/components/schemas/ErrorResponse"
127+
}
128+
}
129+
}
130+
},
131+
"AspectDefault": {
132+
"content": {
133+
"application/json": {
134+
"schema": {
135+
"$ref": "#/components/schemas/AspectDefault"
136+
}
137+
}
138+
},
139+
"description": "The request was successful."
140+
}
141+
},
142+
"requestBodies": {
143+
"AspectDefault": {
144+
"content": {
145+
"application/json": {
146+
"schema": {
147+
"$ref": "#/components/schemas/AspectDefault"
148+
}
149+
}
150+
}
151+
}
152+
}
153+
}
154+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#
2+
# Copyright (c) 2022 Robert Bosch Manufacturing Solutions GmbH
3+
#
4+
# See the AUTHORS file(s) distributed with this work for
5+
# additional information regarding authorship.
6+
#
7+
# This Source Code Form is subject to the terms of the Mozilla Public
8+
# License, v. 2.0. If a copy of the MPL was not distributed with this
9+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
10+
#
11+
# SPDX-License-Identifier: MPL-2.0
12+
13+
---
14+
openapi: 3.0.3
15+
info:
16+
title: AspectDefault
17+
version: v1
18+
servers:
19+
- url: https://example.com/api/v1
20+
variables:
21+
api-version:
22+
default: v1
23+
paths:
24+
/{tenant-id}/aspect-default:
25+
get:
26+
tags:
27+
- AspectDefault
28+
operationId: getAspectDefault
29+
parameters:
30+
- name: tenant-id
31+
in: path
32+
description: The ID of the tenant owning the requested Twin.
33+
required: true
34+
schema:
35+
type: string
36+
format: uuid
37+
responses:
38+
"200":
39+
$ref: '#/components/responses/AspectDefault'
40+
"401":
41+
$ref: '#/components/responses/ClientError'
42+
"402":
43+
$ref: '#/components/responses/Unauthorized'
44+
"403":
45+
$ref: '#/components/responses/Forbidden'
46+
"404":
47+
$ref: '#/components/responses/NotFoundError'
48+
components:
49+
schemas:
50+
ErrorResponse:
51+
type: object
52+
required:
53+
- error
54+
properties:
55+
error:
56+
$ref: '#/components/schemas/Error'
57+
Error:
58+
type: object
59+
required:
60+
- details
61+
properties:
62+
message:
63+
type: string
64+
minLength: 1
65+
path:
66+
type: string
67+
minLength: 1
68+
details:
69+
type: object
70+
minLength: 1
71+
additionalProperties:
72+
type: object
73+
code:
74+
type: string
75+
nullable: true
76+
urn_bamm_io.openmanufacturing.digitaltwin_1.0.0_Characteristic1:
77+
type: string
78+
AspectDefault:
79+
type: object
80+
properties:
81+
property1:
82+
$ref: '#/components/schemas/urn_bamm_io.openmanufacturing.digitaltwin_1.0.0_Characteristic1'
83+
required:
84+
- property1
85+
responses:
86+
Unauthorized:
87+
description: The requesting user or client is not authenticated.
88+
Forbidden:
89+
description: The requesting user or client is not authorized to access resources
90+
for the given tenant.
91+
NotFoundError:
92+
description: The requested Twin has not been found.
93+
ClientError:
94+
description: Payload or user input is invalid. See error details in the payload
95+
for more.
96+
content:
97+
application/json:
98+
schema:
99+
$ref: '#/components/schemas/ErrorResponse'
100+
AspectDefault:
101+
content:
102+
application/json:
103+
schema:
104+
$ref: '#/components/schemas/AspectDefault'
105+
description: The request was successful.
106+
requestBodies:
107+
AspectDefault:
108+
content:
109+
application/json:
110+
schema:
111+
$ref: '#/components/schemas/AspectDefault'
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2022 Robert Bosch Manufacturing Solutions GmbH
3+
*
4+
* See the AUTHORS file(s) distributed with this work for
5+
* additional information regarding authorship.
6+
*
7+
* This Source Code Form is subject to the terms of the Mozilla Public
8+
* License, v. 2.0. If a copy of the MPL was not distributed with this
9+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
10+
*
11+
* SPDX-License-Identifier: MPL-2.0
12+
*/
13+
14+
/// <reference types="Cypress" />
15+
16+
import {
17+
GENERATION_tbDownloadDoc,
18+
GENERATION_tbGenerateOpenApiButton,
19+
GENERATION_tbOutputButton,
20+
SELECTOR_tbGenerateDocumentButton,
21+
SELECTOR_tbOpenApiButton,
22+
SELECTOR_tbPrintButton,
23+
} from '../../support/constants';
24+
25+
describe('Test generation and download from valid Aspect Model', () => {
26+
it('Can generate valid JSON Open Api Specification', () => {
27+
cy.intercept('POST', 'http://localhost:9091/ame/api/models/validate', {fixture: 'model-validation-response.json'});
28+
cy.intercept(
29+
'POST',
30+
'http://localhost:9091/ame/api/generate/open-api-spec?output=json&baseUrl=https://example.com&includeQueryApi=false&pagingOption=NO_PAGING',
31+
{fixture: 'valid-open-api.json'}
32+
);
33+
cy.visitDefault();
34+
cy.startModelling()
35+
.then(() => cy.get(SELECTOR_tbGenerateDocumentButton).click({force: true}))
36+
.then(() => cy.get(SELECTOR_tbOpenApiButton).click({force: true}))
37+
.then(() => cy.get(GENERATION_tbGenerateOpenApiButton).click({force: true}))
38+
.then(() => cy.readFile('cypress/downloads/AspectDefault-open-api.json').should('exist'));
39+
});
40+
41+
it('Can generate and download valid YAML Open Api Specification', () => {
42+
cy.intercept('POST', 'http://localhost:9091/ame/api/models/validate', {fixture: 'model-validation-response.json'});
43+
cy.intercept(
44+
'POST',
45+
'http://localhost:9091/ame/api/generate/open-api-spec?output=yaml&baseUrl=https://example.com&includeQueryApi=false&pagingOption=NO_PAGING',
46+
{fixture: 'valid-open-api.yaml'}
47+
);
48+
49+
cy.visitDefault();
50+
cy.startModelling()
51+
.then(() => cy.get(SELECTOR_tbGenerateDocumentButton).click({force: true}))
52+
.then(() => cy.get(SELECTOR_tbOpenApiButton).click({force: true}))
53+
.then(() => cy.get(GENERATION_tbOutputButton).select('YAML'))
54+
.then(() => cy.get(GENERATION_tbGenerateOpenApiButton).click({force: true}))
55+
.then(() => cy.readFile('cypress/downloads/AspectDefault-open-api.yaml').should('exist'));
56+
});
57+
58+
it('Can generate and download valid Aspect Model documentation', () => {
59+
cy.intercept('POST', 'http://localhost:9091/ame/api/models/validate', {fixture: 'model-validation-response.json'});
60+
cy.intercept('POST', 'http://localhost:9091/ame/api/generate/documentation', {fixture: 'valid-documentation.html'});
61+
cy.visitDefault();
62+
cy.startModelling()
63+
.then(() => cy.get(SELECTOR_tbGenerateDocumentButton).click({force: true}))
64+
.then(() => cy.get(SELECTOR_tbPrintButton).click({force: true}))
65+
.then(() => cy.get(GENERATION_tbDownloadDoc).click({force: true}))
66+
.then(() => cy.readFile('cypress/downloads/AspectDefault-documentation.html').should('exist'));
67+
});
68+
});

core/apps/ame-e2e/src/integration/editor/loading-screen.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@
1414
/// <reference types="Cypress" />
1515

1616
import {
17+
GENERATION_tbOpenDoc,
1718
SELECTOR_dialogDefaultAspectButton,
1819
SELECTOR_dialogStartButton,
1920
SELECTOR_loadingCloseButton,
2021
SELECTOR_modalsDropdown,
22+
SELECTOR_tbGenerateDocumentButton,
2123
SELECTOR_tbLoadButton,
2224
SELECTOR_tbPrintButton,
2325
SELECTOR_tbValidateButton,
2426
} from '../../support/constants';
2527

2628
describe('Test loading screen', () => {
2729
it('can cancel loading model', () => {
28-
cy.intercept('POST', 'http://localhost:9091/ame/api/models/validate', {fixture: 'model-validation-response.json', delay: 5000});
30+
cy.intercept('POST', 'http://localhost:9091/ame/api/models/validate', {
31+
fixture: 'model-validation-response.json',
32+
delay: 5000,
33+
});
2934
cy.visitDefault();
3035
cy.get(SELECTOR_tbLoadButton)
3136
.click({force: true})
@@ -46,8 +51,11 @@ describe('Test loading screen', () => {
4651
});
4752

4853
it('can cancel generate html documentation', () => {
49-
cy.get(SELECTOR_tbPrintButton)
54+
cy.intercept('POST', 'http://localhost:9091/ame/api/models/validate', {fixture: 'model-validation-response.json'});
55+
cy.get(SELECTOR_tbGenerateDocumentButton)
5056
.click({force: true})
57+
.then(() => cy.get(SELECTOR_tbPrintButton).click({force: true}))
58+
.then(() => cy.get(GENERATION_tbOpenDoc).click({force: true}))
5159
.then(() => cy.get(SELECTOR_loadingCloseButton).click({force: true}))
5260
.then(() => cy.get('.cdk-overlay-container').should('not.be.visible', 8000));
5361
});

0 commit comments

Comments
 (0)