swipegames/public-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

swipegames/public-api

Composer 安装命令:

composer require swipegames/public-api

包简介

Generated PHP types for Swipe Games Public API

README 文档

README

API documentation site, OpenAPI specs, and generated client packages for Swipe Games Public API.

  • Docs: Built with docusaurus-openapi-docs
  • API specs: OpenAPI 3.0 YAML in api/v1.0/
  • Packages: Go, TypeScript, and PHP types generated from the specs

Requirements

  • Node.js + Yarn
  • Go
  • Java 17 (brew install --cask temurin@17)

Quick Start

# Install dependencies
yarn install

# Start docs locally
make up

Generated Packages

Types are generated from the OpenAPI specs and published as packages:

Package Registry Install
@swipegames/public-api npm npm install @swipegames/public-api
swipegames/public-api Packagist composer require swipegames/public-api
Go (services) GitHub go get github.com/swipegames/public-api
Go (types only) GitHub go get github.com/swipegames/public-api/api/v1.0/core/types

Commands

Command Description
make up Start docs site locally
make gen-api Regenerate all code (Go + TypeScript + PHP)
make gen-docs Regenerate API documentation
make bump-version v=x.y.z Bump version everywhere and regenerate
make build-node Build the Node/TypeScript package

Versioning

We use semver. See CLAUDE.md for the full versioning workflow.

To bump the version:

make bump-version v=1.2.17

This updates all version locations (API specs, docusaurus config) and regenerates all code and docs.

CI/CD

  • PR workflow: Validates version bump, checks generated code is up-to-date, builds packages and docs
  • Deploy workflow (on release): Publishes npm + Packagist packages, deploys docs to GitHub Pages

Customizations

This documentation includes custom components (swizzled from docusaurus-theme-openapi-docs) to enforce canonical JSON format in all code examples and request panels.

Swizzled Components

When upgrading docusaurus-theme-openapi-docs, these components may need to be reviewed and updated:

1. src/theme/ApiExplorer/CodeSnippets/index.tsx

Purpose: Post-processes code snippets to ensure canonical JSON format

Modifications:

  • Added postProcessSnippet() function that processes code snippets for each language:
    • Python: Adds sort_keys=True parameter to json.dumps() (for explicitness)
    • cURL, C#, Go, PHP, Java, PowerShell, C, Objective-C, OCaml, R, Swift, Kotlin, Rust: Compacts JSON (removes whitespace/newlines)
    • Ruby: Adds { sort_keys: true } option to JSON.dump() (for explicitness)
    • Node.js, JavaScript, Dart: No changes needed
  • Modified all codegen.convert() callbacks to call postProcessSnippet() before setCodeText()
  • Note: Keys are already sorted by ApiExplorerWrapper, so we only compact (not re-sort)

Dependencies:

  • code-snippets-types.ts - Copied from original theme
  • languages.ts - Copied from original theme

2. src/theme/ApiExplorer/Body/index.tsx

Purpose: Displays compact canonical JSON in the interactive request panel

Modifications:

  • Changed all JSON.stringify(obj, null, 2) calls to JSON.stringify(obj) to display compact canonical JSON instead of pretty-printed JSON
  • Applies to: jsonRequestBodyExample, example, and examples bodies
  • Note: Keys are already sorted by ApiExplorerWrapper, so we only remove whitespace

3. src/theme/ApiExplorer/index.js (Wrapper)

Purpose: Pre-sorts JSON keys before code generation

Modifications:

  • Added sortKeysCanonical() function to recursively sort object keys
  • Wraps ApiExplorer component and sorts props.item.jsonRequestBodyExample before passing to original component

Why Canonical JSON?

The Swipe Games API requires canonical JSON format for signature generation:

  • Keys must be alphabetically sorted
  • No whitespace between elements
  • Consistent formatting for HMAC-SHA256 signatures

See /docs/authn.md for detailed authentication documentation.

Maintenance Notes

When updating docusaurus-theme-openapi-docs:

  1. Check if swizzled components have breaking changes
  2. Review modifications in the components listed above
  3. Test code snippet generation for all languages
  4. Verify request panel displays compact JSON
  5. Run yarn build to ensure no compilation errors

swipegames/public-api 适用场景与选型建议

swipegames/public-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 72 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 swipegames/public-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 swipegames/public-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 swipegames/public-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 72
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 32
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-03-16