Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Api Root in " #7

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open

Wrong Api Root in " #7

weierophinney opened this issue Dec 31, 2019 · 1 comment

Comments

@weierophinney
Copy link
Contributor

Let's say my apigility runs under http://example.com/api, with a service /test thus available under http://example.com/api/test. My issue: The buttons to "Try it out!" are sending their requests to http://example.com/test, which ofc will result in a 500 error every time.

I found that I could fix this in this module's Service.php by modifying $this->baseUrl (appending '/api'), but obviously that's not the intended way to do it.

So is this something I am doing wrong (and if so, how do I do it right?) or something the module is doing wrong?


Originally posted by @marartner at zfcampus/zf-apigility-documentation-swagger#32

@iamandersonp
Copy link

i managed to make a workarround to fix this isue since i'm using the swagger tool

in src/Service.php

change the method getPaths() as follow

  private function getPaths() {
    $base = str_replace("index.php", "", $_SERVER['PHP_SELF']);

    $route = $this->getRouteWithReplacements();
    if ($this->isRestService()) {
      return $this->getRestPaths($route);
    }
    $sin = str_replace("/", "", $route);
    $ret = $base . $sin;
    return $this->getOtherPaths($ret);
  }

this way the swagger will automatically change all yours endpoints to the correct path in your sub directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants