Skip to content

Commit a061187

Browse files
committed
v0.1.0 - inital version
1 parent bb8a414 commit a061187

File tree

1,895 files changed

+191962
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,895 files changed

+191962
-3
lines changed

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@
178178
APPENDIX: How to apply the Apache License to your work.
179179

180180
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
181+
boilerplate notice, with the fields enclosed by brackets "{}"
182182
replaced with your own identifying information. (Don't include
183183
the brackets!) The text should be enclosed in the appropriate
184184
comment syntax for the file format. We also recommend that a
185185
file or class name and description of purpose be included on the
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright {yyyy} {name of copyright owner}
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 174 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,175 @@
11
# OpenAPI
2-
Hackolade plugin for OpenAPI 3 API documentation
2+
Plugin to enable OpenAPI 3 as a target in Hackolade data modeling.
3+
4+
<div class="main-content">
5+
6+
<span class="rvts6">For each object in Hackolade, we've defined a set of standard properties that appear in the properties pane.  But it is possible that your company wants to define and track additional properties for models, containers, entities, and attributes.  Hackolade let's you do just that, by leveraging our plugin architecture (used also to integrate our modeling engine with all kinds of NoSQL document databases.)</span>
7+
8+
<span class="rvts6">
9+
</span>
10+
11+
## <span class="rvts0"><span class="rvts16">1) Download and enable plugin</span></span>
12+
13+
<span class="rvts6">To enable the custom properties capability, you first need to download a plugin for each database target for which you wish to add properties.  To do so, go to Help > DB Target Plugin Manager</span>
14+
15+
<img src="lib/Plugin-managermenu.png" width="25%" height="25%">
16+
17+
<span class="rvts6">
18+
</span>
19+
20+
<span class="rvts6">You may choose which plugin to install on your computer.</span>
21+
22+
<img src="lib/Plugin-manageravailablecustomprops.png" width="50%" height="50%">
23+
24+
<span class="rvts6">
25+
</span>
26+
27+
<span class="rvts6">This will result in the plugin appearing in the Installed tab of the plugin manager.</span>
28+
29+
<img src="lib/Plugin-Managerinstalledcustomprops.png" width="50%" height="50%">
30+
31+
<span class="rvts6">
32+
</span>
33+
34+
## <span class="rvts0"><span class="rvts16">2) Access plugin configuration files</span></span>
35+
36+
<span class="rvts6">You are now ready to add custom properties via editing of configuration files.  The plugin configurations files can be found by going to Help > Show plugin directory:</span>
37+
38+
<img src="lib/Plugin-Showplugindirectory.png" width="25%" height="25%">
39+
40+
<span class="rvts6">
41+
</span>
42+
43+
<span class="rvts6">For each custom properties plugin, you will find the a directory structure similar to this one:</span>
44+
45+
<img src="lib/Plugin-CustomPropdirectorystructure.png" width="25%" height="25%">
46+
47+
<span class="rvts18">Notes:</span><span class="rvts6"></span>
48+
49+
<span class="rvts6">i) do NOT make any changes to the package.json file!  Only the <object>LevelConfig.json files should be edited according to the specifications below.</span>
50+
51+
<span class="rvts6">ii) it is advised to keep a backup of the files before making changes, so you can revert back in case of errors.</span>
52+
53+
<span class="rvts6">iii) it is always necessary to restart the application after having saved changes before you can see these changes relected in the properties pane.</span>
54+
55+
<span class="rvts6">iv) for field-level definitions, since field types have different property lists, it may be necessary to define custom properties for multiple field types.</span>
56+
57+
## <span class="rvts0"><span class="rvts16">3) Levels</span></span>
58+
59+
<span class="rvts6">As a reminder, terminology differs between NoSQL database:</span>
60+
61+
<span class="rvts6">- container means: dbs in MongoDB, region in DynamoDB, bucket in Couchbase, collection in Cosmos DB</span>
62+
63+
<span class="rvts6">- entity means: collection in MongoDB, table in DynamoDB, document kind in Couchbase, and document type in Cosmos DB</span>
64+
65+
<span class="rvts6">- field means: field in MongoDB, Couchbase, and Cosmos DB. And attribute in DynamoDB</span>
66+
67+
<span class="rvts6">
68+
</span>
69+
70+
<span class="rvts6">You need to edit the corresponding <object>LevelConfig.json file to add custom properties.</span>
71+
72+
<span class="rvts6">
73+
</span>
74+
75+
## <span class="rvts0"><span class="rvts16">4) Lower tabs</span></span>
76+
77+
<span class="rvts6">For each level, the Hackolade properties pane may have one or more lower tab:</span>
78+
79+
<span class="rvts6">- MongoDB model lower tab:</span>
80+
81+
<img src="lib/MongoDBmodellowertab.png" width="50%" height="50%">
82+
83+
<span class="rvts6">- MongoDB dbs lower tab:</span>
84+
85+
<img src="lib/MongoDBdbslowertab.png" width="50%" height="50%">
86+
87+
<span class="rvts6">- MongoDB collection lower tab:</span>
88+
89+
<img src="lib/MongoDBcollectionlowertab.png" width="50%" height="50%">
90+
91+
<span class="rvts6">- MongoDB field lower tab:</span>
92+
93+
<img src="lib/MongoDBfieldlowertab.png" width="50%" height="50%">
94+
95+
<span class="rvts6">
96+
</span>
97+
98+
<span class="rvts6">If the level allows multiple tabs, you need to choose to which lower tab you want to add properties.</span>
99+
100+
<span class="rvts6">
101+
</span>
102+
103+
## <span class="rvts0"><span class="rvts16">5) Property types</span></span>
104+
105+
<span class="rvts6">The following controls are possible for user-defined properties:</span>
106+
107+
<img src="lib/Plugin-possiblepropertytypes.png" width="50%" height="50%">
108+
109+
* <span class="rvts6">simple text: one line of text</span>
110+
* <span class="rvts6">text area: popup for multi-line text entry</span>
111+
* <span class="rvts6">dropdown selection from a deined list of options</span>
112+
* <span class="rvts6">numeric-only field</span>
113+
* <span class="rvts6">checkbox: for true/false entry</span>
114+
<span class="rvts6">
115+
</span>
116+
117+
<span class="rvts6">
118+
</span>
119+
120+
## <span class="rvts0"><span class="rvts16">6) Property definition</span></span>
121+
122+
<span class="rvts6">Examples are provided in the comments section of each config file.  Here's an overview of the schema:</span>
123+
124+
<img src="lib/Plugin-propertyschema.png" width="50%" height="50%">
125+
126+
<span class="rvts6">Here's another view, consolidated:</span>
127+
128+
<img src="lib/Plugin-custompropsconsolidatedschema.png" width="50%" height="50%">
129+
130+
<span class="rvts6">- propertyName: mandatory, this is the property label that will appear in the Property Pane</span>
131+
132+
<span class="rvts6">- propertyKeyword: mandatory, this is the unique key for the property</span>
133+
134+
<span class="rvts6">- shouldValidate: optional, boolean true/false to define whether to validate the regular expression of the text input [default: false]</span>
135+
136+
<span class="rvts6">- propertyTooltip: optional, in the case of input types textarea and select, it is possible to display a tooltip  defined here</span>
137+
138+
<span class="rvts6">- propertyType: mandatory, this is the control definition, with possible values: text, details, select (i.e. dropdown), checkbox</span>
139+
140+
<span class="rvts6">- options: optional, this is the array of possible checkbox options</span>
141+
142+
<span class="rvts6">- template: optional, this is needed in the case of propertyType = details, to define a popup multi-line text.  Possible value: textarea</span>
143+
144+
<span class="rvts6">- valueType: optional, this is needed in to specify that a property is numberic only.  Possible values: numeric</span>
145+
146+
<span class="rvts6">
147+
</span>
148+
149+
## <span class="rvts0"><span class="rvts16">7) Share customization with team members</span></span>
150+
151+
<span class="rvts6">After making, saving and testing your changes, you should share them with everyone on your team to insure consistency. This is a 3-step process:</span>
152+
153+
<span class="rvts6">- return to the plugin directory via Help > Show plugin directory, and zip up the whole plugin directory where you made your changes;</span>
154+
155+
<span class="rvts6">- transfer this zip file to each team member using Hackolade;</span>
156+
157+
<span class="rvts6">- on each team member's computer, start Hackolade, go to Help > DB target plugin manager, then click the button 'Install from zip file', and choose the zip file file.</span>
158+
159+
<span class="rvts6">
160+
</span>
161+
162+
<span class="rvts6">For the changes to take effect on each computer, it is required to exit Hackolade and restart it.</span>
163+
164+
<span class="rvts6">
165+
</span>
166+
167+
168+
169+
</div>
170+
171+
</div>
172+
173+
</article>
174+
175+
</div>

central_pane/dtdAbbreviation.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"map": "{...}",
3+
"list": "[...]",
4+
"string": "{ABC}",
5+
"number": "{123}",
6+
"bool": "{0/1}",
7+
"bytes": "{BYTES}",
8+
"null": "{null}"
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"tabs": {
3+
"top": "path",
4+
"bottom": "name"
5+
},
6+
"order": {
7+
"nestedCollection": {
8+
"orderBy": "collectionName",
9+
"orderType": "ascending"
10+
}
11+
}
12+
13+
}

forward_engineering/api.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const yaml = require('js-yaml');
2+
const validationHelper = require('./helpers/validationHelper');
3+
const getInfo = require('./helpers/infoHelper');
4+
const { getPaths } = require('./helpers/pathHelper');
5+
const getComponents = require('./helpers/componentsHelpers');
6+
const commonHelper = require('./helpers/commonHelper');
7+
const { getServers } = require('./helpers/serversHelper');
8+
const getExtensions = require('./helpers/extensionsHelper');
9+
10+
module.exports = {
11+
generateModelScript(data, logger, cb) {
12+
try {
13+
const {
14+
dbVersion,
15+
externalDocs: modelExternalDocs,
16+
tags: modelTags,
17+
security: modelSecurity,
18+
servers: modelServers
19+
} = data.modelData[0];
20+
21+
const containersIdsFromCallbacks = commonHelper.getContainersIdsForCallbacks(data);
22+
23+
const info = getInfo(data.modelData[0]);
24+
const servers = getServers(modelServers);
25+
const paths = getPaths(data.containers, containersIdsFromCallbacks);
26+
const components = getComponents(data);
27+
const security = commonHelper.mapSecurity(modelSecurity);
28+
const tags = commonHelper.mapTags(modelTags);
29+
const externalDocs = commonHelper.mapExternalDocs(modelExternalDocs);
30+
31+
const openApiSchema = {
32+
openapi: dbVersion,
33+
info,
34+
servers,
35+
paths,
36+
components,
37+
security,
38+
tags,
39+
externalDocs
40+
};
41+
const extensions = getExtensions(data.modelData[0].scopesExtensions);
42+
43+
const resultSchema = Object.assign({}, openApiSchema, extensions);
44+
45+
switch (data.targetScriptOptions.format) {
46+
case 'yaml':
47+
cb(null, yaml.safeDump(resultSchema, { skipInvalid: true }));
48+
break;
49+
case 'json':
50+
default:
51+
cb(null, JSON.stringify(resultSchema, null, 2));
52+
}
53+
} catch (err) {
54+
logger.log('error', { error: err }, 'OpenAPI FE Error');
55+
cb(err);
56+
}
57+
},
58+
59+
validate(data, logger, cb) {
60+
const { script, targetScriptOptions } = data;
61+
62+
try {
63+
let parsedScript = {};
64+
65+
switch (targetScriptOptions.format) {
66+
case 'yaml':
67+
parsedScript = yaml.safeLoad(script);
68+
break;
69+
case 'json':
70+
default:
71+
parsedScript = JSON.parse(script);
72+
}
73+
74+
validationHelper.validate(parsedScript)
75+
.then((messages) => {
76+
cb(null, messages);
77+
})
78+
.catch(err => {
79+
cb(err.message);
80+
});
81+
} catch (e) {
82+
logger.log('error', { error: e }, 'OpenAPI Validation Error');
83+
84+
cb(e.message);
85+
}
86+
}
87+
};

forward_engineering/config.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extension": "json",
3+
"filterName": "application/json",
4+
"namePrefix": "OpenAPI Schema",
5+
"hasUpdateScript": false,
6+
"validation": true,
7+
"keepRequiredOnArrayItem": true,
8+
"splitView": {
9+
"swaggerUIView": true,
10+
"openedByDefault": true
11+
},
12+
"level": {
13+
"entity": false,
14+
"container": false,
15+
"model": true
16+
},
17+
"options": [
18+
{ "name": "JSON", "keyword": "json", "fileExtensions": [ {
19+
"label": "application/json", "value": "json"
20+
} ] },
21+
{ "name": "YAML", "keyword": "yaml", "fileExtensions": [ {
22+
"label": "application/yaml", "value": "yaml"
23+
} ] }
24+
]
25+
}

0 commit comments

Comments
 (0)