[GH-ISSUE #3301] [bug]: Problems when importing OpenAPI/Swagger documents #1091

Closed
opened 2026-03-16 18:32:06 +03:00 by kerem · 1 comment
Owner

Originally created by @JoeMarkov on GitHub (Aug 30, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3301

Originally assigned to: @anwarulislam on GitHub.

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When I import a new collection from an existing swagger/openapi document, the host and basepath seem to be ignored.

My dream is be able to import the following swagger document below and then be directly able to execute queries against it.

As a new user, I found it very hard to figure out how to manually set the baseurl, I would have hoped that it used the host in the document as a default "baseurl".

then the basepath is also ignored, so the URL it tries to access is wrong.

I am doing this in a teacher/trainer setup.

The document:

swagger: '2.0'
info:
  version: '1.0'
  title: Customer API
  description: API for the www.myserver.com customer API
basePath: "/api"
host: www.myserver.com
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
  "/Customers":
    get:
      operationId: getAllCustomers
      summary: Access all the customers in the database
      responses:
        '200':
          description: Successful Response
          schema:
            type: array
            items:
              "$ref": "#/definitions/customer"
          examples:
            application/json:
            - Id: 1
              FirstName: Muriel
              LastName: Cook
              StreetAddress: 22523 Willison Street
              City: Minneapolis
              ZipCode: '55415'
            - Id: 2
              FirstName: Kenny
              LastName: Taylor
              StreetAddress: 493 Sarah Drive
              City: Lake Charles
              ZipCode: '70601'
            - Id: 3
              FirstName: Patrick
              LastName: Masi
              StreetAddress: 932 White Lane
              City: Macon
              ZipCode: '31201'
  "/Customers/{customerid}":
    get:
      operationId: getCustomerById
      summary: Find Customer by ID
      description: The ID of the Customer
      parameters:
      - "$ref": "#/parameters/customerid"
      responses:
        '200':
          description: Successful Response
          schema:
            type: object
            items:
              "$ref": "#/definitions/customer"
          examples:
            application/json:
              Id: 1
              FirstName: Muriel
              LastName: Cook
              StreetAddress: 22523 Willison Street
              City: Minneapolis
              ZipCode: '55415'
definitions:
  customer:
    title: customer
    type: object
    properties:
      Id:
        type: integer
        description: Customer ID
        format: int32
      FirstName:
        type: string
        example: Tore
        description: The first name of the customer
      LastName:
        type: string
        example: Nestenius
        description: The last name of the customer
      StreetAddress:
        type: string
        example: Storgatan 123
        description: The customer address
parameters:
  customerid:
    name: customerid
    in: path
    required: true
    description: The CustomerID
    type: integer

Steps to reproduce

  1. import the above document
  2. Try to make requests to it.

Environment

Release

Version

Cloud

Originally created by @JoeMarkov on GitHub (Aug 30, 2023). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3301 Originally assigned to: @anwarulislam on GitHub. ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior When I import a new collection from an existing swagger/openapi document, the host and basepath seem to be ignored. My dream is be able to import the following swagger document below and then be directly able to execute queries against it. As a new user, I found it very hard to figure out how to manually set the baseurl, I would have hoped that it used the host in the document as a default "baseurl". then the basepath is also ignored, so the URL it tries to access is wrong. I am doing this in a teacher/trainer setup. The document: ``` swagger: '2.0' info: version: '1.0' title: Customer API description: API for the www.myserver.com customer API basePath: "/api" host: www.myserver.com schemes: - http consumes: - application/json produces: - application/json paths: "/Customers": get: operationId: getAllCustomers summary: Access all the customers in the database responses: '200': description: Successful Response schema: type: array items: "$ref": "#/definitions/customer" examples: application/json: - Id: 1 FirstName: Muriel LastName: Cook StreetAddress: 22523 Willison Street City: Minneapolis ZipCode: '55415' - Id: 2 FirstName: Kenny LastName: Taylor StreetAddress: 493 Sarah Drive City: Lake Charles ZipCode: '70601' - Id: 3 FirstName: Patrick LastName: Masi StreetAddress: 932 White Lane City: Macon ZipCode: '31201' "/Customers/{customerid}": get: operationId: getCustomerById summary: Find Customer by ID description: The ID of the Customer parameters: - "$ref": "#/parameters/customerid" responses: '200': description: Successful Response schema: type: object items: "$ref": "#/definitions/customer" examples: application/json: Id: 1 FirstName: Muriel LastName: Cook StreetAddress: 22523 Willison Street City: Minneapolis ZipCode: '55415' definitions: customer: title: customer type: object properties: Id: type: integer description: Customer ID format: int32 FirstName: type: string example: Tore description: The first name of the customer LastName: type: string example: Nestenius description: The last name of the customer StreetAddress: type: string example: Storgatan 123 description: The customer address parameters: customerid: name: customerid in: path required: true description: The CustomerID type: integer ``` ### Steps to reproduce 1. import the above document 2. Try to make requests to it. ### Environment Release ### Version Cloud
kerem 2026-03-16 18:32:06 +03:00
Author
Owner

@liyasthomas commented on GitHub (May 1, 2024):

Thanks for your patience and valuable feedback. This feature has been implemented in a previous release candidate.

Closing this ticket as this feature is now available in the recent version. Please feel free to reach out if you have any other concerns.

<!-- gh-comment-id:2088146258 --> @liyasthomas commented on GitHub (May 1, 2024): Thanks for your patience and valuable feedback. This feature has been implemented in a previous release candidate. Closing this ticket as this feature is now available in the recent version. Please feel free to reach out if you have any other concerns.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1091
No description provided.