Documentation

Generator
in package

Generate PHP client(s) from OpenAPI specification(s)

Table of Contents

Properties

$componentMapperFactory  : ComponentMapperFactory
$endpointMapperFactory  : EndpointMapperFactory
$logger  : LoggerInterface

Methods

__construct()  : mixed
Meant for autowired dependency-injection
generate()  : void
Generate PHP client(s) from OpenAPI specification(s)
getDefaultLogger()  : LoggerInterface
Pre-configured console logger
getBasePathFromSpec()  : string
Define base path to directory within which to generate the PHP client files.
getNamespaceFromSpec()  : string
Define base namespace to directory within which to generate the PHP client objects.
generateMapping()  : void
Generate a mapping from an OpenAPI spec to PHP client
purge()  : void
Purge directory contents

Properties

Methods

generate()

Generate PHP client(s) from OpenAPI specification(s)

public generate(string $path, string $basePath, string $baseNamespace[, bool $purge = false ]) : void
APIYes
Parameters
$path : string

Path to an individual OpenAPI specification file or a directory containing OpenAPI specifications. Directories will be recursiely spidered to find all specification files.

$basePath : string

Path to the directory in which to create the PHP client files

$baseNamespace : string

Namespace within which to generate the PHP client objects

$purge : bool = false

(Optional, default false) Purge the $basePath directory of all contents before writing the generated files (if not purged, any conflicting files will be over-written)

getDefaultLogger()

Pre-configured console logger

public static getDefaultLogger() : LoggerInterface
APIYes
Return values
LoggerInterface

A color-coded console logger

getBasePathFromSpec()

Define base path to directory within which to generate the PHP client files.

protected getBasePathFromSpec(string $specPath, OpenApi $spec, string $basePath) : string
APIYes

Override to define a base path for client file creation based on a combination of the specification itself, the path to the specification and the originally passed $basePath argument.

For example: suppose you are generating clients on a nested directory of OpenAPI specifications and want the clients to mirror the directory structure of the nested specifications.

Defaults to the $basePath argument passed to generate()

Parameters
$specPath : string

Path to an individual OpenAPI specification file

$spec : OpenApi

OpenAPI specification

$basePath : string

Path to the directory in which to create the PHP client files ($basePath argument passed to generate())

Tags
see
Generator::generate()
see
https://battis.github.io/openapi-client-generator/latest/guide/extending.html

Example

Return values
string

getNamespaceFromSpec()

Define base namespace to directory within which to generate the PHP client objects.

protected getNamespaceFromSpec(string $specPath, OpenApi $spec, string $baseNamespace) : string
APIYes

Defaults to the $baseNamespace argument passed to generate()

Parameters
$specPath : string

Path to an individual OpenAPI specification file

$spec : OpenApi

OpenAPI specification

$baseNamespace : string

Namespace within which to generate the PHP client objects ($baseNamespace argument passed to generate())

Tags
see
Generator::getBasePathFromSpec()

for proposed usage

see
Generator::generate()
see
https://battis.github.io/openapi-client-generator/latest/guide/extending.html

Example

Return values
string

generateMapping()

Generate a mapping from an OpenAPI spec to PHP client

private generateMapping(OpenApi $spec, string $basePath, string $baseNamespace[, bool $purge = false ]) : void
Parameters
$spec : OpenApi

OpenAPI specification

$basePath : string

Path to the directory in which to create the PHP client files

$baseNamespace : string

Namespace within which to generate the PHP client objects

$purge : bool = false

(Optional, default false) Purge the $basePath directory of all contents before writing the generated files (if not purged, any conflicting files will be over-written)

purge()

Purge directory contents

private purge(string $path) : void
Parameters
$path : string

Path to directory to purge


        
On this page

Search results