Last active
July 31, 2018 09:13
-
-
Save JamesMessinger/09dd37c80d3324908ff0 to your computer and use it in GitHub Desktop.
Example of using `allOf` to extend an object in a Swagger API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swagger: "2.0" | |
info: | |
version: "1.0.0" | |
title: minimal | |
description: News Articles ftw | |
paths: | |
/users: | |
get: | |
responses: | |
"200": | |
description: hello world | |
definitions: | |
NewsArticle: | |
title: NewsArticle | |
type: object | |
properties: | |
id: | |
type: integer | |
format: int32 | |
x-mysql-type: int(11) | |
NewsArticleExt: # tmp | |
title: NewsArticleExt | |
type: object | |
allOf: | |
- $ref: "#/definitions/NewsArticle" | |
- properties: | |
test: | |
type: string |
Zhuinden
commented
Jul 28, 2016
Actually this should be something like this
swagger: "2.0"
info:
version: "1.0.0"
title: minimal
description: News Articles ftw
paths:
/users:
get:
responses:
"200":
description: hello world
definitions:
NewsArticle:
title: NewsArticle
type: object
properties:
id:
type: integer
format: int32
x-mysql-type: int(11)
NewsArticleExt: # tmp
title: NewsArticleExt
type: object
allOf:
- $ref: "#/definitions/NewsArticle"
- type: object
properties:
test:
type: string
Lol, in your examples the /users path items has no schema defined, so are not calling any of the definitions...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment