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

fix: bundle externalValue with relative reference in examples object #1747

Merged
merged 9 commits into from
Oct 3, 2024

Conversation

AlexVarchuk
Copy link
Contributor

@AlexVarchuk AlexVarchuk commented Oct 1, 2024

What/Why/How?

The bundle command doesn't correctly resolve externalValue with relative reference.

According to specification https://spec.openapis.org/oas/v3.1.0.html#fixed-fields-15 externalValue may contain relative references. Bundle command doesn't resolve it.

Reference

Resolves #919

Testing

openapi.yaml

openapi: 3.1.0
security: []
info:
  version: 1.0.0
  title: Example.com
  termsOfService: https://example.com/terms/
  contact:
    email: [email protected]
    url: http://example.com/contact
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  description: OpenAPI description with external example
components: {}

paths:
  /:
    post:
      summary: Test request externalValue with relative reference in examples
      requestBody: 
        content:
          application/xml:
            schema:
              type: object
            examples:
              mergeRequest:
                summary: Merge request example
                externalValue: './external-value.json'

Screenshots (optional)

Screenshot 2024-10-01 at 16 56 00

Check yourself

  • Code changed? - Tested with redoc/reference-docs/workflows (internal)
  • All new/updated code is covered with tests
  • New package installed? - Tested in different environments (browser/node)

Security

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

@AlexVarchuk AlexVarchuk self-assigned this Oct 1, 2024
@AlexVarchuk AlexVarchuk requested a review from a team as a code owner October 1, 2024 14:56
Copy link

changeset-bot bot commented Oct 1, 2024

🦋 Changeset detected

Latest commit: 46e1008

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@redocly/openapi-core Patch
@redocly/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 1, 2024

Command Mean [ms] Min [ms] Max [ms] Relative
redocly lint packages/core/src/benchmark/benches/rebilly.yaml 980.3 ± 10.1 964.3 999.8 1.00
redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml 986.1 ± 22.6 959.2 1034.4 1.01 ± 0.03

Copy link
Contributor

github-actions bot commented Oct 1, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.56% 4993/6356
🟡 Branches 67.19% 2062/3069
🟡 Functions 72.98% 824/1129
🟡 Lines 78.85% 4711/5975
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡 core/src/bundle.ts
75.72% (-3.55% 🔻)
65.65% (-4.02% 🔻)
94.44%
75.72% (-3.55% 🔻)

Test suite run success

809 tests passing in 121 suites.

Report generated by 🧪jest coverage report action from 46e1008

@AlexVarchuk AlexVarchuk requested a review from a team as a code owner October 1, 2024 15:01
packages/core/src/ref-utils.ts Outdated Show resolved Hide resolved
packages/core/src/resolve.ts Outdated Show resolved Hide resolved
@AlexVarchuk AlexVarchuk force-pushed the fix/bundle-relative-reference-in-external-value branch from 7df5ba2 to 8e6f12c Compare October 3, 2024 10:58
.changeset/little-pears-sniff.md Outdated Show resolved Hide resolved
@AlexVarchuk AlexVarchuk force-pushed the fix/bundle-relative-reference-in-external-value branch from 42ad933 to 1f8c90f Compare October 3, 2024 12:18
Copy link
Contributor

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small suggestion.

packages/core/src/resolve.ts Outdated Show resolved Hide resolved
@tatomyr
Copy link
Contributor

tatomyr commented Oct 3, 2024

@AlexVarchuk also, please check it in Workflows.

@AlexVarchuk AlexVarchuk merged commit 67ea331 into main Oct 3, 2024
30 checks passed
@AlexVarchuk AlexVarchuk deleted the fix/bundle-relative-reference-in-external-value branch October 3, 2024 17:00
@jeremyfiel
Copy link
Contributor

This is for the bundle command but can it also be utilized for the lint command?

My original issue was about linting

@tatomyr
Copy link
Contributor

tatomyr commented Oct 3, 2024

@jeremyfiel indeed. It needs to be further adjusted to be able to use it in linter, so I'll reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no-invalid-media-type-examples | not working as expected
4 participants