Skip to content

adding attribute examples #1699

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

Merged
merged 46 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
db238f2
add in faq
natsuki-engr Feb 4, 2025
10d4922
OAT to OA
natsuki-engr Feb 11, 2025
c0d15f4
x-tagGroups
natsuki-engr Feb 17, 2025
92e2948
response examples
natsuki-engr Feb 17, 2025
5279f0e
external docs
natsuki-engr Feb 18, 2025
3dac190
union types
natsuki-engr Feb 19, 2025
014f798
security schemes
natsuki-engr Feb 22, 2025
6cf387f
secure endpoint
natsuki-engr Feb 22, 2025
e9c79c4
multiple security schemes
natsuki-engr Mar 3, 2025
7ac5462
file upload
natsuki-engr Mar 28, 2025
5a713f2
add success response description in attribute example
natsuki-engr Apr 15, 2025
9da2add
xml content response
natsuki-engr Apr 16, 2025
f222208
upload multipart/form-data
natsuki-engr Apr 16, 2025
6894ed5
nested structure with @OA\Property
natsuki-engr Apr 25, 2025
7821474
expression of single or list by oneOf
natsuki-engr Apr 25, 2025
b341a18
reusing responses
natsuki-engr May 7, 2025
80f6ff9
callbacks
natsuki-engr May 7, 2025
8c166af
virtual model
natsuki-engr May 7, 2025
b902bb8
class name as type
natsuki-engr May 7, 2025
bf2837a
enums
natsuki-engr May 7, 2025
a918967
multi value query parameter
natsuki-engr May 7, 2025
61b4348
custom response classes
natsuki-engr May 7, 2025
5d37e10
class constants
natsuki-engr May 7, 2025
10b6f3e
fix wrong id
natsuki-engr May 7, 2025
72d01d3
rename wrong file name
natsuki-engr May 7, 2025
f5c6f64
context awareness
natsuki-engr May 7, 2025
7762311
response MediaType and JsonContent
natsuki-engr May 7, 2025
3b3596b
using $ref
natsuki-engr May 7, 2025
40c9a98
custom property
natsuki-engr May 7, 2025
e052848
enum as values
natsuki-engr May 7, 2025
ae962ba
backed enum names as schema
natsuki-engr May 7, 2025
71fd7d0
backed enum values as schema
natsuki-engr May 7, 2025
eb50568
replace singlequote to double quote
natsuki-engr May 7, 2025
d57f1a7
enum as schema
natsuki-engr May 7, 2025
7f824e4
Merge remote-tracking branch 'origin/master' into doc-add-attribute-e…
natsuki-engr May 8, 2025
341c15c
fix errors
natsuki-engr May 9, 2025
64ba8bb
fix syntax error
natsuki-engr May 12, 2025
cac0c6b
fix syntax error
natsuki-engr May 12, 2025
c36bc1c
remove tabs of custom response example
natsuki-engr May 12, 2025
447f406
fix syntax error
natsuki-engr May 12, 2025
db91eea
move example file into inline
natsuki-engr May 12, 2025
e04d06b
add referred schema
natsuki-engr May 12, 2025
d543878
add use statement
natsuki-engr May 13, 2025
c6390d5
Merge remote-tracking branch 'origin/master' into doc-add-attribute-e…
natsuki-engr May 13, 2025
75d06b7
add docs/snippets to CS
natsuki-engr May 13, 2025
66d7e95
apply style of code_sniffer to docs/snippets
natsuki-engr May 13, 2025
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
33 changes: 12 additions & 21 deletions docs/guide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,18 @@ related code, the info annotation (and a few more) is kind of global.
The simplest solution to avoid this issue is to add a 'dummy' class to the docblock and add
all 'global' annotations (e.g. `Tag`, `Server`, `SecurityScheme`, etc.) **in a single docblock** to that class.

```php
/**
* @OA\Tag(
* name="user",
* description="User related operations"
* )
* @OA\Info(
* version="1.0",
* title="Example API",
* description="Example info",
* @OA\Contact(name="Swagger API Team")
* )
* @OA\Server(
* url="https://example.localhost",
* description="API server"
* )
*/
class OpenApiSpec
{
}
```
<codeblock id="dummy-class">
<template v-slot:at>

<<< @/snippets/guide/faq/dummy_class_at.php

</template>
<template v-slot:an>

<<< @/snippets/guide/faq/dummy_class_an.php

</template>
</codeblock>

**As of version 4.8 the `doctrine/annotations` library is optional and might cause the same message.**

Expand Down
21 changes: 21 additions & 0 deletions docs/snippets/guide/faq/dummy_class_an.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* @OA\Tag(
* name="user",
* description="User related operations"
* )
* @OA\Info(
* version="1.0",
* title="Example API",
* description="Example info",
* @OA\Contact(name="Swagger API Team")
* )
* @OA\Server(
* url="https://example.localhost",
* description="API server"
* )
*/
class OpenApiSpec
{
}
18 changes: 18 additions & 0 deletions docs/snippets/guide/faq/dummy_class_at.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use OpenApi\Attributes as OAT;

#[OAT\Tag(name: "user", description: "User related operations")]
#[OAT\Info(
version: "1.0",
title: "Example API",
description: "Example info",
contact: new OAT\Contact(name: "Swagger API Team"),
)]
#[OAT\Server(
url: "https://example.localhost",
description: "API server",
)]
class OpenApiSpec
{
}