How does one document a JSON attribute named "$ref" since it is a reserved keyword?
See original GitHub issueI 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:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 packageswagger-parser
. I will open an issue there if that turns out to be the case.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).