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

chore: make "config" field available to derived classes #810

Merged
merged 7 commits into from
Aug 22, 2022

Conversation

roman-sainchuk
Copy link
Contributor

@roman-sainchuk roman-sainchuk commented Aug 16, 2022

What/Why/How?

It would be nice to have access to config field in subclasses extending BaseResolver class.
Example:

export class ExternalResolver extends BaseResolver {
  override async loadExternalRef(absoluteRef: string): Promise<Source> {
    if (isHttpPath(absoluteRef)) {
      const { body, mimeType } = await readFileFromUrl(
        absoluteRef,
        this.config.http // Here is the need in config field
      );
      return new Source(absoluteRef, body, mimeType);
    }

    return new Source(
      absoluteRef,
      (await getDocumentByURI(absoluteRef)).getText()
    );
  }
}

Reference

Testing

Screenshots (optional)

Check yourself

  • Code is linted
  • Tested with redoc/reference-docs/workflows
  • All new/updated code is covered with tests

Security

  • Security impact of change has been considered
  • Code follows company security practices and guidelines

@github-actions
Copy link
Contributor

github-actions bot commented Aug 16, 2022

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 68.91% 2924/4243
🟡 Branches 62.15% 1614/2597
🟡 Functions 60.56% 473/781
🟡 Lines 68.75% 2711/3943

Test suite run success

473 tests passing in 81 suites.

Report generated by 🧪jest coverage report action from c53c50d

@roman-sainchuk roman-sainchuk marked this pull request as ready for review August 18, 2022 11:17
@roman-sainchuk roman-sainchuk requested review from RomanHotsiy, tatomyr and a team August 18, 2022 12:20
@roman-sainchuk roman-sainchuk self-assigned this Aug 18, 2022
@roman-sainchuk roman-sainchuk merged commit 5671e9d into master Aug 22, 2022
@roman-sainchuk roman-sainchuk deleted the chore/reuse-resolver-config branch August 22, 2022 11:20
@roman-sainchuk roman-sainchuk mentioned this pull request Aug 22, 2022
5 tasks
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