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

Display Global Headers & Parameters #1443

Open
itizarsa opened this issue Apr 16, 2024 · 4 comments
Open

Display Global Headers & Parameters #1443

itizarsa opened this issue Apr 16, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@itizarsa
Copy link

What happens?

Global headers & parameters under components aren't displayed

What did you expect to happen?

OpenAPI spec supports global headers & parameters under components. It should be displayed alongside the operation

SS

How can we reproduce the issue?

Current Doc - https://sandbox.scalar.com/e/b59fw

Expected Doc - https://sandbox.scalar.com/e/6sWkt

Swagger/OpenAPI Example

No response

@itizarsa itizarsa added the bug Something isn't working label Apr 16, 2024
@itizarsa
Copy link
Author

itizarsa commented Apr 19, 2024

@marclave @hanspagel I can pick this up. Could someone help me figure out where to check to start working on this?

@hanspagel hanspagel self-assigned this Apr 25, 2024
@hanspagel
Copy link
Member

That’s so kind! Actually, this is part is a little complex (or maybe I should even say messy). If you want to give it a try, that’s where I’d start:

We need the components as a 2nd parameter in this function:
https://github.com/scalar/scalar/blob/main/packages/api-reference/src/hooks/useOperation.ts#L19

Unfortunately, we don’t have the components available in the component (yet). So we’ll probably need some prop drilling, passing the whole specification down as a prop:
https://github.com/scalar/scalar/blob/main/packages/api-reference/src/components/Content/Operation/EndpointDetails.vue

And once it’s in there, you can add the mentioned logic to useOperation.

Unfortunately, we’ll probably need to pass the headers to the API client too and it’s not using the same logic:
https://github.com/scalar/scalar/blob/main/packages/api-reference/src/helpers/openClientFor.ts

When I look at the code, I see a lot of potential for refactoring. I’m so sorry for making it so hard. If you’re stuck, just ping me again, and I’ll give it a try asap. It’d be a great opportunity for some refactoring anyway. :)

@itizarsa
Copy link
Author

itizarsa commented May 1, 2024

@hanspagel This is not supported on Swagger, should we do this on the scalar? Since it's not the behaviour of Swagger, people might want to opt out of this. We need to think about that too.

@hanspagel
Copy link
Member

It’s in the OpenAPI specification, so we definitely want to support this. :) And if someone asks for it, we’ll add a setting for sure, but we can do this quickly once it’s needed I’d say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants