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.

Extra JSON Reference properties ignored - reduces reusability of references

See original GitHub issue

Hi everyone.

I feel that the ignoring of extra properties when using JSON References goes against the goal of reusability.

Take this example from a fictional Swagger contract:

{
    addresses: [
        "homeAddress": {
            "description": "The premises at which electricity is provided.",
            "$ref": "#/definitions/Address"
        },
        "invoiceAddress": {
            "description": "The billing address - must be where the customer's credit card is registered.",
            "$ref": "#/definitions/Address"
        }
    ]
}

The “description” properties help to distinguish between the two uses of the “Address” Reference. Of course you could argue that better naming of the “homeAddress” and “invoiceAddress” properties could achieve this, but we are not always in control of property names in our data models and sometimes you need a more verbose description.

The Swagger editor (http://editor.swagger.io/#/) is an example of an application that could be improved by removing this limitation.

Is this something that has been raised previously? Please see here for a discussion on the Swagger Google Group: https://groups.google.com/forum/#!topic/swagger-swaggersocket/ewgimdO2cOI

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:73
  • Comments:87 (55 by maintainers)

github_iconTop GitHub Comments

49reactions
IvanGoncharovcommented, Mar 3, 2016

Actually it supported both in Swagger and Draft-4, you just need to use allOf keyword. So instead of:

description: 'The premises at which electricity is provided.'
$ref": '#/definitions/Address'

You should write:

description: 'The premises at which electricity is provided.'
allOf:
  - $ref: '#/definitions/Address'

It standard usage of allOf nothing fancy here, and I think it fully solve this problem.

8reactions
qchocommented, Feb 24, 2016

I think this is a very good Proposal. In my example I want to set:

      parameters:
        - $ref: '#/parameters/fields'
          default: 'local_default'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Extra JSON Reference properties ignored - reduces reusability of ...
Hi everyone. I feel that the ignoring of extra properties when using JSON References goes against the goal of reusability.
Read more >
openapi - Swagger schema properties ignored when using $ref
1 Answer 1 ; openapi: 3.1.0 ... components: ; # openapi: 3.1.0 # This is supported parameters: - $ref: ; lowerBound: $ref: "#/definitions/Time"...
Read more >
Using external definition reference raises "Extra JSON ...
I use swagger editor 2.10.1 as my first version. But I have problems to use my existing json schema files. I have created...
Read more >
Understanding JSON Schema
JSON Schema is a powerful tool for validating the structure of JSON data. However, learning to use it by reading its.
Read more >
OpenAPI Specification v3.0.3 | Introduction, Definitions, & More
The reference string. This object cannot be extended with additional properties and any properties added SHALL be ignored. 4.7.23.2 Reference ...
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