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.

How does one document a JSON attribute named "$ref" since it is a reserved keyword?

See original GitHub issue

I have a question about “$ref” and OpenAPI 3.0.0 specification. I am documenting a datamodel (I will call it “DataModel” for clarification) in “#/components/schemas/DataModel” which has a JSON attribute named “$ref”. However, that is a reserved keyword in OpenAPI 3.0.0, used for referencing other areas of the OpenAPI document. How can I document my attribute “$ref” in the properties section of “#components/schemas/DataModel”? Is there an escape sequence that I can put before $ref? “$ref” is the name of an attribute, and does not reference a section in the OpenAPI 3.0.0 document.

Example:

components:
   schemas:
      DataModel:
         type: "object"
         properties:
            $ref: 
               type: "string"
               example: "DocType|OtherDataModel|1351039-1"

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
EngineerEthancommented, Mar 9, 2020

Thank you! Based on your comments above, $ref should be parsed the way I expected it to be parsed when it is an attribute name, so I can link this issue when/if I open another issue. I think this is a problem with the npm package swagger-parser. I will open an issue there if that turns out to be the case.

1reaction
cebecommented, Mar 7, 2020

Using a reference, i.e. placing $ref to reference other parts of the document is only allowed in specific places, using $ref as a property name should not have a special meaning in OpenAPI 3.0 as far as I see (not sure about 3.1 though).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reserved words in DynamoDB
The following keywords are reserved for use by DynamoDB. Do not use any of these words as attribute names in expressions. This list...
Read more >
Generic keywords — Understanding JSON Schema 2020- ...
JSON Schema includes a few keywords, that aren't strictly used for validation, but are used to describe parts of a schema. None of...
Read more >
Google JSON style-guide
future we wish to make ingredients a reserved word, we can do one of two things: 1) Choose a different name: { "apiVersion":...
Read more >
Working with JSON in Azure Cosmos DB
Reserved keywords and special characters in JSON​​ For example, SELECT c. grade and SELECT c["grade"] are equivalent. This syntax is useful to ...
Read more >
Using $ref
Local Reference – $ref: '#/definitions/myElement' # means go to the root of the current document and then find elements definitions and myElement one...
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