Skip to content

Commit

Permalink
Added support for Operation EXAMPLE value in ASP.NET Core Generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
knom committed Dec 12, 2017
1 parent 643ef64 commit b9048d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,20 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
}
}

if (operation.examples != null){
for (Map<String, String> example : operation.examples)
{
for (Map.Entry<String, String> entry : example.entrySet())
{
// Replace " with \", \r, \n with \\r, \\n
String val = entry.getValue().replace("\"", "\\\"")
.replace("\r","\\r")
.replace("\n","\\n");
entry.setValue(val);
}
}
}

processOperation(operation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ namespace {{packageName}}.Controllers
{{/dataType}}{{/responses}}
{{#returnType}}
string exampleJson = null;
{{#examples}}
exampleJson = "{{{example}}}";
{{/examples}}
{{#isListCollection}}{{>listReturn}}{{/isListCollection}}{{^isListCollection}}{{#isMapContainer}}{{>mapReturn}}{{/isMapContainer}}{{^isMapContainer}}{{>objectReturn}}{{/isMapContainer}}{{/isListCollection}}
{{!TODO: defaultResponse, examples, auth, consumes, produces, nickname, externalDocs, imports, security}}
//TODO: Change the data returned
Expand Down

0 comments on commit b9048d3

Please sign in to comment.