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: wrong discriminator mapping when bundling with derefernce #1666

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

tatomyr
Copy link
Contributor

@tatomyr tatomyr commented Aug 15, 2024

What/Why/How?

Fixed bundling with the --dereferenced option. Previously, references to external files were not substituted with references to components, causing them to become invalid.

For example, bundling this:

openapi: 3.1.0
info: {}
paths:
  /test:
    get:
      responses:
        default:
          content:
            application/json:
              schema:
                type: object
                discriminator:
                  propertyName: discriminatedProp
                  mapping:
                    Foo: ./foo.yaml
                    Bar: ./bar.yaml
                oneOf:
                  - $ref: ./foo.yaml
                  - $ref: ./bar.yaml

will lead to this (please notice the comments):

openapi: 3.1.0
info: {}
paths:
  /test:
    get:
      responses:
        default:
          content:
            application/json:
              schema:
                type: object
                discriminator:
                  propertyName: discriminatedProp
                  mapping:
                    Foo: ./foo.yaml # <-- THIS REFERENCE IS NO LONGERE VALID
                    Bar: ./bar.yaml # <-- THIS REFERENCE IS NO LONGERE VALID
                oneOf:
                  - type: object
                    properties: &ref_0
                      discriminatedProp:
                        type: string
                      foo:
                        type: string
                  - type: object
                    properties: &ref_1
                      discriminatedProp:
                        type: string
                      bar:
                        type: boolean
components:
  schemas:
    foo:
      type: object
      properties: *ref_0
    bar:
      type: object
      properties: *ref_1

Reference

#1602

Testing

Screenshots (optional)

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

Copy link

changeset-bot bot commented Aug 15, 2024

🦋 Changeset detected

Latest commit: ea2b460

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 Aug 15, 2024

Command Mean [s] Min [s] Max [s] Relative
redocly lint packages/core/src/benchmark/benches/rebilly.yaml 1.011 ± 0.020 0.986 1.062 1.00
redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml 1.018 ± 0.026 0.977 1.061 1.01 ± 0.03

@tatomyr tatomyr force-pushed the fix/wrong-discriminator-mapping branch from 2342376 to 234d763 Compare August 15, 2024 12:07
Copy link
Contributor

github-actions bot commented Aug 15, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.57% 4991/6352
🟡 Branches 67.24% 2061/3065
🟡 Functions 72.98% 824/1129
🟡 Lines 78.86% 4709/5971

Test suite run success

809 tests passing in 121 suites.

Report generated by 🧪jest coverage report action from ea2b460

@tatomyr tatomyr self-assigned this Aug 15, 2024
@tatomyr tatomyr marked this pull request as ready for review August 15, 2024 12:22
@tatomyr tatomyr requested review from a team as code owners August 15, 2024 12:22
@tatomyr tatomyr force-pushed the fix/wrong-discriminator-mapping branch from 3a9ecd3 to c5b88dd Compare August 16, 2024 14:02
@tatomyr tatomyr force-pushed the fix/wrong-discriminator-mapping branch from c5b88dd to 0933365 Compare August 29, 2024 12:45
@tatomyr tatomyr force-pushed the fix/wrong-discriminator-mapping branch from 0933365 to ea2b460 Compare October 18, 2024 08:00
@RomanHotsiy RomanHotsiy merged commit 5a493e7 into main Oct 18, 2024
41 checks passed
@RomanHotsiy RomanHotsiy deleted the fix/wrong-discriminator-mapping branch October 18, 2024 09:21
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.

3 participants