Skip to content

C# code gen api path encoding problem #4977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
muralidharalladi opened this issue Mar 8, 2017 · 3 comments · Fixed by #5112
Closed

C# code gen api path encoding problem #4977

muralidharalladi opened this issue Mar 8, 2017 · 3 comments · Fixed by #5112

Comments

@muralidharalladi
Copy link

Description

we are getting "C# code gen api path encoding problem". We have composite key in model.
API Path in swagger json: /Resources(City='{City}',State='{State}')
API Path in c# gen Api file: /Resources(City&#x3D ;&#39 ;{City}&#39 ;,State&#x3D ;&#39 ;{State}&#39 ;)
= --> "&#x3D ;"
' --> "&#39 ;"

we are getting error in below code gen file
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/csharp/api.mustache
var localVarPath = "{{path}}";

Swagger-codegen version

Swagger Editor

Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues
Suggest a Fix

In java client codegen file showing correct but in C# client codegen file api path is encoding.
We want same behaviour as java client.

@wing328
Copy link
Contributor

wing328 commented Mar 13, 2017

@muralidharalladi please share the spec so that we can more easily reproduce the issue.

@wing328 wing328 added this to the v2.2.3 milestone Mar 13, 2017
@muralidharalladi
Copy link
Author

{
"swagger": "2.0",
"info": {
"description": "sample",
"version": "1.0.0",
"title": "Swagger sample",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "test.swagger.io",
"basePath": "/v2",
"tags": [
{
"name": "Resource",
"description": "Everything about your Pets"
}
],
"schemes": [
"http"
],
"paths": {
"/Resources(City='{City}',State='{State}')": {
"get": {
"tags": [
"Resource"
],
"summary": "Find Resource",
"description": "",
"operationId": "getResource",
"produces": [
"application/json"
],
"parameters": [
{
"name": "City",
"type": "string",
"in": "path",
"description": "key that needs to be passed",
"required": true
},
{
"name": "State",
"type": "string",
"in": "path",
"description": "key that needs to be passed",
"required": true
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Resource"
}
}
},
"400": {
"description": "Invalid status value"
}
}
}
}
},
"definitions": {
"Resource": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"username": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
},
"userStatus": {
"type": "integer",
"format": "int32",
"description": "User Status"
}
}
}
}
}
From swagger editor we used "Generate Client" using C#
In the source code src\IO.Swagger\Api\ResourceApi.cs file methods
GetResourceWithHttpInfo and GetResourceAsyncWithHttpInfo contains localVarPath variable.
Problem with this variable path encodeing.

@wing328
Copy link
Contributor

wing328 commented Mar 18, 2017

@muralidharalladi the issue should be fixed via #5112. Please pull the latest master to give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants