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] OpenAPI import does not seem to honor default variables in servers declaration

See original GitHub issue
  • Insomnia Version: 6.6.2
  • Operating System: MacOS mojave 10.14.6

Details

I’m trying to import an OpenAPI 3 spec that uses variables in the server url. Default values are provided for these in the variables declaration. This results in an error when i try to import the file: Invalid URL: http://{host}:{port}/{basePath}

If I replace the url with the following string it works: http://localhost:8080/filemanagement

OpenAPI yaml file (parts of it - but it can be used to reproduce the bug and import works after replacing the servers/url part):

openapi: 3.0.2
info:
  description: OpenAPI definition for filemanagment services
  license:
    name: todo
    url: todo
  title: filemanagement
  version: 0.1.0
servers:
  - description: Devserver
    url: http://{host}:{port}/{basePath}
    variables:
      host:
        default: localhost
        description: Various servers (production, local development etc).
      port:
        default: "8080"
        description: Port to reach server on.
        enum:
          - "8080"
          - "9090"
      basePath:
        default: filemanagement
        description: API version, for information on other supported versions see those
          specifications.
tags:
  - description: Operations for managing file storages such as S3.
    name: storages
  - description: Operations for managing files connected to data sources.
    name: files

paths:
  /files:
    get:
      operationId: find_files
      parameters:
        - description: Search for files based on metadata.
          explode: true
          in: query
          name: metadata
          required: false
          schema:
            type: string
          style: form
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileDescription'
          description: List of files matching the search criteria. List will be empty
            if no files match the criteria.
      tags:
        - files
      x-openapi-router-controller: filemanagement_service.controllers.files_controller

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
vitaliiscommented, Jan 16, 2020

Not sure if it is the same or not, but I also can not import OpenAPI to insomnia because of 2 errors.

  1. Import failed TypeError: Cannot read property ‘Symbol(Symbol.iterator)’ of undefined
  2. failed to import ‘Import failed’ Cannot read property 'map' of undefined. This happens then you press “Import from File” button in a fresh workspace for example.

The first error is also shown when you go to Application > Preferences under “Data” tab and use “Import from clipboard” option.

Sadly, currently it seems impossible to import an OpenAPI spec into insomnia.

3reactions
develohpandacommented, May 10, 2020

Thanks for that @SylannBin! A missing servers declaration wasn’t handled by the openapi3 importer previously, resulting in those errors. I’m willing to say @vitaliis is experiencing the same thing as well.

That has been resolved by #2007 though, and will be included in the next release of Insomnia Core. I confirmed by importing that specification successfully while running on the latest develop.

image

Also I just wanted to point out that the bug does not occur when you directly copy&paste your openapi.json inside of the Insomnia Rest Designer text editor.

This is because Designer already includes the fix 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] OpenAPI import does not seem to honor default ... - GitHub
Details. I'm trying to import an OpenAPI 3 spec that uses variables in the server url. Default values are provided for these in...
Read more >
API import restrictions and known issues - Azure
Details of known issues and restrictions on OpenAPI, WSDL, and WADL formats support in Azure API Management.
Read more >
OpenAPI - document that was imported into - App Connect - IBM
You can import OpenAPI documents that contain API definitions into IBM App Connect. ... Variables are not supported for use with the servers...
Read more >
PyCharm Educational 183.4588.180 Release Notes - YouTrack
Feature PY‑5138 Link to source code from .po files Feature PY‑3454 Highlight HTTP links in reStructuredText Feature PY‑3451 Support Structure View for reStructuredText Feature PY‑2239 Custom...
Read more >
Known issues - PaperCut
PaperCut Print Deploy: Defaults and Capabilities are not correctly captured on PaperCut Mobility Print queues when cloning. Server: 1.5.1805 Cloner: 493.
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