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

Commit

Permalink
feat(backend): pass Path Item Object to backend (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
silasbw authored Dec 28, 2018
1 parent d8820a7 commit 551bdf8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
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

0 comments on commit 551bdf8

Please sign in to comment.