PHPackages                             segrax/opa-policy-generator - 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. segrax/opa-policy-generator

ActiveLibrary[API Development](/categories/api)

segrax/opa-policy-generator
===========================

Convert OpenAPI 3 specs to OPA Policies

0.5.0(2y ago)3715↓20%1[1 PRs](https://github.com/segrax/opa-policy-generator/pulls)MITPHPCI passing

Since Dec 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/segrax/opa-policy-generator)[ Packagist](https://packagist.org/packages/segrax/opa-policy-generator)[ RSS](/packages/segrax-opa-policy-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (11)Used By (0)

Open Policy Agent Policy Generator
==================================

[](#open-policy-agent-policy-generator)

Convert an [OpenAPI](https://www.openapis.org/) 3 specification to an OPA policy.

[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.txt)

Warning
-------

[](#warning)

While this tool will produce a file representing a policy, it is advised a manual review of every line is performed prior to using the policy.

Items such as API-Keys must be manually set, and any other security related items not definable in a spec.

Early Development
-----------------

[](#early-development)

This tool is under development and may not support all OpenAPI3 features, please open feature requests if you find features missing that you require.

How to use
----------

[](#how-to-use)

The easiest way to use opapg is via docker, mounting a folder with a spec in as a volume

```
    docker run --volume d:/projects/myapi:/srv/app segrax/opapg from-openapi openapi.yaml --output=mypolicy
```

This will produce a policy and a set of tests for the policy (in the mounted volume) and will output the results of an 'opa test' command to the console

```
data.name.api.test_locat_id_oauth2_allowed: PASS (537.7µs)
data.name.api.test_locat_id_oauth2_denied: PASS (401.6µs)
data.name.api.test_locat_id_apiKey1_allowed: PASS (352.5µs)
data.name.api.test_locat_id_apiKey1_denied: PASS (293.5µs)
data.name.api.test_locations_near_allowed: PASS (280.2µs)
data.name.api.test_locations_get_allowed: PASS (849.6µs)
data.name.api.test_locations_create_bearerAuth_allowed: PASS (707.1µs)
data.name.api.test_locations_create_bearerAuth_denied: PASS (346.1µs)
data.name.api.test_media_get_allowed: PASS (398µs)
data.name.api.test_media_list_allowed: PASS (343.1µs)
data.name.api.test_media_upload_bearerAuth_allowed: PASS (314.3µs)
data.name.api.test_media_upload_bearerAuth_denied: PASS (447.2µs)
--------------------------------------------------------------------------------
PASS: 12/12
```

Todo
----

[](#todo)

Lots of features remain to be added, please submit ideas/feature requests to the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.txt) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance53

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

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 ~163 days

Recently: every ~293 days

Total

9

Last Release

1036d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1327406?v=4)[Robert Crossfield](/maintainers/segrax)[@segrax](https://github.com/segrax)

---

Top Contributors

[![segrax](https://avatars.githubusercontent.com/u/1327406?v=4)](https://github.com/segrax "segrax (26 commits)")

---

Tags

openapiopaauthzPolicyrego

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/segrax-opa-policy-generator/health.svg)

```
[![Health](https://phpackages.com/badges/segrax-opa-policy-generator/health.svg)](https://phpackages.com/packages/segrax-opa-policy-generator)
```

###  Alternatives

[swagger-api/swagger-ui

 Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.

28.8k45.4M99](/packages/swagger-api-swagger-ui)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

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

Automatic generation of API documentation for Laravel applications.

2.1k7.8M57](/packages/dedoc-scramble)[devizzent/cebe-php-openapi

Read and write OpenAPI yaml/json files and make the content accessable in PHP objects.

379.0M49](/packages/devizzent-cebe-php-openapi)[psx/api

Parse and generate API specification formats

37178.0k4](/packages/psx-api)[marcelthole/openapi-merge

Merge multiple OpenAPI YML/JSON files into one

1886.4k4](/packages/marcelthole-openapi-merge)

PHPackages © 2026

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