Skip to content

Instantly share code, notes, and snippets.

@JamesMessinger
Created April 15, 2016 15:27
Show Gist options
  • Save JamesMessinger/e867ccd425e730634ee71f43c462a34f to your computer and use it in GitHub Desktop.
Save JamesMessinger/e867ccd425e730634ee71f43c462a34f to your computer and use it in GitHub Desktop.
This example demonstrates a URL-encoded JSON Pointer in a Swagger 2.0 API definition
swagger: "2.0"
info:
version: 1.0.0
title: Blog
paths:
"/blogs/{id}/posts":
parameters:
- name: "id"
in: "path"
type: "integer"
required: true
post:
summary: Add a new post to a blog
responses:
201:
description: Created
schema:
title: BlogPost
type: object
properties:
id:
type: integer
title:
type: string
author:
type: string
get:
summary: Get a list of posts for a blog
parameters:
- name: "id"
in: "path"
type: "integer"
required: true
responses:
200:
description: Success
schema:
type: array
items:
# This line works in Swagger Editor,
# but the "{" and "}" characters are technically invalid,
# according to RFC 6901, sections 5 & 6 - https://tools.ietf.org/html/rfc6901#section-5
# $ref: "#/paths/~1blogs~1{id}~1posts/post/responses/201/schema"
# This line is valid, according to RFC 6901
# (the "{" and "}" characters have been encoded)
# But, it doesn't work in Swagger Editor
$ref: "#/paths/~1blogs~1%7Bid%7D~1posts/post/responses/201/schema"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment