Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ function enrichSchema(schema){
for(var path in schema.paths){

for(var method in schema.paths[path]){
var generatedCode = OpenAPISnippet.getEndpointSnippets(schema, path, method, targets);
schema.paths[path][method]["x-codeSamples"] = [];
for(var snippetIdx in generatedCode.snippets){
var snippet = generatedCode.snippets[snippetIdx];
schema.paths[path][method]["x-codeSamples"][snippetIdx] = { "lang": snippet.title, "source": snippet.content };
}

if (method.indexOf('x-') === 0) continue;
try {
var generatedCode = OpenAPISnippet.getEndpointSnippets(schema, path, method, targets);
schema.paths[path][method]["x-codeSamples"] = [];
for(var snippetIdx in generatedCode.snippets){
var snippet = generatedCode.snippets[snippetIdx];
schema.paths[path][method]["x-codeSamples"][snippetIdx] = { "lang": snippet.title, "source": snippet.content };
}
}
catch (err) {
console.error(`Error while processing "${method}" "${path}"\n`, err);
}
}
}
return schema;
Expand Down