Download the PHP package utopia-php/openapi without Composer

On this page you can find all versions of the php package utopia-php/openapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package openapi

Utopia OpenAPI

[!IMPORTANT] This repository is a read-only mirror of packages/openapi in appwrite/appwrite. Development happens there — please open issues and pull requests against appwrite/appwrite.

A framework-independent PHP library for parsing OpenAPI documents into one immutable, typed model.

OpenAPI 2.0, 3.0, and 3.1 documents all produce the same Utopia\OpenAPI\Specification object. Consumers can work with metadata, operations, schemas, requests, responses, and security without handling each source format separately.

Supported versions

Source format Supported versions Version enum
OpenAPI (Swagger) 2 2.0 Version::V2
OpenAPI 3.0 3.0 and all 3.0.x patch releases Version::V3_0
OpenAPI 3.1 3.1 and all 3.1.x patch releases Version::V3_1

The complete source version remains available through Specification::$sourceVersion. For example, an openapi: 3.1.1 document has Version::V3_1 as its semantic version and 3.1.1 as its source version.

Swagger 1.x is not supported.

Requirements

Install the package with Composer:

Parsing a document

Pass JSON content directly to the parser:

Decoded associative arrays are also accepted:

The parser detects the format from swagger: 2.0 or openapi: 3.x.x.

Requiring a specific version

Supply a Version when the caller expects a particular OpenAPI version:

Parsing fails with InvalidSpecification if the expected version and declared document version differ.

An instance API is available as well:

Working with the model

Every supported source format produces a Utopia\OpenAPI\Specification containing:

Operations

All operations can be retrieved as one ordered list:

Operations can also be selected by an OpenAPI tag:

The library models OpenAPI tags as tags. It does not assign SDK service or platform semantics to them.

Schemas

Schemas are represented by typed classes under Utopia\OpenAPI\Model, with Schema as their common base:

The model preserves:

Schema references remain references rather than being recursively expanded:

This makes valid recursive schemas safe to parse. Resolve the local component reference of a schema explicitly when its concrete type is needed:

resolveSchema() follows chained local schema references and leaves missing, external, or cyclic references unresolved.

OpenAPI 3.1 annotated enumerations (oneOf or anyOf of const + title) are mapped onto StringSchema fields. The type name is the composite title. Value names are each branch’s title.

The composite tree is preserved. stringEnum() returns a synthesized StringSchema (enum, enumName, enumKeys, open) so consumers do not walk the union.

An anyOf that adds an unconstrained type: string branch documents suggested values without closing the set (open: true). That includes a legacy multi-value string enum next to type: string, a flattened list of const values plus type: string, and a nested annotated oneOf plus type: string. openStringEnumBranch() returns the same StringSchema only when open is true.

allOf, unions with $ref members, and unions with multiple multi-value enum branches are not treated as string enums. Mixed const and object, numeric const, or multi-value enum branches throw InvalidSpecification.

Conditional references

CompositeSchema::conditionalReferences() returns references with required scalar literals in oneOf/anyOf branches composed through allOf (including nested allOf and OpenAPI 3.1 const):

The result is a list of references with a list of conditions for each:

Property names and references are values, not array keys, so numeric strings such as "0" remain strings when iterated or encoded as JSON.

Scalar types, unresolved references, and the schema tree are preserved. Unsupported members, optional/nullable conditions, extra scalar constraints, conflicting literals (including const/enum), or repeated references return [] for the whole union. These are selection hints, not validation or exclusivity guarantees; callers choose a selection policy. Vendor extensions and discriminators are unchanged.

Parameters and request bodies

Path-level parameters are inherited by operations. An operation-level parameter with the same case-sensitive name and in value replaces the inherited parameter.

OpenAPI 3.x request bodies and OpenAPI 2.0 body parameters both produce RequestBody objects. OpenAPI 2.0 form-data parameters are normalized into request content with object properties and encoding metadata.

Responses and media types

Responses remain indexed by their original status code or default key. Response order is preserved.

OpenAPI 2.0 produces values and OpenAPI 3.x response content both produce MediaType objects. The same normalization applies to OpenAPI 2.0 consumes and request content.

Security

Security alternatives retain OpenAPI's AND/OR semantics. This document:

is represented as two SecurityRequirement objects and means:

Security inheritance is also preserved:

Supported security scheme types include API keys, HTTP basic and bearer authentication, OAuth 2 flows, OpenID Connect, and OpenAPI 3.1 mutual TLS.

Vendor extensions

Fields whose names begin with x- are retained in each extensible model's extensions map:

Extensions are opaque. The parser does not interpret x-appwrite or any other vendor-specific behavior.

OpenAPI 2.0 normalization

OpenAPI 2.0 documents are read directly; they are not converted into an intermediate OpenAPI 3 document.

OpenAPI 2.0 field Canonical model
host, basePath, schemes Server objects
definitions Specification::$schemas
Body parameters RequestBody
Form-data parameters Request content and encodings
consumes Request media types
produces Response media types
Response schema Response media schema
securityDefinitions Security schemes
Root and operation security Security requirements

Global and operation-level consumes, produces, parameters, and security follow their standard inheritance and override rules.

References

Local references use RFC 6901 JSON Pointer syntax:

Escaped pointer tokens are supported:

Local non-schema references needed to build typed objects are resolved with cycle detection. Schema references intentionally remain ReferenceSchema objects so recursive schema graphs are not expanded.

External file and URL references are not resolved. The parser never performs implicit filesystem or network access.

Error handling

All public exceptions implement Utopia\OpenAPI\Exception\OpenAPIException:

The parser validates structure required to construct the model. It is not a complete OpenAPI conformance validator.

Current scope

The core parser supports JSON strings and decoded PHP arrays. The following capabilities are intentionally outside its current scope:

A missing operationId is currently accepted and represented as an empty string.

Development

Development takes place in the utopia-php monorepo. From its root, run:

Run bin/monorepo check openapi --fix to apply Pint formatting and Rector refactoring. PHPStan findings require manual fixes. The monorepo provides the shared QA tools; this package keeps its Rector configuration.

composer test is the unit tier and runs on the host against local fixtures. No services or containers are required. Monorepo CI runs tests and QA checks for changed packages, validates package conventions, and lints Markdown with Vale.

The test suite covers version handling, metadata, operations, parameter inheritance, requests, responses, schemas, recursive references, security semantics, OpenAPI 2.0 normalization, and JSON Pointer escaping.

License

MIT. See LICENSE.


All versions of openapi with dependencies

PHP Build Version
Package Version
Requires php Version >=8.5
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package utopia-php/openapi contains the following files

Loading the files please wait ...