Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/CONTRIBUTING.md export-ignore
generated/** linguist-generated
resources/shieldlabs-api.yaml linguist-generated
sync.sh text eol=lf
generate.sh text eol=lf
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,15 @@ jobs:
run: vendor/bin/php-cs-fixer check --diff
- name: Coverage
run: vendor/bin/phpunit --coverage-text --only-summary-for-coverage-text

generated:
name: Generated API types
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
persist-credentials: false
- name: Rebuild generated files
run: ./generate.sh
- name: Fail if generated files drifted
run: git diff --exit-code
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this package are documented in this file. The format is
based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the package
follows [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Added

- `sync.sh` downloads the OpenAPI description and `generate.sh` rebuilds `generated/` from it. The supported client is unchanged.

## [1.0.0] - 2026-09-30

First stable release, published as `shieldlabs/shieldlabs-php`. It replaces the
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,14 @@ Enums: `LookupType`, `RiskBand` (`Trusted`, `Suspicious`, `Dangerous`, `RateLimi

## Development

Refresh the generated client when the API description changes. This does not replace the supported library in this repository.

```bash
./sync.sh # download the current OpenAPI description into resources/
./generate.sh # rebuild generated/ from that file
```


```bash
composer install
composer test # PHPUnit: unit, shared fixture and integration tests
Expand Down
9 changes: 9 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"invokerPackage": "ShieldLabs\\Generated",
"packageName": "ShieldLabsGenerated",
"composerPackageName": "shieldlabs/shieldlabs-php-generated",
"gitUserId": "ShieldLabs-ai",
"gitRepoId": "shieldlabs-php",
"developerOrganization": "ShieldLabs Inc.",
"hideGenerationTimestamp": true
}
69 changes: 69 additions & 0 deletions generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"

if ! docker info >/dev/null 2>&1; then
echo "Docker is not running. Start Docker and run this script again." >&2
exit 1
fi

generator="php"
image="openapitools/openapi-generator-cli:v7.23.0"
workdir="$(mktemp -d)"
trap 'rm -rf "$workdir"' EXIT

python3 - "$PWD/resources/shieldlabs-api.yaml" "$workdir/spec.yaml" << 'PY'
import sys
from pathlib import Path

source, dest = sys.argv[1:]
lines = Path(source).read_text().splitlines(keepends=True)
out = []
i = 0
while i < len(lines):
if lines[i].startswith(" description:"):
out.append(" description: Identification results and risk scoring for your backend.\n")
i += 1
while i < len(lines) and not (lines[i].startswith(" ") and not lines[i].startswith(" ")):
i += 1
continue
out.append(lines[i])
i += 1
Path(dest).write_text("".join(out))
PY

rm -rf generated
mkdir -p generated
cat > generated/.openapi-generator-ignore << 'IGN'
README.md
git_push.sh
.travis.yml
.gitignore
docs/
test/
api/openapi.yaml
.github/
IGN

docker run --rm -u "$(id -u):$(id -g)" \
-v "$PWD":/local -v "$workdir":/work -w /local \
"$image" generate \
-i /work/spec.yaml \
-g "$generator" \
-o /local/generated \
-c /local/config.json \
--global-property apis,models,supportingFiles,modelTests=false,apiTests=false,modelDocs=false,apiDocs=false

find generated \( -name README.md -o -name '*README.md' -o -name git_push.sh -o -name .travis.yml -o -name appveyor.yml -o -name .gitignore -o -name build.sbt -o -name '*.sln' \) -delete
rm -rf generated/docs generated/test generated/.github
find generated -type d -empty -delete

if [ "$generator" = "go" ]; then
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD/generated":/src -w /src golang:1.24-bookworm gofmt -w .
cat > generated/go.mod << 'MOD'
module github.com/ShieldLabs-ai/shieldlabs-go/generated

go 1.23
MOD
fi
8 changes: 8 additions & 0 deletions generated/.openapi-generator-ignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions generated/.openapi-generator/FILES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions generated/.openapi-generator/VERSION

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions generated/.php-cs-fixer.dist.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions generated/composer.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading