-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
54 additions
and
7 deletions.
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 express from 'express'; | ||
import * as OpenApiValidator from '../src'; | ||
import { expect } from 'chai'; | ||
import * as request from 'supertest'; | ||
import * as path from 'path'; | ||
|
||
describe('default export resolver', () => { | ||
let server = null; | ||
let app = express(); | ||
|
||
before(async () => { | ||
app.use( | ||
OpenApiValidator.middleware({ | ||
apiSpec: { | ||
openapi: '3.0.0', | ||
info: { version: '1.0.0', title: 'test bug OpenApiValidator' }, | ||
paths: { | ||
'/': { | ||
get: { | ||
operationId: 'anything', | ||
// @ts-ignore | ||
'x-eov-operation-handler': 'controller-with-default', | ||
responses: { 200: { description: 'home api' } } | ||
} | ||
}, | ||
}, | ||
}, | ||
operationHandlers: path.join(__dirname, 'resources'), | ||
}), | ||
); | ||
|
||
server = app.listen(3000); | ||
console.log('server start port 3000'); | ||
}); | ||
|
||
after(async () => server.close()); | ||
|
||
it('should use default export operation', async () => { | ||
return request(app) | ||
.get(`/`) | ||
.expect(200) | ||
.then((r) => { | ||
expect(r.body).to.have.property('success').that.equals(true); | ||
}); | ||
}); | ||
}); |
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,3 @@ | ||
export default function (req, res) { | ||
res.json({success: true}).end(); | ||
} |