Apiclient: paths are relative to server url?

Hi!

I’m using the client to make requests to an existing API - and so far it’s amazing!

One confusion I’ve run into though is that the paths don’t seem to be appended to the servers url. They are treated as absolute paths on the server.

If the servers url ends in /api/v1/ and a path entry is /article, I’d expect to see /api/v1/article - instead I see /article

The OpenAPI spec is clear that the paths will be appended to the server url.

Here’s an example.

Schema:

openapi: 3.0.0
info:
title: Relative Paths
version: ‘1.0’
description: An example for relative paths
servers:

  • url: https://example.com/rest/v1
    description: Example API
    paths:
    /relative/path:
    get:
    summary: This path should be appended to the complete server URL.
    operationId: relative

Code:

import apistar

import requests
import logging
import os

from http.client import HTTPConnection
HTTPConnection.debuglevel = 1

logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger(“urllib3”)
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

schema = open(os.path.join(
os.path.dirname(os.path.abspath(file)),
‘schema.yaml’
)).read()

client = apistar.Client(schema=schema)
client.request(‘relative’)

The debugging output shows:

“GET /relative/path HTTP/1.1” 404 606

Thanks in advance!

Aaron