Manuel del Pino Lucena
Manuel del Pino Lucena

Reputation: 203

How can I use $ as text in vscode snippets?

The problem comes when I try to create a snippet for openapi3.

{
  "openApi3-MultipleExamples": {
    "prefix": "openApi3-MultipleExamples",
    "body": [
      "MultipleExamples:",
      "  description: A user object.",
      "  content:",
      "    application/json:",
      "      schema:",
      "        $ref: '#/components/schemas/User'   # Reference to an object",
      "      examples:",
      "        Jessica:",
      "          value:",
      "            id: 10",
      "            name: Jessica Smith",
      "        Ron:",
      "          value:",
      "            id: 20",
      "            name: Ron Stewart"
    ],
    "description": "Multiple examples in response bodies"
  }
}

In this example $ref will be created as only ref because seems like a variable. How can I use $ as a text in vscode snippets?

Upvotes: 0

Views: 53

Answers (1)

rioV8
rioV8

Reputation: 28663

You have to escape the $

"\\$ref: '#/components/schemas/User'   # Reference to an object"

Upvotes: 1

Related Questions