Contributions
Generate endpoint with parameter binding in C#
Hello, I currently have this OpenAPI yml: ...snipped from an endpoint description.... requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SubmitRequest' this moustache: public async Task<{{returnType}}> {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{#isPathParam}}{{#hasMore}},{{/hasMore}}{{/isPathParam}}{{^isPathParam}}{{#isQueryParam}}{{#hasMore}}, {{/hasMore}}{{/isQueryParam}}{{^isQueryParam}}{{#isBodyParam}}{{#hasMore}}, {{/hasMore}}{{/isBodyParam}}{{/isQueryParam}}{{/isPathParam}}{{/allParams}}) and it generates this endpoint: public async Task<ObjA> Post([FromBody]SubmitRequest submitRequest) What I need is to add the C# Bind keyword so it looks like this: public async Task<ObjA> Post([FromBody,Bind]SubmitRequest submitRequest) Reading here I see no way to do it with a yml directive. I've tried some moustache trickery with vendor extensions but documentation on moustache is very sparse and I'm not sure if I am doing something wrong or it just can't be done. If I do this in the YML: x-bindBody: $ref: '#/components/schemas/SubmitRequest' and this in moustache public async Task<{{returnType}}> {{operationId}}({{#vendorExtensions.x-bindBody}}[FromBody,Bind]{{/vendorExtensions.x-bindBody}}) this is what I get....very close but not quite there. public async Task<ObjA> Post([FromBody,Bind]) Any ideas?729Views0likes0Commentsnullable and default are not generating as expected in my model
Good Morning, I'm having difficulty with nullable: false not generating correctly. From everything I can see it is correct. I am wondering if this is applicable to my scenario. https://community.smartbear.com/t5/SwaggerHub/json-schema-validation-of-null-values/m-p/186450#M861 Here is the relevant snippet: isWithdrawalPaused: type: boolean nullable: false Which produces: [DataMember(Name="isWithdrawalPaused")] public bool? IsWithdrawalPaused { get; set; } For those not familiar with c# the bool? is a nullable and I want bool. I don't know where the breakdown is and so perhaps it is the engine we are using to interpret the swagger into C#? swagger-codegen-cli-2.3.0.jar Any suggestions would be greatly appreciated. TIA4KViews0likes1Comment