Skip to content

Commit

Permalink
fix: removing jsonpath dependency for ask-smapi-sdk(#624)
Browse files Browse the repository at this point in the history
Co-authored-by: kakha urigashvili <kakuri@amazon.com>
  • Loading branch information
kakhaUrigashvili and kakha urigashvili committed May 14, 2020
1 parent 32810f3 commit 19c3cc1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
21 changes: 11 additions & 10 deletions ask-smapi-sdk/lib/util/ModelIntrospector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
* permissions and limitations under the License.
*/

import { nodes, PathComponent } from 'jsonpath';

/**
* Introspects on the Skill Managament API (SMAPI) model.
*/
Expand Down Expand Up @@ -49,15 +47,18 @@ export class ModelIntrospector {
}

private processModel() : void {
const modelDefinitions : Array<{ path : PathComponent[]; value : any; }> = nodes(this.modelJson, '$["definitions"][*]');
this.definitions = new Map();
for (const definition of modelDefinitions) {
this.definitions.set(definition.path[definition.path.length - 1].toString(), definition.value);
}
const operationDefinitions : Array<{ path : PathComponent[]; value : any; }> = nodes(this.modelJson, '$["paths"][*][*]');
const modelDefinitions = this.modelJson.definitions;
this.definitions = new Map(Object.keys(modelDefinitions).map((key) => [key, modelDefinitions[key]]));

const operationDefinitions : any[] = [];
Object.keys(this.modelJson.paths).forEach((pathKey) => {
Object.keys(this.modelJson.paths[pathKey]).forEach((operationKey) => {
operationDefinitions.push(this.modelJson.paths[pathKey][operationKey]);
});
});

this.operations = new Map();
for (const operation of operationDefinitions) {
const operationDefinition = operation.value;
for (const operationDefinition of operationDefinitions) {
const apiOperationName = operationDefinition['x-operation-name'];
if (apiOperationName) {
const apiVersion = parseInt(apiOperationName.substring(apiOperationName.length - 1), 10);
Expand Down
3 changes: 1 addition & 2 deletions ask-smapi-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"SDK"
],
"dependencies": {
"ask-smapi-model": "^1.4.0",
"jsonpath": "^1.0.2"
"ask-smapi-model": "^1.4.0"
},
"devDependencies": {
"@types/chai": "^4.1.2",
Expand Down

0 comments on commit 19c3cc1

Please sign in to comment.