Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as path from 'path'; | ||
import * as express from 'express'; | ||
import { expect } from 'chai'; | ||
import * as request from 'supertest'; | ||
import { createApp } from './common/app'; | ||
import * as packageJson from '../package.json'; | ||
import { log } from 'console'; | ||
|
||
describe.only('styles', () => { | ||
let app = null; | ||
before(async () => { | ||
const apiSpec = path.join('test', 'resources', 'query.serialization.yaml'); | ||
app = await createApp({ apiSpec }, 3005, (app) => | ||
app.use( | ||
`/`, | ||
express | ||
.Router() | ||
.get('/api/q_form_explode', (req, res) => res.json({ query: req.query })) | ||
.get('/api/q_form_nexplode', (req, res) => res.json({ query: req.query })), | ||
), | ||
); | ||
}); | ||
|
||
after(async () => { | ||
app.server.close(); | ||
}); | ||
|
||
it('should handle querey param (default) style=form, explode=true', async () => | ||
request(app) | ||
.get('/api/q_form_explode?state=on&state=off') | ||
.expect(200) | ||
.then((r) => { | ||
expect(r.body.query.state).is.an('array').of.length(2); | ||
})); | ||
|
||
it.only('should handle query param with style=form, explode=false', async () => | ||
request(app) | ||
.get('/api/q_form_nexplode') | ||
.query({ | ||
state: 'on,off', | ||
}) | ||
.expect(200) | ||
.then((r) => { | ||
expect(r.body.query.state).is.an('array').of.length(2); | ||
})); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
openapi: '3.0.3' | ||
info: | ||
title: Dummy | ||
version: '0.1.0' | ||
|
||
paths: | ||
/api/q_form_explode: | ||
get: | ||
parameters: | ||
- description: Description | ||
schema: | ||
title: State | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Foo' | ||
description: A description | ||
name: state | ||
in: query | ||
responses: | ||
200: | ||
description: OK | ||
content: | ||
'application/json; charset=utf-8': | ||
schema: | ||
type: object | ||
|
||
/api/q_form_nexplode: | ||
get: | ||
parameters: | ||
- description: Description | ||
required: false | ||
explode: false | ||
schema: | ||
title: State | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Foo' | ||
description: A description | ||
name: state | ||
in: query | ||
responses: | ||
200: | ||
description: OK | ||
content: | ||
'application/json; charset=utf-8': | ||
schema: | ||
type: object | ||
|
||
|
||
components: | ||
schemas: | ||
Foo: | ||
type: string | ||
enum: | ||
- on | ||
- off | ||
|
||
|