swagger-api / swagger-api/swagger-codegen
[PHP] Separate `host` into `host` and `basePath`
Open
Nobody has claimed this yet.
Client: PHP
General: Suggestion
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated PHP client's Swagger\Client\Configuration class and trace how host and basePath from the Swagger definition are combined for TestApi requests. Implement the requested host, basePath, and baseUrl behavior, then verify that changing the host preserves the configured path and that requests no longer return 404.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100