Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example YAML validation warnings #1114

Merged
merged 7 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Examples/example-object/example-object.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@
use OpenApi\Annotations as OA;

/**
* @OA\Tag(
* name="user",
* description="User related operations"
* )
* @OA\Info(
* version="1.0",
* title="Example for response examples value"
* title="Example for response examples value",
* description="Example info",
* @OA\Contact(name="Swagger API Team")
* )
* @OA\Server(
* url="https://example.localhost",
* description="API server"
* )
*/
class OpenApiSpec
Expand All @@ -18,6 +28,9 @@ class OpenApiSpec
* @OA\Put(
* path="/users/{id}",
* summary="Updates a user",
* description="Updates a user",
* operationId="updateUser",
* tags={"user"},
* @OA\Parameter(
* description="Parameter with mutliple examples",
* in="path",
Expand All @@ -41,6 +54,9 @@ class UserUpdateEndpoint
* @OA\Post(
* path="/users",
* summary="Adds a new user - with oneOf examples",
* description="Adds a new user",
* operationId="addUser",
* tags={"user"},
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
Expand Down
19 changes: 19 additions & 0 deletions Examples/example-object/example-object.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
openapi: 3.0.0
info:
title: 'Example for response examples value'
description: 'Example info'
contact:
name: 'Swagger API Team'
version: '1.0'
servers:
-
url: 'https://example.localhost'
description: 'API server'
paths:
'/users/{id}':
put:
tags:
- user
summary: 'Updates a user'
description: 'Updates a user'
operationId: updateUser
parameters:
-
name: id
Expand All @@ -26,7 +37,11 @@ paths:
description: OK
/users:
post:
tags:
- user
summary: 'Adds a new user - with oneOf examples'
description: 'Adds a new user'
operationId: addUser
requestBody:
content:
application/json:
Expand Down Expand Up @@ -69,3 +84,7 @@ components:
error:
type: string
type: object
tags:
-
name: user
description: 'User related operations'
37 changes: 35 additions & 2 deletions Examples/misc/misc-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

/**
* @OA\OpenApi(
* security={{"bearerAuth": {}}}
* security={{"bearerAuth": {}}},
* @OA\Tag(
* name="endpoints"
* )
* )
*
* @OA\Info(
* title="Testing annotations from bugreports",
* version="1.0.0",
* description="NOTE:
This sentence is on a new line"
This sentence is on a new line",
* @OA\Contact(name="Swagger API Team")
* )
*
* @OA\Components(
Expand Down Expand Up @@ -42,6 +46,9 @@ class OpenApiSpec
*
* @OA\Get(
* path="/api/endpoint",
* description="An endpoint",
* operationId="endpoint",
* tags={"endpoints"},
* @OA\Parameter(name="filter", in="query", @OA\JsonContent(
* @OA\Property(property="type", type="string"),
* @OA\Property(property="color", type="string"),
Expand Down Expand Up @@ -72,3 +79,29 @@ class Endpoint
class Response
{
}

/**
* Another API endpoint.
*
* @OA\Get(
* path="/api/anotherendpoint",
* description="Another endpoint",
* operationId="anotherendpoints",
* tags={"endpoints"},
* @OA\Parameter(
* name="things[]",
* in="query",
* description="A list of things.",
* required=false,
* @OA\Schema(
* type="array",
* @OA\Items(type="integer")
* )
* ),
* security={{ "bearerAuth": {} }},
* @OA\Response(response="200", ref="#/components/responses/200")
* )
*/
class MultiValueQueryParam
{
}
32 changes: 32 additions & 0 deletions Examples/misc/misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ openapi: 3.0.0
info:
title: 'Testing annotations from bugreports'
description: "NOTE:\nThis sentence is on a new line"
contact:
name: 'Swagger API Team'
version: 1.0.0
servers:
-
Expand All @@ -16,7 +18,11 @@ servers:
paths:
/api/endpoint:
get:
tags:
- endpoints
summary: 'An API endpoint.'
description: 'An endpoint'
operationId: endpoint
parameters:
-
name: filter
Expand All @@ -34,6 +40,29 @@ paths:
security:
-
bearerAuth: []
/api/anotherendpoint:
get:
tags:
- endpoints
summary: 'Another API endpoint.'
description: 'Another endpoint'
operationId: anotherendpoints
parameters:
-
name: 'things[]'
in: query
description: 'A list of things.'
required: false
schema:
type: array
items:
type: integer
responses:
'200':
$ref: '#/components/responses/200'
security:
-
bearerAuth: []
components:
responses:
'200':
Expand Down Expand Up @@ -66,3 +95,6 @@ components:
security:
-
bearerAuth: []
tags:
-
name: endpoints
18 changes: 16 additions & 2 deletions Examples/nesting/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,28 @@
/**
* An entity controller class.
*
* @OA\Info(version="1.0.0", title="Nested schemas")
* @OA\Info(
* version="1.0.0",
* title="Nested schemas",
* description="Example info",
* @OA\Contact(name="Swagger API Team")
* )
* @OA\Server(
* url="https://example.localhost",
* description="API server"
* )
* @OA\Tag(
* name="api",
* description="All API endpoints"
* )
*/
class ApiController
{
/**
* @OA\Get(
* tags={"api"},
* path="/entity/{id}",
* description="Get the entity",
* @OA\Parameter(
* name="id",
* in="path",
Expand All @@ -23,7 +37,7 @@ class ApiController
* )
* ),
* @OA\Response(
* response="default",
* response="200",
* description="successful operation",
* @OA\JsonContent(ref="#/components/schemas/ActualModel")
* )
Expand Down
15 changes: 13 additions & 2 deletions Examples/nesting/nesting.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
openapi: 3.0.0
info:
title: 'Nested schemas'
description: 'An entity controller class.'
description: 'Example info'
contact:
name: 'Swagger API Team'
version: 1.0.0
servers:
-
url: 'https://example.localhost'
description: 'API server'
paths:
'/entity/{id}':
get:
tags:
- api
description: 'Get the entity'
operationId: dd148eadcee53770e24b2350f932e3bd
parameters:
-
Expand All @@ -18,7 +25,7 @@ paths:
type: integer
format: int64
responses:
default:
'200':
description: 'successful operation'
content:
application/json:
Expand Down Expand Up @@ -53,3 +60,7 @@ components:
base:
type: string
type: object
tags:
-
name: api
description: 'All API endpoints'
22 changes: 19 additions & 3 deletions Examples/polymorphism/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,31 @@

use OpenApi\Annotations as OA;

/**
* @OA\Info(
* title="Polymorphism",
* description="Polymorphism example",
* version="1",
* @OA\Contact(name="Swagger API Team")
* )
* @OA\Tag(
* name="api",
* description="API operations"
* )
* @OA\Server(
* url="https://example.localhost",
* description="API server"
* )
*/
class Controller
{
/**
* @OA\Info(title="Polymorphism", version="1")
*
* @OA\Get(
* path="/test",
* description="Get test",
* tags={"api"},
* @OA\Response(
* response="default",
* response="200",
* description="Polymorphism",
* @OA\JsonContent(ref="#/components/schemas/Request")
* )
Expand Down
33 changes: 23 additions & 10 deletions Examples/polymorphism/polymorphism.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
openapi: 3.0.0
info:
title: Polymorphism
description: 'Polymorphism example'
contact:
name: 'Swagger API Team'
version: '1'
servers:
-
url: 'https://example.localhost'
description: 'API server'
paths:
/test:
get:
operationId: ef7f8a05d4ce52bae215869c1decc7c1
tags:
- api
description: 'Get test'
operationId: 2bf08e1a95c02130edf82da5846bfca3
responses:
default:
'200':
description: Polymorphism
content:
application/json:
Expand All @@ -18,12 +28,12 @@ components:
Responsible:
properties:
type:
nullable: false
type: string
enum:
- employee
- assignee
- fl
nullable: false
type: object
discriminator:
propertyName: type
Expand All @@ -37,25 +47,28 @@ components:
$ref: '#/components/schemas/EmployeeResponsible'
EmployeeResponsible:
allOf:
-
$ref: '#/components/schemas/Responsible'
-
properties:
property2:
nullable: false
type: string
-
$ref: '#/components/schemas/Responsible'
nullable: false
FlResponsible:
allOf:
-
$ref: '#/components/schemas/Responsible'
-
properties:
property3:
nullable: false
type: string
-
$ref: '#/components/schemas/Responsible'
nullable: false
Request:
properties:
payload:
$ref: '#/components/schemas/Responsible'
type: object

tags:
-
name: api
description: 'API operations'
Loading