Untitled

 avatar
unknown
plain_text
2 years ago
1.4 kB
6
Indexable
<?php

use OpenApi\Attributes as OA;

#[OA\Info(
    title: "My API",
    version: "1.0.0",
    description: "An example API",
    contact: #[OA\Contact(email: "support@example.com")]
)]
#[OA\SecurityScheme(
    type: "http",
    scheme: "bearer",
    bearerFormat: "JWT"
)]
class MyAPI {
    #[OA\Get(
        path: "/v4/search",
        summary: "Search listings",
        operationId: "searchListings",
        responses: #[OA\Responses(
            responses: [
                "200" => #[OA\Response(
                    responseCode: "200",
                    description: "Search results",
                    content: #[OA\MediaType(
                        mediaType: "application/json",
                        schema: #[OA\Schema(ref: SearchParams::class)]
                    )]
                )]
            ]
        )],
        parameters: #[OA\Parameter(
            name: "q_paginate",
            in: "query",
            description: "Whether to paginate the results",
            required: false,
            schema: #[OA\Schema(type: "integer")]
        )],
        security: #[OA\SecurityRequirement(
            securitySchemeName: "bearerAuth",
            scopes: []
        )]
    )]
    public function searchListings(SearchParams $params): array {
        // Implement your search functionality here...
    }
}
Editor is loading...