stoplightio / elements

Build beautiful, interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.
https://stoplight.io/open-source/elements/
Apache License 2.0
1.83k stars 206 forks source link

Allow to intercept try it request #1860

Open tmkasun opened 3 years ago

tmkasun commented 3 years ago

User story.

As a developer I want to intercept the outgoing tryout HTTP request So that I can Inject / Update HTTP request parameters such as headers

UPDATE:

The above user story is actually kind of intermediate requirement, My final goal is to auto-populate the Authentication parameters

image

so, As an API Consumer I want to set my authentication parameter automatically So that I can avoid coping the parameters (I:e API Key, Bearer token) manually

Is your feature request related to a problem?

I can't add to change the Authorization header value or Add a custom HTTP header to the TryIt request

UPDATE:

As per the updated user story, My problem is, I can set the Authentication parameters programmatically, No prop or API in the Elements component to set the Operation Auth Value (operationAuthValue)

Describe the solution you'd like

Expose a request interceptor interface, to modify this tryit fetch request parameters.

Additional context

As an example, In Swagger-UI library they expose a requestInterceptor parameter that users(library) can use to intercept any HTTP requests initiated from the swagger UI.

mnaumanali94 commented 3 years ago

Hey @tmkasun, exciting that WSO2 is evaluating elements for usage in dev portals. Can we setup a call to go through what you're looking to do and how we can possibly collaborate?

tmkasun commented 3 years ago

Hi @mnaumanali94 , Yeah that's great, Let's have a call, I sent a meeting invitation to your github email, Let me know whether that timeslot works for you, Else feel free to re-schedule the call.

moon0326 commented 2 years ago

Are there any updates to this feature request by any chance?

tmkasun commented 2 years ago

Hi @moon0326 ,

I check the latest code in the TryIt.tsx. It seems like now we can change the request parameters via onRequestChange prop. Haven't tested it though, So we might able to use that callback function to get to the request headers. @mnaumanali94 can you shed some light on this ?

moon0326 commented 2 years ago

Thank you! I did not notice that. I'll look into it :)