Skip to content

Instantly share code, notes, and snippets.

@marians
Created November 14, 2016 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marians/0c9ad72aa700a7afd2fb15dd3d3b10b3 to your computer and use it in GitHub Desktop.
Save marians/0c9ad72aa700a7afd2fb15dd3d3b10b3 to your computer and use it in GitHub Desktop.
How to avoid repeating a parameter definition in an Open API 2.0 spec?
swagger: "2.0"
host: api.example.com
schemes:
- https
info:
title: An Example API Spec
version: "1"
paths:
/users/{user_id}/:
get:
operationId: getUser
summary: Get user details
parameters:
- name: user_id
in: path
required: true
type: string
responses:
"200":
description: Success
patch:
operationId: updateUser
summary: Update user details
parameters:
- name: user_id
in: path
required: true
type: string
responses:
"204":
description: Success
delete:
operationId: deleteUser
summary: Delete a user
parameters:
- name: user_id
in: path
required: true
type: string
responses:
"204":
description: Success
parameters:
userIdUrlParam:
name: user_id
in: path
description: User ID
required: true
type: string
@marians
Copy link
Author

marians commented Nov 14, 2016

How to replace the three definitions of the parameter user_id with references to #/parameters/userIdUrlParam?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment