Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

feat(backend): pass Path Item Object to backend #24

Merged
merged 1 commit into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ directly to the API caller.

* `options.body` - JSONifable object.
* `options.method` - HTTP method.
* `options.operationObject` - Swagger/OpenAPI Operation Object.
* `options.pathItemObject` - Swagger/OpenAPI Path Item Object.
* `options.parameters` - named query parameters.
* `options.qs` - named query parameters (legacy).
* `options.pathname` - URL pathname.
Expand Down
2 changes: 1 addition & 1 deletion lib/backends/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FetchClient {
* @param {object} options - options object.
* @param {object} options.body - JSONifable object.
* @param {string} options.method - HTTP method.
* @param {string} options.operationObject - Swagger/OpenAPI Operation Object.
* @param {string} options.pathItemObject - Swagger/OpenAPI Path Item Object.
* @param {object} options.parameters - named query parameters.
* @param {object} options.qs - named query parameters (legacy).
* @param {string} options.pathname - URL pathname.
Expand Down
6 changes: 3 additions & 3 deletions lib/backends/swagger-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SwaggerClient {
* @param {object} options - options object.
* @param {object} options.body - JSONifable object.
* @param {string} options.method - HTTP method.
* @param {string} options.operationObject - Swagger/OpenAPI Operation Object.
* @param {string} options.pathItemObject - Swagger/OpenAPI Path Item Object.
* @param {object} options.parameters - named query parameters.
* @param {object} options.qs - named query parameters (legacy).
* @param {string} options.pathname - URL pathname.
Expand All @@ -28,9 +28,9 @@ class SwaggerClient {
options.qs || options.parameters,
options.pathnameParameters
)

const operationId = options.pathItemObject[options.method.toLowerCase()].operationId
return this.client.execute({
operationId: options.operationObject.operationId,
operationId,
parameters
})
}
Expand Down
3 changes: 2 additions & 1 deletion lib/backends/swagger-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ describe('lib.backends.swagger-client', () => {
const client = new SwaggerClient({ client: swagger })

client.http({
operationObject: { operationId: 'getFoo' },
method: 'GET',
pathItemObject: { get: { operationId: 'getFoo' } },
body: { a: 1 },
parameters: { b: 2 },
pathnameParameters: { c: 3 }
Expand Down
3 changes: 1 addition & 2 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,9 @@ class Component {
* @returns {(Promise|Stream)} Promise
*/
_requestAsync (method, options) {
const operationObject = this.pathItemObject[method.toLowerCase()]
return this.backend.http(Object.assign({
method,
operationObject,
pathItemObject: this.pathItemObject,
pathname: this.getPath(),
pathnameParameters: this.parameters
}, options))
Expand Down