Browse Source

Start on migration doc

shalvah 4 years ago
parent
commit
b79154fb74
4 changed files with 89 additions and 8 deletions
  1. 4 4
      config/scribe.php
  2. 8 4
      docs/index.md
  3. 75 0
      docs/migrating-v2.md
  4. 2 0
      docs/migrating.md

+ 4 - 4
config/scribe.php

@@ -52,13 +52,13 @@ return [
      */
     'auth' => [
         /*
-         * Set this to true if any endpoints in your API are authenticated.
+         * Set this to true if any endpoints in your API uses authentication.
          */
         'enabled' => false,
 
         /*
-         * Set this to true if your API is authenticated by default.
-         * You can also use @unauthenticated or @authenticated on individual methods to change their status.
+         * Set this to true if your API should be authenticated by default.
+         * You can then use @unauthenticated or @authenticated on individual endpoints to change their status.
          */
         'default' => false,
 
@@ -290,7 +290,7 @@ INTRO
 
                     /*
                      * Files which should be sent with the API call.
-                     * Each value should be a valid absolute path to a file on this machine.
+                     * Each value should be a valid path (absolute or relative to your project directory) to a file on this machine.
                      */
                     'fileParams' => [
                         // 'key' => '/home/me/image.png',

+ 8 - 4
docs/index.md

@@ -4,16 +4,20 @@ Generate API documentation for humans from your Laravel/Lumen/[Dingo](https://gi
 
 
 ```eval_rst
-.. admonition:: Wondering where to get started?
+.. admonition:: Wondering where to get started? Try one of these links:
    
-   If you're coming from mpociot/laravel-apidoc-generator, check out `what's new <whats-new.html>`_ and the `migration guide <migrating.html>`_. Otherwise, check out the `getting started guide <guide-getting-started.html>`_.
+   - `what's new in v2 <migrating-v2.html>`_
+   - `migrating from mpociot/laravel-apidoc-generator <migrating.html>`_, or
+   - the `getting started guide <guide-getting-started.html>`_.
 ```
 
 ```eval_rst
 .. Tip:: Looking to document your Node.js APIs? Check out `Scribe for JS <https://github.com/knuckleswtf/scribe-js>`_.
 ```
+
 ## Features
 - Pretty HTML documentation page, with included code samples and friendly text
+- Included "Try It Out" button so users can test your API
 - Markdown source files that can be edited to modify docs
 - Extracts body parameters information from FormRequests
 - Safely calls API endpoints to generate sample responses, with authentication and other custom configuration supported
@@ -29,7 +33,7 @@ Generate API documentation for humans from your Laravel/Lumen/[Dingo](https://gi
    :maxdepth: 2
 
    guide-getting-started
-   whats-new
+   migrating-v2
    migrating
    documenting/index
    generating-documentation
@@ -42,7 +46,7 @@ Generate API documentation for humans from your Laravel/Lumen/[Dingo](https://gi
 ```
 
 ## Installation
-PHP 7.2.5 and Laravel/Lumen 5.8 or higher are required.
+PHP 7.2.5 and Laravel/Lumen 6 or higher are required.
 
 ```sh
 composer require --dev knuckleswtf/scribe

+ 75 - 0
docs/migrating-v2.md

@@ -0,0 +1,75 @@
+Scribe 2 comes with a bunch of changes focused on making the documentation process easier and the output better. Some of these changes were introduced in recent minor versions, so we'll highlight them here in case you missed them.
+
+- "Try It Out" button gives you free interactive documentation 
+
+## The new `description` field replaces `postman.description`
+The `description` field, where you can add a description of your API. This field will be used in the following ways:
+- as the `info.description` field in the Postman collection
+- as the `info.description` field in the OpenAPI spec
+- as the first paragraph under the "Introduction" section on the webpage, before the `intro_text`
+
+Since we've added this field, we've removed the Postman-specific `postman.description`.
+
+## `postman.auth` has been removed in favour of `postman.overrides`
+We've removed `postman.auth`. It didn't make sense to have two ways of setting Postman-specific auth information (`postman.auth` and `postman.overrides`).
+
+How to migrate: If you need to set Postman-specific auth now, use an `auth` key in `postman.overrides`:
+
+```php
+'postman' => [
+  'overrides' => [
+    'auth' => [], // your auth info
+  ]
+]
+```
+
+
+## Types are now supported for URL and query parameters
+Previously, you couldn't specify types for URL and query parameters. The idea was that it didn't make sense, since they're all passed as strings in the URL anyway. But we've changed that. The thinking now is that these types can pass semantic information to your API consumers—even though they're strings in the URL, they have actual significance outside of that. You can now pass types for URL and query parameters.
+
+How to migrate:
+If you don't want to use this, no problem! All URL and query parameters will remain `string` by default. If you'd like to add types, just specify a type with @urlParam and @queryParam like you'd  do with @bodyParam (after the parameter name).
+
+If you have custom strategies, you should update them
+
+## New syntax for array and object parameters
+The old dot notation syntax was based on Laravel's validation syntax. However, it had a few limitations in our case. It wasn't well-thought out, and was based on PHP semantics rather than JSON, which meant it didn't fit really well for documenting types. The new syntax uses some elements of the old.
+
+How to migrate: 
+
+Description | Old | New
+-----------|------|---------
+To denote an array `cars` of elements of type x | cars array, cars.* x | cars x[]
+To denote an object `cars` | cars object | cars object
+To denote an object `cars` with fields | cars object, cars.name string | cars object, cars.name string
+To denote an array of objects `cars` with fields | cars.* object, cars.*.name string | cars object[], cars[].name string
+
+Replace `.*.` in docblocks with '[].'
+Replace `.*` in docblocks with `[]` appended to the type name 
+Ensure there's parent object for object fields
+
+## add_routes: Postman collection route renamed
+When you use `laravel` type docs and have `add_routes` set to `true`, you'll have three routes added to your Laravel app: one for the webpage, one for the Postman collection and one for the OpenAPI spec. The route for the Postman collection was previously named `scribe.json`, but has now been renamed to `scribe.postman`, to bring it in line with the OpenAPI route, which is named `scribe.openapi`.
+
+## Switch Postman base URL to use variables
+Postman collection base URL now uses a variale, so you can change the base URL for all endpoints in your collection easier.
+
+## Represent object/array fields better in docs
+
+## New config file structure
+
+- title
+- description
+- output => 
+    'webpage' => type, intro_text, output_path, logo, etc
+    'postman' =>
+    'openapi' => 
+   ]
+   
+   
+   
+   ## `auth.default` key added
+   
+   # API: include 'name' in parameter details
+   
+   ## @responseFile supports other directories

+ 2 - 0
docs/migrating.md

@@ -1,6 +1,8 @@
 # Migrating from mpociot/laravel-apidoc-generator to Scribe v1
 There's quite a few changes in Scribe, and this guide aims to show you the key parts you need to look out for so things don't break. After migrating, you should also check out the [list of new features](./whats-new.html).
 
+> Note: this guide describes how to migrate to Scribe version 1. Scribe 2 is the current release, so you should follow the [migration guide](./migrating-v2.html) for that when you're done with this.
+
 ## Requirements
 - PHP version: 7.2.5+
 - Laravel/Lumen version: 5.8+