giansalex/swagger-objects

PHP Object to Swagger Definitions

v1.1.1 2023-01-13 17:10 UTC

This package is auto-updated.

Last update: 2024-11-13 21:22:31 UTC


README

Travis-CI

PHP Objects to Swagger Definitions.

Install

Via Composer from packagist.org.

composer require giansalex/swagger-objects

Php object

class Document
{
    /**
     * @var string
     */
    private $tipoDoc;

    /**
     * @var string
     */
    private $nroDoc;

    /**
     * @return string
     */
    public function getTipoDoc()
    {
        return $this->tipoDoc;
    }

    /**
     * @param string $tipoDoc
     * @return Document
     */
    public function setTipoDoc($tipoDoc)
    {
        $this->tipoDoc = $tipoDoc;
        return $this;
    }

    /**
     * @return string
     */
    public function getNroDoc()
    {
        return $this->nroDoc;
    }

    /**
     * @param string $nroDoc
     * @return Document
     */
    public function setNroDoc($nroDoc)
    {
        $this->nroDoc = $nroDoc;
        return $this;
    }
}

Usage

$swagger = new Swagger();
$result = $swagger->fromClass(Document::class);

var_dump();

Result

[
'definitions' => [
    'Document' => [
        'type' => 'object',
        'properties' => [
            'tipoDoc' => [
                'type' => 'string'
            ],
            'nroDoc' => [
                'type' => 'string'
            ]
        ]
    ]
  ]
]