浏览代码

Bugfix in OAS generation: use correct `in` value for header security scheme

shalvah 4 年之前
父节点
当前提交
896c2132ad
共有 3 个文件被更改,包括 4 次插入11 次删除
  1. 1 0
      config/scribe.php
  2. 1 1
      docs/generating-documentation.md
  3. 2 10
      src/Writing/OpenAPISpecWriter.php

+ 1 - 0
config/scribe.php

@@ -117,6 +117,7 @@ INTRO
      * For 'static' docs, the collection will be generated to public/docs/collection.json.
      * For 'laravel' docs, it will be generated to storage/app/scribe/collection.json.
      * Setting `laravel.add_routes` to true (above) will also add a route for the collection.
+     * Collection schema: https://schema.getpostman.com/json/collection/v2.0.0/collection.json
      */
     'postman' => [
         'enabled' => true,

+ 1 - 1
docs/generating-documentation.md

@@ -23,7 +23,7 @@ You can configure Postman collection generation in the `postman` section of your
 
 - To turn it off, set the `postman.enabled` config option to false.
 
-- To override some fields in the generated collection, set the `openapi.overrides` config option to your changes. You can use dot notation to update specific nested fields. For instance, `['info.version' => '2.0.0']` will override the 'version` key in the 'info` object whenever generating.
+- To override some fields in the generated collection, set the `postman.overrides` config option to your changes. You can use dot notation to update specific nested fields. For instance, `['info.version' => '2.0.0']` will override the 'version` key in the 'info` object whenever generating.
 
 - The base URL used in the Postman collection is the value of `config('app.url')` by default. To change this, set the value of the `postman.base_url` key.
 

+ 2 - 10
src/Writing/OpenAPISpecWriter.php

@@ -398,10 +398,11 @@ class OpenAPISpecWriter
 
         switch ($location) {
             case 'query':
+            case 'header':
                 $scheme = [
                     'type' => 'apiKey',
                     'name' => $parameterName,
-                    'in' => 'query',
+                    'in' => $location,
                     'description' => '',
                 ];
                 break;
@@ -414,15 +415,6 @@ class OpenAPISpecWriter
                     'description' => '',
                 ];
                 break;
-
-            case 'header':
-                $scheme = [
-                    'type' => 'header',
-                    'name' => $parameterName,
-                    'in' => 'header',
-                    'description' => '',
-                ];
-                break;
                 // OpenAPI doesn't support auth with body parameter
         }