Skip to content

[PHP] Separate host into host and basePath #5841

@ackintosh

Description

@ackintosh
Description

Problem

swagger: "2.0"
info:
  title: TEST API
  version: ""
host: aaa.example.com
basePath: /private
$c = new Swagger\Client\Configuration();

$c->getHost();// string "http://aaa.example.com/private"

// `/private` WILL BE LOST...
$c->setHost('http://bbb.example.com');

$c->getHost();// string "http://bbb.example.com"

$api = new Swagger\Client\Api\TestApi(null, $c);
$api->getXXX();
// 404 Not Found

I'd like to improve Configuration as follows.

  • new methods
    • Configuration::setBasePath()
    • Configuration::getBasePath()
    • Configuration::getBaseUrl()
/*
 * setter
 */
// Only the `host` is changed.
$c->setHost('http://bbb.example.com');
// If we want to change the `basePath`, like this.
$c->setBasePath('/public');

/*
 * getter
 */
$c->getHost();
// string "http://bbb.example.com"
$c->getBasePath();
// string "/public"
$c->getBaseUrl();
// string "http://bbb.example.com/public"
Swagger-codegen version

2.3.0


Please let me know what you think.
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions