Last active
August 29, 2015 14:19
-
-
Save davesag/c8cf393f1a14d4df757e to your computer and use it in GitHub Desktop.
Defining a map of arbitrary translation keys in Swagger 2.0
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: "0.0.1" | |
title: Localised Thingy demonstration | |
definitions: | |
translation: | |
required: | |
- default | |
properties: | |
default: | |
type: string | |
additionalProperties: | |
type: string | |
thingy: | |
required: | |
- code | |
properties: | |
code: | |
type: string | |
translations: | |
$ref: '#/definitions/translation' | |
localisedThingy: | |
required: | |
- code | |
- name | |
properties: | |
code: | |
type: string | |
description: A locale code | |
pattern: '^[a-z]{2}(\|[a-z]+)?$' | |
name: | |
type: string | |
description: The localised name | |
paths: | |
/thingies: | |
get: | |
description: |- | |
Gets `Thingy` objects. | |
responses: | |
# Response code | |
200: | |
description: A bunch of `Thingies` | |
schema: | |
type: array | |
items: | |
$ref: '#/definitions/thingy' | |
/{locale}/thingies: | |
get: | |
description: |- | |
Gets correctly localised `Thingies` | |
parameters: | |
- name: locale | |
in: path | |
type: string | |
required: true | |
default: default | |
responses: | |
200: | |
description: A bunch of localised `Thingies` | |
schema: | |
type: array | |
items: | |
$ref: '#/definitions/localisedThingy' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated version (w/webron's corrections) works with swagger-codegen-2.1.1-M1 (Java/JavaJaxRS) ... makes a Map<String,String> for 'translation' and embeds that as a property of thingy ...