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

Generate valid JSON expected by http://editor.swagger.io #33

Closed
darewreck54 opened this issue Dec 24, 2015 · 5 comments
Closed

Generate valid JSON expected by http://editor.swagger.io #33

darewreck54 opened this issue Dec 24, 2015 · 5 comments

Comments

@darewreck54
Copy link

Hi,

I'm not sure if this is really an issue, but an observation that I notice. I'm not sure if this is related to an issue with swashbuckle or is it swashbuckle.OData.

I noticed that when you take the swagger json via "swagger/docs/v1" and copy and paste it on http://editor.swagger.io/#/, there are some potential issues/improvements:

  1. It doesn't take advantage of the ""basePath" attribute, and as a result for each end point will copy the basePath. This seems a bit repetitive.

Example: if the URL is "localhost/api/vi/Products GET

Generated json will display: "GET /api/vi/Products" If the baseURL is used, then you can display "GET /Products/" instead.

  1. Also the generated json populates each endpoint with a
"consumes": [],
"produces": [],

If these two fields are not filled in, then you will not be able to use the "Try this" for the end point on the swagger UI and an error "Object is missing the required property 'accept'"

It's expecting the "produces": ["application/json"]". If all the endpoints, accept the same it can be marked at the higher level then each endpoint.

However, its interesting the the swagger UI that is generated doesn't have this issue, but the generated .json does. I would expect it to be consistent in terms of the swagger UI and the swagger json that represents the UI to be consistent.

Thanks,
D

@rbeauchamp
Copy link
Owner

Hey, 1) Swashbuckle.OData supports and displays both WebApi and OData routes that likely have different base paths. Does swagger/swashbuckle support multiple base paths?
2) Marking this issue as an enhancement with help wanted to update the JSON output.

Thanks!

@rbeauchamp rbeauchamp changed the title Issue with generated swagger Json Generate valid JSON expected by http://editor.swagger.io Jan 2, 2016
@rbeauchamp
Copy link
Owner

I think this enhancement would involve researching and updating this code: why don't the OData media type formatters return true for CanReadType() and CanWriteType()?

@joshbooker
Copy link

Ran into the Consumes : [] thing today. Can we just hard code "application/json" for now? ;-) I so wish I had the skills to help with PRs & tests etc. Keep up the great work, we understand if you cannot do it all.

@rbeauchamp
Copy link
Owner

Yeah hard coding would be easiest for now if it's causing issues.

@ghost ghost closed this as completed in dc42161 Jan 9, 2016
@ghost
Copy link

ghost commented Jan 9, 2016

consumes and produces is now correctly populated in v2.10.1. Please give it a try. Thanks!

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

No branches or pull requests

3 participants