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

Path-level parameters are not displayed in the UI #2791

Closed
xplicit opened this issue Mar 26, 2017 · 10 comments
Closed

Path-level parameters are not displayed in the UI #2791

xplicit opened this issue Mar 26, 2017 · 10 comments

Comments

@xplicit
Copy link

xplicit commented Mar 26, 2017

I have following definition of "Accept" parameter

{
"name":"Accept",
"in":"header",
"description":"Accept Header",
"type":"string",
"required":true,
"enum":["application/json"]
}

If I put this declaration on paths level, then this parameter is not shown in UI and when I click "Execute" button, I see error message in console that required "Accept" parameter is not set.

If I put this parameter on operation level, then I see it on UI, but when click "Execute" button it does not send request to server and does not show anything in response, errors or console.

If I remove this parameter completely, then Swagger UI starts work as expected.

But I can't remove it, because Azure/Autorest client does not send 'accept' headers with appropriate mime type without the parameter and I have to keep it in schema to make autorest generated clients work.

This is on v3.0.3 of Swagger UI, on previous version (2.2.10) it works correctly in all cases

@webron
Copy link
Contributor

webron commented Mar 27, 2017

You shouldn't specify Accept as a header parameter. That's why consumes exists and that's how you should specify it. Autorest respects consumes as well as far as I know so it shouldn't be a problem.

@webron webron closed this as completed Mar 27, 2017
@xplicit
Copy link
Author

xplicit commented Mar 27, 2017

Autorest does not send "Accept" header without explicity adding it in parameters, even if all operations have set consumes and produces to application/json. There is unresolved issue about it Azure/autorest#656

So currently there is no way to use Autorest both with Swagger UI v3, that's why I open this issue.

@webron
Copy link
Contributor

webron commented Mar 27, 2017

That's an issue for Autorest to resolve then, as they don't follow the spec.

@xplicit
Copy link
Author

xplicit commented Mar 27, 2017

By the way, I did not see in specs anywhere that if you define "Accept" header parameter that client must stop work as Swagger UI 3 does.

Moreover Swagger UI 3 does not work with any header parameter, defined at path level, not only Accept

@xplicit
Copy link
Author

xplicit commented Mar 27, 2017

"parameters" :
[{
"name":"X-Test",
"in":"header",
"description":"Test Header",
"type":"string",
"required":true,
"enum":["application/json"]
}]

is defined at path level. If click "execute" button, I've got error message in console: "Required parameter X-Test is not provided"

@webron
Copy link
Contributor

webron commented Mar 27, 2017

The issue with path level parameters has been resolved - swagger-api/swagger-js#972. Which version of swagger-ui do you test with? Do you experience that the parameter is not rendered but is still required?

If so, it'd help to get a full spec reproducing the issue.

I understand the spec might not be very clear about the Accept header, and I'll open a ticket about it, but the issue is still with Autorest.

@xplicit
Copy link
Author

xplicit commented Mar 27, 2017

If define "X-Test" parameter at operation level Swagger UI 3 does not send requests to server, when click "Execute" button.

Swagger UI 2.2.10 does this job correctly both at operation and path level.

@xplicit
Copy link
Author

xplicit commented Mar 27, 2017

At path level "X-Test" does not show in UI, at operation level it shows in UI, but still not work.
I use the version from master, commit 822dda8

@webron
Copy link
Contributor

webron commented Mar 27, 2017

Yup, I see it now.

@webron webron reopened this Mar 28, 2017
@webron webron changed the title Swagger UI can not work with "Accept" header parameter Path-level parameters are not displayed in the UI Mar 28, 2017
@webron
Copy link
Contributor

webron commented Apr 8, 2017

Parameters should be displayed now. Please reopen otherwise.

@webron webron closed this as completed Apr 8, 2017
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

2 participants