Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
feat: Example in Parameters #39
Browse files Browse the repository at this point in the history
  • Loading branch information
joolfe committed Jul 26, 2020
1 parent c05919e commit f391960
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ function parseParameters (query = [], header = []) {

/* Accumulator function for different types of parameters */
function mapParameters (type) {
return (parameters, { key, description }) => {
return (parameters, { key, description, value }) => {
parameters.push({
name: key,
in: type,
schema: { type: 'string' },
...(description ? { description } : {})
...(description ? { description } : {}),
...(value ? { example: value } : {})
})
return parameters
}
Expand Down
11 changes: 11 additions & 0 deletions test/resources/input/Headers.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
"value": "other",
"description": "Another header",
"type": "text"
},
{
"key": "No-description",
"value": "header without description",
"type": "text"
},
{
"key": "No-value",
"value": "",
"description": "header without value",
"type": "text"
}
],
"url": {
Expand Down
3 changes: 3 additions & 0 deletions test/resources/output/GetMethods.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ paths:
schema:
type: string
description: Filter by age
example: '45'
- name: name
in: query
schema:
type: string
description: Filter by name
example: Jhon
- name: review
in: query
schema:
type: string
description: Indicate if should be reviewed or not
example: 'true'
responses:
'200':
description: Successful response
Expand Down
17 changes: 17 additions & 0 deletions test/resources/output/Headers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,41 @@ paths:
schema:
type: string
description: Custom header
example: hudjilksns78jsijns090
- name: X-Other
in: header
schema:
type: string
description: Another header
example: other
- name: No-description
in: header
schema:
type: string
example: header without description
- name: No-value
in: header
schema:
type: string
description: header without value
- name: age
in: query
schema:
type: string
description: Filter by age
example: '45'
- name: name
in: query
schema:
type: string
description: Filter by name
example: Jhon
- name: review
in: query
schema:
type: string
description: Indicate if should be reviewed or not
example: 'true'
responses:
'200':
description: Successful response
Expand All @@ -62,11 +77,13 @@ paths:
schema:
type: string
description: Indicate the type of body sent by client
example: application/json
- name: X-My-Header
in: header
schema:
type: string
description: Custom header
example: hudjilksns78jsijns090
responses:
'200':
description: Successful response
Expand Down

0 comments on commit f391960

Please sign in to comment.