PHPackages                             lukedavis/gcp-api-gateway-spec - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. lukedavis/gcp-api-gateway-spec

ActiveLibrary[API Development](/categories/api)

lukedavis/gcp-api-gateway-spec
==============================

Generates a Google Cloud API Gateway spec file based on a provided config and a given Swagger 2.0 YAML

v2.0.3(1y ago)1721MITPHPPHP &gt;=8.0

Since Jul 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dir/gcp-api-gateway-spec)[ Packagist](https://packagist.org/packages/lukedavis/gcp-api-gateway-spec)[ RSS](/packages/lukedavis-gcp-api-gateway-spec/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (0)

GCP API Gateway Spec Generator
==============================

[](#gcp-api-gateway-spec-generator)

This is a simple tool that:

- Takes a Swagger 2.0 spec file
- Takes a configuration file
- Generates a new Swagger 2.0 spec file with API Gateway specific properties
- Optionally (recommended), strips responses from the original spec file, and replaces them with generic 200 responses.
    - Complicated responses are a constant source of errors when deploying to the API Gateway, and in most use cases are not necessary.

> The generator does not handle converting API specs (i.e., OpenAPI 3.0 to Swagger 2.0). It is assumed that you have a Swagger 2.0 spec file. If you have an API spec file in a different format, it is recommended to use [api-spec-converter](https://github.com/LucyBot-Inc/api-spec-converter) or another tool to convert it to Swagger 2.0.

The main use case of this tool is an intermediate step in the deployment of an API to Google Cloud Platform's API Gateway. As Google still uses the old Swagger 2.0 spec, and has additional fields that can be added/removed, this tool helps to automate the process of generating a spec file that is compatible with the API Gateway. A common use case for this tool would be on a CI pipeline:

1. Autogenerate spec for your API
2. Convert spec to Swagger 2.0
3. Generate API Gateway spec file
4. Deploy to API Gateway

Installation
------------

[](#installation)

Ensure you have [Composer](https://getcomposer.org/) installed and available in your PATH, as well as PHP 8.0 or later.

### Local

[](#local)

Run the following command in your project root:

```
composer require lukedavis/gcp-api-gateway-spec --dev
```

After installing, you can now run the tool using: `./vendor/bin/gcp-api-gateway-spec generate` from your project root.

### Global

[](#global)

Run the following command anywhere in your terminal:

```
composer global require lukedavis/gcp-api-gateway-spec
```

After installing, the tool will now be in your composer installation's bin directory at `/vendor/bin/gcp-api-gateway-spec`.

You can view the path to your composer's home directory by running `composer -n config --global home`.

> You can alias the path to the tool or add the composer vendor/bin directory to your PATH in your `.zshrc` or `.bashrc` for easier access.

Usage
-----

[](#usage)

### Requirements

[](#requirements)

- Swagger 2.0 YAML spec file
    - If you are working with an OpenAPI 3.0 spec file, I recommend using [api-spec-converter](https://github.com/LucyBot-Inc/api-spec-converter) to create a Swagger 2.0 spec file.
- Configuration file (see [Configuration](#Configuration))
- Output
    - Can be absolute path, relative path, or either + a filename. If no filename is provided, the generated file will be named `generator-output.yaml`.

### Command

[](#command)

```
gcp-api-gateway-spec generate \
  --input=swagger2.yaml \
  --output=api-gateway.yaml \
  --config=config.yaml \
  [--preserve-responses]
```

### Examples

[](#examples)

Absolute path with filename:

```
gcp-api-gateway-spec generate \
    --input=swagger.yaml \
    --output=/tmp/api-gateway.yaml \
    --config=config.yaml
```

With `--preserve-responses` and a relative output to cwd:

```
gcp-api-gateway-spec generate \
    --input=swagger.yaml \
    --output=api-gateway.yaml
    --config=config.yaml \
    --preserve-responses
```

Configuration
-------------

[](#configuration)

Below are the configuration options, take a look at the [example config](config.example.yaml) for a more practical example.

```
# Define your security definitions here
securityDefinitions: []

# Default configuration applied to all paths if not overridden
# Useful for setting global security definitions
path-defaults:
  security: []

# Path/method specific overrides
# Useful for setting security definitions on specific paths
path-overrides: []
```

Disclaimer
----------

[](#disclaimer)

This tool is not officially supported by Google Cloud Platform or the API Gateway team.

This tool is provided as-is and without warranties of any kind. Luke Davis is not responsible for any security issues, vulnerabilities, or other problems that may arise from the use of this tool.

Users are responsible for ensuring the security and suitability of this tool for their specific needs and use cases. Use at your own risk.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance42

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Recently: every ~0 days

Total

14

Last Release

478d ago

Major Versions

v1.2.9 → v2.0.02025-01-18

PHP version history (2 changes)1.0.0PHP &gt;=8.1

v1.2.7PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/505864?v=4)[lke](/maintainers/lke)[@LKE](https://github.com/LKE)

---

Top Contributors

[![dir](https://avatars.githubusercontent.com/u/6627316?v=4)](https://github.com/dir "dir (25 commits)")

---

Tags

apigoogleopenapigatewaygcpoas

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lukedavis-gcp-api-gateway-spec/health.svg)

```
[![Health](https://phpackages.com/badges/lukedavis-gcp-api-gateway-spec/health.svg)](https://phpackages.com/packages/lukedavis-gcp-api-gateway-spec)
```

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[darkaonline/swagger-lume

OpenApi or Swagger integration to Lumen

3372.3M3](/packages/darkaonline-swagger-lume)[psx/api

Parse and generate API specification formats

37178.0k4](/packages/psx-api)[harmbandstra/swagger-ui-bundle

Exposes swagger UI inside your Symfony project through a route (eg. /docs)

42867.3k](/packages/harmbandstra-swagger-ui-bundle)[erasys/openapi-php

Open API 3.0 builder and validation library for PHP that helps you write valid specs.

2080.3k5](/packages/erasys-openapi-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
