question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Referenced schema with internal fields not detected as identical when bundling

See original GitHub issue

This one is edge casey, so forgive me for the less than clear title.

Let’s say we have spec C, referencing a schema from an external spec called spec A:

          properties:
            items:
              type: array
              items:
                $ref: 'https://a-service.io/openapi.yaml#/components/schemas/Order'

The Order schema has a single internal field (x-internal: true).

At the same time, spec C itself also has the identical Order schema with the single internal field, further down. Why? Because spec C was created by merging spec A and spec B, one of which has the original Order schema, and the other referencing the original Order schema.

What happens while bundling is that we end up with a schema called “schemas-Order”, produced by the bundle.ts getComponentName(), which did not detect that the incoming schema is identical to the one already in the file. My hunch is that this is because one of the schemas at that point already has the internal field stripped out, while the other one doesn’t.

This does not happen when using my original plugin written according to the docs (separate decorators for stripping internal operations, properties, parameters, components).

It also doesn’t happen if I dereference spec B prior to merging it into the final spec (by running “openapi bundle” on it, then merging). This is an acceptable workaround, but since we also store specs A and B prior to merging, it means we store a larger file than necessary.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bojanzcommented, Jan 18, 2022

Apologies for the delay on my side, I’ll try to produce a repo demonstrating this bug tomorrow.

0reactions
adamaltmancommented, Mar 29, 2022

Let’s close this for now. @bojanz if you have a reproduction, please re-open it.

Also, we’ve made some changes recently to our configuration file format.

https://github.com/redocly-demo/demo-remove-x-internal

If you can make or share a reproduction of the issue, feel free to take from there and add to the level of complexity you need to reproduce the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"$id" and "$ref" changes in JSON Schema draft 2019-09 and ...
@handrews - I've started working on implementing JSON Schema 2019-09, and I'd like to know more details about how $ref is supposed to...
Read more >
Structuring a complex schema — Understanding JSON ...
In order to reference a schema, we need a way to identify a schema. Schema documents are identified by non-relative URIs. Schema documents...
Read more >
Common Problems Found in RAML 1.0 API Specifications
If you meant to reference an element that is in the file, such references are not allowed. References to inner elements are valid...
Read more >
Build schema for eas.json - Expo Documentation
This document is a reference that outlines the schema for the "build" key in eas.json. For an explanation of how to use it,...
Read more >
Schema Reference - Vespa Documentation
A field not contained in the document. Use synthetic fields (outside document) to derive new field values to be placed in the indexing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found