Giter VIP home page Giter VIP logo

asyncapi-php-template's People

Contributors

nickshoe avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

andreadangel1

asyncapi-php-template's Issues

[Bug Report] - Additional "AnonymousSchema" php classes after code generation

Environment details
-PHP version: 8.1.16

Description
After the php code generation, it will be created a class named "AnonymousSchema" for every schema that inherits its properties from another one.

Example
I have two object-type schemas into the asyncapi .yaml file:

DomainEvent:
      type: object
      discriminator: _type
      required:
        - _type
        - id
        - createdAt
      properties:
        _type:
          type: string
          readOnly: true
        id:
          type: string
          readOnly: true
        createdAt:
          type: string
          format: date-time
          example: '2012-04-23T18:25:43.511Z'
          readOnly: true
    UserPasswordResetEvent:
      description: A user password reset event.
      allOf:
        - $ref: "#/components/schemas/DomainEvent"
        - type: object
          required:
            - user
            - tempPassword
          properties:
            user:
              $ref: "#/components/schemas/User"
            tempPassword:
              type: string

In this example, "UserPasswordResetEvent" inherits its properties from "DomainEvent".
After generating the "UserPasswordResetEvent" php class, it will be created another php class named "AnonymousSchema8.class.php". The last one is identical to the first one, exept for missing the hereditariness from "AnonymousSchema8.class.php" and "DomainEvent.class.php"

[Bug Report] - Missing annotation for an array property after code generation

Environment details
-PHP version: 8.1.16
-Message broker: RabbitMQ

Description
If I have a schema with an array type property, the code generation will not add the annotation for that one into the PHP class.
JMS will not be able to deserialize the array property during the subscription of the message and will give a PHP Fatal error.

Example
I have an object-type schema like this into the asyncapi .yaml file:

Email:
      type: object
      properties:
        subject:
          type: string
        body:
          type: string
        recipients:
          type: array
          items:
            type: string

From this schema, it will be generated a model called "Email.class.php" with these 3 properties:

<?php

namespace AsyncAPI\Models;

class Email
{

  private string $subject;
  private string $body;
  private array $recipients;
...
...
...

Now, we publish an event with an "Email" object like this:

$event = new EmailEvent(
    new Email(
        'Password expired!',
        'Hi, your password has been expired',
        ['[email protected]','[email protected]']
    ),
    ...
    ...
);

Then, If we try to subscribe the message from RabbitMQ, it will give this error:
PHP Fatal error: Uncaught JMS\Serializer\Exception\RuntimeException: You must define a type for AsyncAPI\Models\Email::$recipients.

Workaround
Add this code to the class. In this example, it will be the Email class:

<?php

namespace AsyncAPI\Models;

use JMS\Serializer\Annotation as Serializer; //this

class Email
{

  private string $subject;
  private string $body;
  /**
  * @Serializer\Type("array<string>")  //and this
  */
  private array $recipients;
...
...
...

[Bug Report] - Unhandled schema type 'boolean'

Environment details
-PHP version: 8.1.16

Description
If I have a schema with a boolean type property, the code won't be generated. It will instead give an error in the console log.

Example
I have an object-type schema like this into the asyncapi .yaml file, with the "superUser" boolean property:

User:
      type: object
      required:
        - id
        - firstName
        - lastName
        - email
      properties:
        id:
          type: integer
        firstName:
          type: string
        lastName:
          type: string
        email:
          type: string
          format: email
        dateOfBirth:
          type: string
          format: date
        superUser:
          type: boolean

If we go to the console log after launching the code generation prompt, we will see this error:

Something went wrong:
Error: Unhandled schema type 'boolean'.
    at ClassHierarchyEvaluator.determineSchemaClass

As the error says, the boolean type is not handled in the "class-hierrachy-evaluator.js" file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.