swagger-api / swagger-api/swagger-client

applySecurities fails as securityDef is returned as undefined.

Open
#2,439 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.7k
Forks
765
Avg merge
1d 1h
Merged PRs (30d)
6

Description

securityDef is returning undefined because get function is not able to look through nested object. Although the spec included the security definition get functioned failed to look for securitySchemes key.
https://github.com/swagger-api/swagger-js/blob/e0003d0d29a561a36c01004a3b65bdae5bc56b84/src/execute/oas3/build-request.js#L94

This is probably because the webpack config doesn't enable the Deep property path support for methods like _.get, _.has, & _.set. feature set

I was using https://swaggerapis.rainmaker.espressif.com/ API which involves getting an AccessToken(apiKey) after sending a login request. All rest of the authorised API calls used this token for verification. Whenever I made a request, securityDef would be undefined and API call would not execute.

I highly suspect the fix is just to add the above feature set to the loadlash module.

Thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/execute/oas3/build-request.js around line 94 and inspect how the security definition is retrieved, then review the webpack configuration and its lodash feature support. Reproduce the request against the described API and confirm that nested securitySchemes resolution produces a security definition and allows the authorized call to execute.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
api, authentication, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.