Skip to content
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

Not showing status code 201,400,403,404 on swagger ui in .Net #1194

Closed
jitsingh89 opened this issue Nov 24, 2017 · 2 comments
Closed

Not showing status code 201,400,403,404 on swagger ui in .Net #1194

jitsingh89 opened this issue Nov 24, 2017 · 2 comments

Comments

@jitsingh89
Copy link

jitsingh89 commented Nov 24, 2017

I am not able to show status code 201,400,500,404 etc on swagger ui page Like (Response class (Status 200). It's always showing "Status 200". I have to show status code for created 201,Forbidden 403, BadRequest 400. I have also used swashbuckle.example dll.

This is my class
public class EmployeeExample: IExamplesProvider
{
public object GetExamples()
{
return new Employee(){
ID=0,
Name="Jitu",
City="Noida"
}
}

This is my method in controller:-

[HttpPost
[SwaggerResponse(HttpStatusCode.Creted, Type = typeof(IEnumerable))]
public HttpResponseMessage Get(string lang)
{
Return Request,CreateResponse(HttpStatusCode.Created, objectyofresponse);
}

I want to shwo like this.
222

is the below issue closed ?
swagger-api/swagger-ui#1117
mattfrear/Swashbuckle.AspNetCore.Filters#9

Please let me know how can i show status code with example value.

@Marusyk
Copy link

Marusyk commented Dec 12, 2017

@jitsingh89 Use SwaggerResponseRemoveDefaultsAttribute

[HttpPost]
[SwaggerResponseRemoveDefaults]
[SwaggerResponse(HttpStatusCode.Creted, Type = typeof(IEnumerable))]
public HttpResponseMessage Get(string lang)
{
     return Request.CreateResponse(HttpStatusCode.Created, objectyofresponse);
}

@mattfrear
Copy link

I think you can close this issue

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

No branches or pull requests

4 participants