Redocly / Redocly/redocly-cli

`file` shoud be an accepted primitive data type in swagger 2.0 spec

Open
#540 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

governance p2 Type: Bug
Dominant language
TypeScript
Stars
1.5k
Forks
228
Avg merge
1d 14h
Merged PRs (30d)
48

Description

Describe the bug
See https://swagger.io/specification/v2/#specification, Section Data types.

An additional primitive data type "file" is used by the Parameter Object and the Response Object to set the parameter type or the response as being a file.

It seems this file data type exception is not accounted for Response object.

To Reproduce
Steps to reproduce the behavior:
openapi lint --format stylish spec.yml

Expected behavior
No spec error should be raised.

Logs

spec.yml:
  28:19  error    spec                    `type` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".
  3:1    warning  info-license            Info object should contain `license` field.
  20:5   warning  operation-operationId   Operation object should contain `operationId` field.
  24:7   warning  operation-4xx-response  Operation must have at least one `4xx` response.

OpenAPI definition

swagger: "2.0"

info:
  title: API
  version: 0.0.1
  description: |
    API

host: swagger.petstore
schemes:
  - https
basePath: /api/v1
consumes:
  - application/json
produces:
  - application/json; charset=utf-8

paths:
  /foo:
    get:
      summary: foo
      produces:
        - application/octet-stream
      responses:
        200:
          description: txt file
          schema:
            type: file

openapi-cli Version(s)
redocly/openapi-cli:v1.0.0-beta.80 container

Node.js Version(s)
See above.

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 by reproducing the reported error with the Swagger 2.0 specification shown in the issue and trace the openapi lint validation of the Response Object schema. Done means a response schema using type: file passes without the reported type error, while the existing warnings remain as appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.