- Fixed parsing enum parameters in NancyModule
This commit is contained in:
Jakub Malek 2016-05-24 10:25:18 +02:00 committed by Jakub Malek
parent 57aa6d01d2
commit c653aeec0b
2 changed files with 4 additions and 3 deletions

View File

@ -8,14 +8,15 @@ using {{packageName}}.Utils;
namespace {{packageName}}.Modules namespace {{packageName}}.Modules
{ {
{{#operations}}{{#operation}}{{#allParams}}{{#isEnum}}{{>innerApiEnum}}{{/isEnum}}{{/allParams}}{{/operation}} public sealed class {{classname}}Module : NancyModule {{#operations}}{{#operation}}{{#allParams}}{{#isEnum}} {{>innerApiEnum}}{{/isEnum}}{{/allParams}}
{{/operation}} public sealed class {{classname}}Module : NancyModule
{ {
public {{classname}}Module({{classname}}Service service) public {{classname}}Module({{classname}}Service service)
:base("") :base("")
{ {{#operation}} { {{#operation}}
{{httpMethod}}["{{path}}"] = parameters => {{httpMethod}}["{{path}}"] = parameters =>
{ {
{{#allParams}}{{#isBodyParam}}var {{paramName}} = this.Bind<{{&dataType}}>();{{/isBodyParam}}{{^isBodyParam}}{{#isEnum}}{{>innerApiEnumName}}{{/isEnum}}{{^isEnum}}var{{/isEnum}} {{paramName}} = Parameters.ValueOf<{{&dataType}}>(parameters, "{{paramName}}");{{#hasMore}} {{#allParams}}{{#isBodyParam}}var {{paramName}} = this.Bind<{{&dataType}}>();{{/isBodyParam}}{{^isBodyParam}}{{#isEnum}}var {{paramName}} = Parameters.ValueOf<{{>innerApiEnumName}}>(parameters, "{{paramName}}");{{/isEnum}}{{^isEnum}}var {{paramName}} = Parameters.ValueOf<{{&dataType}}>(parameters, "{{paramName}}");{{/isEnum}}{{#hasMore}}
{{/hasMore}}{{/isBodyParam}}{{/allParams}}{{#allParams}}{{#required}} {{/hasMore}}{{/isBodyParam}}{{/allParams}}{{#allParams}}{{#required}}
Preconditions.IsNotNull({{paramName}}, "Required parameter: '{{paramName}}' is missing at '{{operationId}}'"); Preconditions.IsNotNull({{paramName}}, "Required parameter: '{{paramName}}' is missing at '{{operationId}}'");
{{/required}}{{/allParams}} {{/required}}{{/allParams}}

View File

@ -46,7 +46,7 @@ namespace {{packageName}}.Models
public bool Equals({{classname}} other) public bool Equals({{classname}} other)
{ {
return this.Equals((object) other); return Equals((object) other);
} }
public override int GetHashCode() public override int GetHashCode()