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

file_put_contents(public/docs/openapi.yaml): Failed to open stream: No such file or directory #793

Closed hanspagel closed 3 months ago

hanspagel commented 5 months ago

Scribe version

4.29.0

PHP version

8.2.11

Framework

Laravel

Framework version

10.28.0

Scribe config

type => "external_static"
theme => "scalar"

What happened?

It works fine with the default config, but with external_static and scalar it throws an error when I run php artisan scribe:generate:

 file_put_contents(public/docs/openapi.yaml): Failed to open stream: No such file or directory

  at vendor/knuckleswtf/scribe/src/Writing/Writer.php:100
     96▕
     97▕             $spec = $this->generateOpenAPISpec($parsedRoutes);
     98▕             if ($this->isStatic) {
     99▕                 $specPath = "{$this->staticTypeOutputPath}/openapi.yaml";
  ➜ 100▕                 file_put_contents($specPath, $spec);
    101▕             } else {
    102▕                 $outputPath = $this->paths->outputPath('openapi.yaml');
    103▕                 Storage::disk('local')->put($outputPath, $spec);
    104▕                 $specPath = Storage::disk('local')->path($outputPath);

Docs

shalvah commented 4 months ago

I guess we need to create the public/docs directory first...🤔

mikeah2011 commented 3 months ago

done

composer.json

  ... 
  scripts

      "post-install-cmd": [
          "mkdir -p public/docs",
          "@php artisan scribe:generate"
      ],
shalvah commented 3 months ago

Yeah, would appreciate a PR to fix that in the package.

mikeah2011 commented 3 months ago

done https://github.com/knuckleswtf/scribe/pull/829