smartbear.com CORS error when importing file/URL
Hello,
I am running swagger editor in docker on a remote machine and accessing it at localhost at port 8090 via a tunnel. I am also hosting my openapi spec files on a remote http server accessible locally at port 8095 via a tunnel.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fe6c49889c03 myhttpd "httpd-foreground" 20 hours ago Up 20 hours 0.0.0.0:8095->80/tcp, :::8095->80/tcp my-httpd
c365e0c63a6d swaggerapi/swagger-editor:v5.0.0-alpha.88-unprivileged "/docker-entrypoint.…" 23 hours ago Up 23 hours 0.0.0.0:8090->8080/tcp, :::8090->8080/tcp dreamy_wu
When I import the main OAS file
http://localhost:8095/openapi-test.yaml
which uses remote refs, content is loaded but the editor reports CORS errors for incorrect resource
ref https://smartbear.com/openapi-test-comp.yaml
The correct ref URL would be
https://localhost:8095/openapi-test-comp.yaml
as seen below in the browser:
Any suggestion on how to avoid/resolve this error?
Thanks
openapi-test.yaml:
openapi: 3.0.3
info:
title: Test - OpenAPI 3.0
description: |-
_draft_
termsOfService: http://swagger.io/terms/
contact:
email: apiteam@test.com
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.0
paths:
/api/orders/{orderId}:
put:
tags:
- test
summary: Update an order
description: Update an order
operationId: updateOrder
parameters:
- $ref: 'openapi-test-comp.yaml#/components/parameters/apiKey'
- $ref: 'openapi-test-comp.yaml#/components/parameters/orderId'
requestBody:
$ref: "openapi-test-comp.yaml#/components/requestBodies/order"
responses:
'200':
description: Successful operation
content:
application/json:
schema:
oneOf:
- $ref: 'openapi-test-comp.yaml#/components/schemas/order'
application/xml:
schema:
oneOf:
- $ref: 'openapi-test-comp.yaml#/components/schemas/order'
'400':
description: Invalid ID supplied
'404':
description: Order not found
'422':
description: Validation exception
security:
- test_auth:
- write:order
- read:order
components:
parameters:
apiKey:
name: api_key
in: header
description: ''
required: true
schema:
type: string
example: "7885007453a84ba59aa846b27ad7deb0"
orderId:
name: orderId
in: path
description: ID of order
required: true
schema:
type: string
schemas:
order:
type: object
required:
- id
- name
properties:
id:
type: string
example: 5d7d95a7-1d0e-4493-9558-0ad621b69ac5
name:
type: string
ApiResponse:
type: object
properties:
code:
type: integer
format: int32
type:
type: string
message:
type: string
xml:
name: '##default'
requestBodies:
order:
description: order that needs to be added
required: true
content:
application/json:
schema:
oneOf:
- $ref: 'openapi-test-comp.yaml#/components/schemas/order'
application/xml:
schema:
oneOf:
- $ref: 'openapi-test-comp.yaml#/components/schemas/order'
application/x-www-form-urlencoded:
schema:
oneOf:
- $ref: 'openapi-test-comp.yaml#/components/schemas/order'
securitySchemes:
test_auth:
type: oauth2
flows:
implicit:
authorizationUrl: https://test.com/authorize
scopes:
write:order: modify order
read:order: read order
api_key:
type: apiKey
name: api_key
in: header
openapi-test-comp.yaml:
components:
parameters:
apiKey:
name: api_key
in: header
description: ''
required: true
schema:
type: string
example: "7885007453a84ba59aa846b27ad7deb0"
orderId:
name: orderId
in: path
description: ID of order
required: true
schema:
type: string
schemas:
order:
type: object
required:
- id
- name
properties:
id:
type: string
example: 5d7d95a7-1d0e-4493-9558-0ad621b69ac5
name:
type: string
ApiResponse:
type: object
properties:
code:
type: integer
format: int32
type:
type: string
message:
type: string
xml:
name: '##default'
requestBodies:
order:
description: order that needs to be added
required: true
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/order'
application/xml:
schema:
oneOf:
- $ref: '#/components/schemas/order'
application/x-www-form-urlencoded:
schema:
oneOf:
- $ref: '#/components/schemas/order'
securitySchemes:
test_auth:
type: oauth2
flows:
implicit:
authorizationUrl: https://test.com/authorize
scopes:
write:order: modify order
read:order: read order
api_key:
type: apiKey
name: api_key
in: header