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

add str replace for external_laravel with theme "elements" #906

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cleeimpro
Copy link

Added another str_replace so that the case for external_laravel with the theme "elements" is also matched.

Without the new str_replace the following is generated in the index.blade.php file:
<elements-api apiDescriptionUrl="../docs/openapi.yaml" ...
With the new str_replace the relative url is replaced with a route:
<elements-api apiDescriptionUrl="{{ route("scribe.openapi") }}" ...

The problem only occurs if laravel.docs_url is changed manually.
Then the openapi.yaml-file cannot be found.

This is not a problem with scalar and rapidoc, as the attribute (e.g. data-url) matches a lowercase ‘url’ correctly.

@@ -178,6 +178,7 @@ protected function performFinalTasksForLaravelType(): void
$contents = str_replace('href="../docs/collection.json"', 'href="{{ route("' . $this->paths->outputPath('postman', '.') . '") }}"', $contents);
$contents = str_replace('href="../docs/openapi.yaml"', 'href="{{ route("' . $this->paths->outputPath('openapi', '.') . '") }}"', $contents);
$contents = str_replace('url="../docs/openapi.yaml"', 'url="{{ route("' . $this->paths->outputPath('openapi', '.') . '") }}"', $contents);
$contents = str_replace('Url="../docs/openapi.yaml"', 'Url="{{ route("' . $this->paths->outputPath('openapi', '.') . '") }}"', $contents);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$contents = str_replace('Url="../docs/openapi.yaml"', 'Url="{{ route("' . $this->paths->outputPath('openapi', '.') . '") }}"', $contents);
// With Elements theme, we'd have <elements-api apiDescriptionUrl="../docs/openapi.yaml"
$contents = str_replace('Url="../docs/openapi.yaml"', 'Url="{{ route("' . $this->paths->outputPath('openapi', '.') . '") }}"', $contents);

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

Successfully merging this pull request may close these issues.

2 participants