Skip to content

Commit

Permalink
Refactor example code to avoid text on stdout (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann authored Apr 17, 2022
1 parent 24b2337 commit 3e41d60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Examples/polymorphism/polymorphism-3.1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ components:
type: string
type:
type: string
const: 'Virtual'
const: Virtual
FlResponsible:
allOf:
-
Expand Down
35 changes: 15 additions & 20 deletions Examples/using-refs/OpenApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ class OpenApiSpec
{
}

?>
You can define top-level parameters which can be references with $ref="#/components/parameters/$parameter"
<?php

/**
* You can define top-level parameters which can be references with $ref="#/components/parameters/parameter".
*
* @OA\Parameter(
* parameter="product_id_in_path_required",
* name="product_id",
Expand Down Expand Up @@ -45,16 +43,16 @@ class ProductRequestBody
{
}

?>
You can define top-level responses which can be references with $ref="#/components/responses/$response"

I find it usefull to add @OA\Response(ref="#/components/responses/todo") to the operations when i'm starting out with writting the swagger documentation.
As it bypasses the "@OA\Get() requires at least one @OA\Response()" error and you'll get a nice list of the available api calls in swagger-ui.

Then later, a search for '#/components/responses/todo' will reveal the operations I haven't documented yet.
<?php

/**
* You can define top-level responses which can be references with $ref="#/components/responses/response".
*
* I find it useful to add `@OA\Response(ref="#/components/responses/todo")` to the operations when i'm starting out with
* writing the swagger documentation.
* As it bypasses the `@OA\Get()` it requires at least one `@OA\Response()` error and you'll get
* a nice list of the available api calls in swagger-ui.
*
* Then later, a search for '#/components/responses/todo' will reveal the operations I haven't documented yet.
*
* @OA\Response(
* response="product",
* description="All information about a product",
Expand All @@ -75,14 +73,11 @@ class TodoResponse
{
}

?>

And although definitions are generally used for model-level schema's' they can be used for smaller things as well.
Like a @OA\Schema, @OA\Property or @OA\Items that is uses multiple times.

<?php

/**
* And although definitions are generally used for model-level schema's' they can be used for smaller things as well.
*
* Like a `@OA\Schema`, `@OA\Property` or `@OA\Items` that is uses multiple times.
*
* @OA\Schema(
* schema="product_status",
* type="string",
Expand Down

0 comments on commit 3e41d60

Please sign in to comment.