OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.86k stars 6.59k forks source link

[BUG] [PHP] php-ze-ph generated operation cannot access description #3152

Open agrizzli opened 5 years ago

agrizzli commented 5 years ago

Bug Report Checklist

Description

php-ze-ph module templates use {{description}} variable in api.mustache to provide description for each operation. However this description won't be available in template, since guard {{#description}} does not twig:

{{#description}}
     * {{description}}
{{/description}}
openapi-generator version

4.0.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
    description: 'Test description'
    version: 1.0.0
    title: 'Test'
paths:
    /example_item:
        post:
            tags:
                - ExampleItem
            operationId: addExampleItem
            summary: 'Add new example item'
            description: 'Adds example item to the system'
            requestBody:
              description: 'Example item to add'
              content:
                  application/json:
                      schema:
                          $ref: '#/components/schemas/ExampleItem'

            responses:
                201:
                    description: 'Item created'
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/ExampleItem'
components:
  schemas:
    ExampleItem:
        type: object
        required:
            - example_string
        properties:
            id:
                type: integer
                readOnly: true
                example: 1
            example_string:
                type: string
                maxLength: 6
                pattern: '[0-9]{4,6}'
                example: 'Some string contents'
Command line used for generation
npx openapi-generator generate -Dapis='/example_item' -i spec/openapi/api-v1.yml -g php-ze-ph -o .
Steps to reproduce
/**
 * @PHA\Route(pattern="/example_item")
 */
class ExampleItem
{
    /**
     * Add new example item
     * @PHA\Post()
     * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
     * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json")
     * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\ExampleItem::class,"objectAttr":"bodyData"})
     * TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
     * @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
     * @param ServerRequestInterface $request
     *
     * @throws PHException\HttpCode 501 if the method is not implemented
     *
     * @return \App\DTO\ExampleItem
     */
    public function addExampleItem(ServerRequestInterface $request): \App\DTO\ExampleItem
    {
        //TODO implement method
        /** @var \App\DTO\ExampleItem $bodyData */
        $bodyData = $request->getAttribute("bodyData");
        throw new PHException\HttpCode(501, "Not implemented");
    }
Related issues/PRs
Suggest a fix
auto-labeler[bot] commented 5 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

jbtrystram commented 4 years ago

I am seeing the same issue on the asciidoc generator. The description isn't accessible from each operation and endpoint context. The field is properly parsed because adding {{this}} outside of the {{#apiInfo}} loop does outputs the description field in the path objects.