question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: validateMimeTypeOAS3 error - `allowedValues` is not provided for `request-mime-type` rule

See original GitHub issue

Describe the bug when I use lint extends all I’m getting an error for allowedValues is not provided for request-mime-type rule. If I change the config to recommended the linter succeeds.

To Reproduce Steps to reproduce the behavior:

  1. Given this .redocly.yaml file (below)
  2. And this OpenAPI file(s)
  3. Run this command with these arguments… openapi lint ./my-swagger.yaml --format stylish
  4. See error

Expected behavior the linter should produce an error for the missing mime-type and define where it should be included in the spec.

Logs

openapi lint ./my-swagger.yaml --format stylish
validating ./my-swagger.yaml...
Something went wrong when processing ./my-swagger.yaml:

  - Parameter "allowedValues" is not provided for "request-mime-type" rule.

(node:28796) UnhandledPromiseRejectionWarning: Error: Parameter "allowedValues" is not provided for "request-mime-type" rule
    at Object.validateMimeTypeOAS3 (C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\utils.js:111:15)
    at leave (C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\rules\oas3\request-mime-type.js:10:29)
    at visitWithContext (C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\walk.js:205:13)
    at walkNode (C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\walk.js:177:21)
    at walkNode (C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\walk.js:154:25)
    at walkNode (C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\walk.js:154:25)
    at walkNode (C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\walk.js:154:25)
    at walkNode (C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\walk.js:154:25)
    at Object.walkDocument (C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\walk.js:32:5)
    at C:\Users\fiel\.nvm\versions\node\v14.18.1\bin\node_modules\@redocly\openapi-cli\node_modules\@redocly\openapi-core\lib\lint.js:64:16
(Use `node --trace-warnings ...` to show where the warning was created)
(node:28796) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:28796) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

OpenAPI definition If applicable, add an OpenAPI definition and .redocly.yaml configuration file that helps reproduce the problem. At a minimum, please state the specification version(s) you’re using (e.g. 2.0, 3.0, 3.1).

openapi: 3.0.0
info:
  version: '1.1'
  title: 'an api'
  description: ' a description.'
  contact:
    name: 'Jeremy'
    email: 'jeremy@me.com'
servers:
  - url: 'http://api.redocly.com'
paths:
  /v1/endpoint:
    post:
      summary: 'this is a summary'
      description: 'this is a description'
      operationId: createRecord
      tags:
        - createRecord
      parameters:
        - $ref: '#/components/parameters/customerTransactionId'
        - $ref: '#/components/parameters/clientId'
        - $ref: '#/components/parameters/locale'
        - $ref: '#/components/parameters/establishedId'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/component_1'
lint:
  extends:
    - all
  rules:
    info-license: off
    info-license-url: off
    operation-tag-defined: off
    tag-description: off

openapi-cli Version(s) 1.0.0-beta.69

Node.js Version(s) v14.18.1

Additional context relates to #422

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
michaelgwelchcommented, May 12, 2022

@tatomyr You can hide my comment or mark it as off-topic. After struggling with this for a bit my colleague that set up redocly-cli on our repo showed me that we actually have 4 different config files. 😄 We have 4 different configs we need to run with. I changed one that wasn’t being called in our normal build. If I change the correct config file then the problem does disappear as mentioned above.

We are having fun trying to figure out how to upgrade from @redocly/openapi-cli": "^1.0.0-beta.63, but I just discovered that with recommended everything seems to work fine.

1reaction
RomanHotsiycommented, Jan 5, 2022

@adamaltman I agree.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Misleading error message claiming allowed values in "in" of a ...
If I just complete the parameter definition by providing it's schema, this error is not reported, although the value for "in" is still...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found