Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
DESIGNER-351: raml to swagger : Avoid create unused uriParameters inh…
Browse files Browse the repository at this point in the history
…erited from resource type
  • Loading branch information
Gaston Lodieu committed Feb 16, 2017
1 parent 50040db commit 2d22e92
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
11 changes: 7 additions & 4 deletions lib/importers/baseraml.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,15 @@ class RAMLImporter extends Importer {
return this._mapHeadersParameters(data, traits);
}

_mapURIParams(uriParams) {
_mapURIParams(uriParams, path) {
const pathParams = {type: 'object', properties: {}, required: []};

for (const i in uriParams) {
if (!uriParams.hasOwnProperty(i)) continue;
const key = uriParams[i];

if (!_.includes(path, key.name)) continue;

pathParams.properties[key.name] = {
type: key.type || 'string'
};
Expand Down Expand Up @@ -476,18 +478,19 @@ class RAMLImporter extends Importer {

_mapEndpoint(project, resource, baseURI, pathParams) {
let resultParams = JSON.parse(JSON.stringify(pathParams));
const path = baseURI + resource.relativeUri;
if (resource.uriParameters) {
if(_.isEmpty(resultParams))
resultParams = this._mapURIParams(resource.uriParameters);
resultParams = this._mapURIParams(resource.uriParameters, path);
else{
let newParams = this._mapURIParams(resource.uriParameters);
let newParams = this._mapURIParams(resource.uriParameters, path);
_.merge(resultParams.properties, newParams.properties);
resultParams.required = _.concat(resultParams.required, newParams.required);
}
}

const mResource = {
path: baseURI + resource.relativeUri,
path: path,
endpoints: [],
annotations: {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ paths:
in: path
required: true
type: string
- name: mediaTypeExtension
in: path
description: Media type
required: true
type: string
put:
operationId: PUT_identities-id-make_primary
description: |
Expand Down

0 comments on commit 2d22e92

Please sign in to comment.