bump-sh/github-action

Keep getting an Error in '/components/securitySchemes/bearer_token' for missing key: type

opman129 opened this issue · 8 comments

  • I keep getting this error "Error: raw_definition property '/components/securitySchemes/bearer_token' is missing in my Github action every time I raise a pull request to deploy my documentation
    required keys: type" even though key: type is clearly defined in my Openapi specification file.

Open API components object

components:
  securitySchemes:
    bearer_token:
      type: http
      scheme: bearer
      bearerFormat: JWT
security:
  - bearer_token: [] 

Error

Run bump-sh/github-action@v1
  with:
    doc: cosmily
    token: ***
    file: redoc/openapi/openapi.yaml
    command: deploy
* Let's deploy a new documentation version on Bump... done
Error: raw_definition property '/components/securitySchemes/bearer_token' is missing required keys: type

Hi @opman129, thanks for your report! I'm sorry that you are having troubles deploying your OpenAPI contract to bump.sh.
Unfortunately I can't reproduce the error with this very minimal openapi contract file:

openapi: 3.0.1
info:
  title: My API docs
  description: |
    My API docs
  contact:
    email: hello@bump.sh
  license:
    name: 'Apache, 2.0'
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
  version: 1.0.0
servers: []
tags: []
paths: {}
components:
  securitySchemes:
    api_key:
      type: apiKey
      name: api_key
      in: header
    bearer_token:
      type: http
      scheme: bearer
      bearerFormat: JWT
security:
  - bearer_token: []

Which gives me the following result:

* Let's deploy a new documentation version on Bump... done
* Your new documentation version will soon be ready at https://bump.sh/hub/paulrbr/doc/cosmily

Would you be able to share with us the exact openapi.yaml file that you are trying to deploy please? Either here or you can send it to us by email hello@bump.sh. Thanks a lot 🙏

Hi again @opman129, I've been able to reproduce with a potential invisible problem in your initial openapi.yml file.

It seems that YAML accepts lines starting with non-breaking spaces, so if I replace the first space of the line containing the type: http key I indeed get the same error as you.

As seen on my text editor, non-breaking spaces are underlined in blue:
Capture d’écran de 2021-12-17 10-04-39

Would that file I do get the same error. Could you check your YAML file for non-breaking spaces please? Many thanks!

Hello @paulRbr, Thanks for your response. I've checked the openapi YAML file for non-breaking spaces and everything seems to be good but the error still persists. I would email you my specification file and you can have a look at it to see if I'm missing anything. Thank you.

@paulRbr I was having this same issue but removing the ref to an external file and putting this inline works:

type: http
scheme: bearer
bearerFormat: JWT

@paulRbr @opman129 I also removed the underscore and used bearerToken in my key name not bearer_token

Thanks @jasongoldelocks, I don't think refs to external files are supported for securitySchemes at the moment then. And good work on the removal of the underscore (_) in the bearer token.

Hi @jasongoldelocks, hi @opman129,

Oh I understood now, so your original top-level openapi contract file looked like this, I guess:

components:
  securitySchemes:
    bearerToken:
      $ref: 'security.yml'
security:
  - bearerToken: [] 

We indeed had an issue in the base specs validation rules that didn't allow references ($ref) in the securitySchemes top-level object. Thanks a lot for reporting this issue: we have now fixed the bug on bump.sh so you should be able to extract your security schemes in dedicated references (internal or external files) without any issues.

Please let me know if I can help with anything else.

Thanks so much for the help @paulRbr. That'll be all for now.