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

feat: request interceptor #1588

Merged
merged 1 commit into from
Jun 24, 2024
Merged

feat: request interceptor #1588

merged 1 commit into from
Jun 24, 2024

Conversation

melissag-ensemble
Copy link
Collaborator

@melissag-ensemble melissag-ensemble commented Jun 21, 2024

Description

Enable adding of request interceptor to RedoclyAPIBlock

Related Issue

https://jira.corp.adobe.com/browse/DEVSITE-1190

Motivation and Context

Things I tried that didn't work:

  1. https://redocly.com/docs/developer-portal/guides/reference-docs-hooks/#steps. The RedoclyAPIBlock setup doesn't work with this.

  2. Also attempted to dynamically import the callback function, placing it in the static folder, similar to how we place open api spec in the static folder so we can access them within gatsby:
    <RedoclyAPIBlock src="/redocly-test/openapi/openapi.yaml" requestInterceptorSrc="/redocly-test/_override/ReferenceDocsHooks.js" />

But that resulted in the following error being thrown:
Cannot find module '/redocly-test/_override/ReferenceDocsHooks.js'

It looks like this isn't supported in Gatsby yet:

So the only option left is to pass the function as a string. However, due to limitations in gatsby and markdown, the function string can't contain comments nor empty lines. This is mentioned in the readme.

How Has This Been Tested?

  1. https://github.com/AdobeDocs/redocly-test/blob/c33c1cb9ea2a38274d4c36563f3798f2bd5e5e17/src/pages/api-full/index.md?plain=1#L7-L11
  2. https://developer-stage.adobe.com/redocly-test/api-full/#operation/getInventory
  3. click Try It button
  4. enter api-key: secret-key
  5. click Send
  6. confirm status 200 and you get a response back
  7. confirm request interceptor has been invoked by checking the console log

Screenshots (if appropriate):

Untitled

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@melissag-ensemble melissag-ensemble marked this pull request as ready for review June 22, 2024 00:00
@melissag-ensemble melissag-ensemble requested review from timkim and removed request for timkim June 22, 2024 00:01
@timkim timkim merged commit 967ca4f into main Jun 24, 2024
3 checks passed
@timkim timkim deleted the melissa/request-interceptor-4.11.16 branch June 24, 2024 18:09
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

Successfully merging this pull request may close these issues.

2 participants