knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.58k stars 280 forks source link

[BUG]: Changing output_path for type=static does not work as expected #778

Open dfsmania opened 6 months ago

dfsmania commented 6 months ago

Scribe version

4.27.0

PHP version

8.1.2

Framework

Laravel

Framework version

10.38.1

Scribe config

title => "My custom title"
static.output_path => "public/docs/api"
auth.enabled => true
auth.default => true
auth.name => "my_key"
auth.placeholder => "{YOUR_ACCESS_KEY}"
logo => "../path/to-logo.png"

What happened?

Changing the output_path config value (for type=static) does not work as expected when accessing the API documentation using the URL.

For example, if I change my output_path to public/docs/api, the documentation is correctly created in that folder:

public/docs/api/
├── collection.json
├── css
│   ├── theme-default.print.css
│   └── theme-default.style.css
├── images
│   └── navbar.png
├── index.html
├── js
│   ├── theme-default-4.27.0.js
│   └── tryitout-4.27.0.js
└── openapi.yaml

However, when accessing the URL: http://<my_domain>/docs/api all the assets can't be loaded and the site is not rendered neither working correctly:

Screenshot from 2023-12-28 12-00-31

As you can see, they are still loaded from http://<my_domain>/docs (the default output_path value).

On the other hand, opening the file index.html in a browser works as expected.

Docs

dfsmania commented 6 months ago

Update

Sorry for this, after playing a while I realize that for my case: 'type'='static' and 'output_path'='public/docs/api', I should access the URL with full path and it works correctly: http://<my_site>/docs/api/index.html. Actually, using 'http://<my_site>/docs/api/' works fine too, i.e, with an ending slash symbol.

So, I can only suggest to add this tip on the documentation for future readers. Also, you may also change the default output paths to something like public/docs/api (type=static) and /docs/api (type=laravel). This way, by default the package may live easily with other documentations, in my case I have an ERD diagram of the database on the public/docs/erd folder.