Documentation

GroupingGenerator extends Generator
in package

We know that the OpenAPI specifications we're dealing with have titles that we can use to organize our clients (e.g. "Foo Bar", "Foo Baz" so we'll organize them as "Foo\Bar" and "Foo\Baz").

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

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())

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

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())

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