Skip to content

v8.0.0

Choose a tag to compare

@Korbeil Korbeil released this 01 Oct 09:52
· 52 commits to next since this release
3bb5c60

Added

  • [Tests] Nightly, non-blocking corpus smoke job (castor qa:corpus, .github/workflows/corpus-smoke.yml): generates a client for each vendor-published real-world spec pinned in corpus/specs.json (Kubernetes, Docker, Slack, Netlify, GitHub 3.0 / 3.1, Stripe, Plaid, Box, Twilio, Discord, OpenAI) and asserts that generation does not crash and the output parses, with a report-only Mago summary — no committed output or baselines (#1041 point 3). The fixture tests' php-parser syntax gate moved into the reusable PhpSyntaxGate
  • [JsonSchema] [OpenApi] Console generate commands now print generation progress: a header per schema (Generating for schema … / Output: …), timed ➜ Guessing… done (Xs) / ➜ Generating… done (Xs) phase lines, a ➜ N files written total, the grouped file counts (models, enums, normalizers, validators, runtime, auth, client, endpoints, exceptions) and Done in Xs. Silent at --quiet (#252, ADR 0013)
  • [JsonSchema] [OpenApi] New experimental generation events system (#859, ADR 0013), built on symfony/event-dispatcher (new require of jane-php/json-schema and jane-php/open-api-common). Subscribers implement Symfony\Component\EventDispatcher\EventSubscriberInterface; Jane::build() / JaneOpenApi::build() accept an optional second Symfony\Contracts\EventDispatcher\EventDispatcherInterface argument — when omitted, a listener-less dispatcher is used. Lifecycle events (GenerationStarted/EndedEvent, SchemaStarted/EndedEvent, GuessingStarted/EndedEvent, GeneratingStarted/EndedEvent, FileGeneratedEvent) carry readonly payloads; mutation events carry live mutable references: PropertyGuessedEvent lets listeners replace a guessed property type (Property::setType()) so models and normalizers stay consistent, and PropertyGeneratedEvent / ClassGeneratedEvent expose the model's PhpParser AST (Stmt\Property / Stmt\Class_) for docblock types, psalm tags, custom methods, traits or extends. Event constructors are frozen; the event set may grow. Throwing listeners abort generation through the existing GenerationFailedException wrapping
  • [OpenApi] New x-fetch-mode OpenAPI extension on GET and HEAD operations (values lazy — the default, eager, preload), plus the default-fetch-mode generation option (mirrors default-additional-properties plumbing, GET/HEAD only). lazy returns a lazy ghost proxy deferring the send to first access; eager is the historical blocking behavior; preload registers the request immediately. Every other verb is always eager, and misuses (x-fetch-mode on a non-GET/HEAD operation, invalid values) fail generation with clean, complete [ERROR] blocks through a new FetchModeValidator plugged into each component's SchemaParser::validateSchema() (ADR 0002, ADR 0012)
  • [OpenApi] lazy / preload operations return a lazy ghost proxy of the endpoint's generated model class built on PHP native lazy objects (PHP >= 8.4; earlier versions degrade to the eager behavior at runtime). Reading any property of the proxy sends the request, parses the response through the endpoint's own status-code mapping and copies the parsed model's properties onto the proxy (instanceof, cloning and serialization behave like a plain model); documented 4xx/5xx exceptions are thrown on first access. Generated endpoints expose getTargetClass(): ?string; responses that are not a single generated model (JSON arrays and maps, scalar bodies, no-content responses, several models / content types) are not ghostable and their configured deferred mode degrades to eager (see ADR 0014). New runtime helper Jane\Component\OpenApiRuntime\Client\GhostFactory (availability check, ghost creation, forced initialization)
  • [OpenApi] New Jane\Component\OpenApiRuntime\Client\Plugin\ServerUrlHttpClient decorator replacing AddHostPlugin + AddPathPlugin: request URLs are explicitly rewritten to the specification's server URL (scheme, host, port, base path). base_uri cannot be used for this: RFC 3986 resolution drops the base URI path for absolute-path request URLs (verified against symfony/http-client)

Removed

  • BC-breaking [OpenApi] Remove the Jane\Component\OpenApiRuntime\Client\Result wrapper and its surface (toObject(), toArray(), getStatusCode(), isInitialized(), await(), cancel()): lazy / preload operations return a lazy ghost proxy of the model class instead (see the Added entries and ADR 0014); state introspection uses the reflection API (ReflectionClass::isUninitializedLazyObject() / initializeLazyObject()), batching uses executeRawEndpoint() + stream() on raw responses, and custom Endpoint implementations must add the new getTargetClass(): ?string
  • BC-breaking [JsonSchemaRuntime] Remove the global static state from Jane\Component\JsonSchemaRuntime\Reference (allowExternalRefs(), setAllowedExternalHosts(), setAllowedLocalRefRoots(), setFollowRedirects(), resetConfig() and the process-wide caches). Reference configuration now lives on a ReferenceResolver instance threaded through the generation pipeline; generated code keeps resolving references through a shared ReferenceResolver::default() (ADR 0008)
  • BC-breaking [JsonSchema] Remove the deprecated Jane\Component\JsonSchema\Exception\JaneExceptionInterface alias; the JsonSchema and OpenAPI exceptions now implement Jane\Component\JsonSchemaRuntime\Exception\JaneExceptionInterface directly
  • BC-breaking [OpenApi] Remove the deprecated $fetch = 'response' mode and the FETCH_RESPONSE constant from the generated client: executeEndpoint() always parses the response body, and executeRawEndpoint() remains the explicit raw-response escape hatch. The trigger_deprecation bridge is gone
  • BC-breaking [OpenApi] Rename the mis-spelled anyOf/oneOf reference guessers (AnyOfReferencefGuesser, OneOfReferencefGuesser) to AnyOfReferenceGuesser / OneOfReferenceGuesser; the shared logic now lives in OpenApiCommon\Guesser\OpenApiSchema\AbstractXOfReferenceGuesser
  • BC-breaking [OpenApi] Remove PSR-7, PSR-17, PSR-18 and HTTPlug from the OpenAPI runtime and generated clients: the runtime and generated code are now built on Symfony\Contracts\HttpClient\HttpClientInterface / Symfony\Contracts\HttpClient\ResponseInterface and native string|resource|array bodies. jane-php/open-api-runtime requires symfony/http-client ^6.4 || ^7.0 || ^8.0 and no longer depends on psr/*, php-http/* or nyholm/psr7. The HTTPlug PluginClient / AddHostPlugin / AddPathPlugin stack is replaced by HttpClientInterface decorators (see the Added / Changed entries and ADR 0012)
  • BC-breaking [OpenApi] Remove the legacy $fetch / FETCH_OBJECT mechanism: generated operation methods lost their trailing string $fetch parameter, Client::FETCH_OBJECT and the vestigial $fetchMode argument of parseResponse() are gone, and the dead Jane\Component\OpenApiRuntime\Client\Exception\InvalidFetchModeException is deleted. Raw responses: executeRawEndpoint(); per-operation fetch strategies: x-fetch-mode (below)
  • BC-breaking [OpenApi] Remove Client::create() dependencies on the PSR-17 factories: the generated signature is now create(?Symfony\Contracts\HttpClient\HttpClientInterface $httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = [][, bool $applyServerPlugins = true]) and the constructor is __construct(HttpClientInterface $httpClient, SerializerInterface $serializer)

Changed

  • BC-breaking [OpenApi] The constructor of the generated runtime Client (and therefore of the generated Client extending it) is now final: Client::create() ends in new static($httpClient, $serializer), which is only safe when no subclass can change the constructor's signature. Subclasses still add or override operation methods; construction is wired through create() ($additionalPlugins, $additionalNormalizers) or by calling the constructor with your own HttpClientInterface and SerializerInterface (#1066, unsafe-instantiation)
  • BC-breaking [OpenApi] throw-unexpected-status-code is now enabled by default: a response status (or content type) the specification does not declare makes the generated endpoint throw BadResponseException (an UnexpectedStatusCodeException carrying the response) instead of returning null from transformResponseBody() — the behaviour announced in #377 and asked for again in #815. Set 'throw-unexpected-status-code' => false to keep the old outcome; the generated method then ends in an explicit return null; instead of falling through. @return no longer lists null when the option is on (#1066, missing-return-statement)
  • BC-breaking [OpenApi] Generated endpoint constructors and client operation methods no longer default $queryParameters, $formParameters and $headerParameters to [] when the specification requires one of their keys: the options resolver rejected the empty array at request time anyway, which with the lazy default fetch mode only surfaced on first access of the Result. The signature now matches the documented array{...} shape and a missing array fails at the call site (ArgumentCountError) instead of later (MissingOptionsException). An optional request body declared before such an array loses its = null default as well, as PHP already treated it as required (#1066, invalid-parameter-default-value)
  • BC-breaking [JsonSchema] [OpenApi] Generation options are consolidated into a single frozen Jane\Component\JsonSchema\Generator\Options value object as the canonical source of defaults. Programmatic callers that previously had to pass a required reference key to JsonSchema\Jane::build() no longer do (it now defaults to false); reference defaults to false uniformly. The console keeps its historical reference => true default. (ADR 0009)
  • BC-breaking [OpenApi3] [OpenApi31] Generated status-level exception classes now use constructor property promotion (private readonly) instead of a property block plus constructor assignments
  • [JsonSchema] [OpenApi] Reference resolution, the validator factory and the schema parser no longer use process-global static state; each build owns its instance (ADR 0008)
  • [OpenApi3] [OpenApi31] Consolidate 100%-identical generator code (request-body content generators, GetTransformResponseBodyTrait, GetGetExtraHeadersTrait) into OpenApiCommon behind version hooks (ADR 0010)
  • [JsonSchema] [OpenApi] Console commands now declare their name and description through the #[AsCommand] attribute (command names unchanged), the --config-file option value is validated before reaching the typed loaders, and Application::VERSION now derives from Composer's installed versions instead of a stale constant
  • [JsonSchemaBundle] [OpenApiBundle] Bundle commands are fully DI-managed (autowired loaders, #[AsCommand], delegation through the component command lifecycle with real exit codes) and resolve their default configuration from %kernel.project_dir%: the documented config/jane/json-schema.php / config/jane/open-api.php paths are now honored first, with the legacy underscored variants as fallback. Configuration under jane_json_schema: / jane_open_api: is validated: empty config is accepted, unknown keys now fail loudly instead of being silently ignored. Both bundles now require symfony/config, symfony/console, symfony/dependency-injection and symfony/http-kernel, and the PHP floor is ^8.1
  • [JsonSchema] php-cs-fixer run during generation no longer swallows its output and exit code: fixer output is forwarded at -v verbosity and a failing fixer run now triggers a warning and an exception
  • BC-breaking [OpenApi] HTTP client decorators replace HTTPlug plugins: $additionalPlugins in the generated Client::create() now accepts decorator factories (callable(HttpClientInterface): HttpClientInterface, applied left-to-right after the server URL decorator). Jane\Component\OpenApiRuntime\Client\Plugin\AuthenticationRegistry is now such a decorator factory reading authentication scopes from the request extra option bag (AuthenticationRegistry::SCOPES_OPTION, the historical X-Jane-Authentication header is gone), and generated authentication classes implement decorate(string $method, string $url, array &$options): void + getScope(): string instead of authentication(RequestInterface): RequestInterface (header based authentication writes to $options['headers'], query based to $options['query'])
  • BC-breaking [OpenApi] Multipart request bodies are built by a new internal Jane\Component\OpenApiRuntime\Client\MultipartStreamBuilder (raw string body) replacing the PSR-7 based php-http/multipart-stream-builder, keeping the GH#1036 part semantics (filename fallback to the property name, per-part Content-Type from encoding). Binary request bodies are typed string|resource (PSR-7 StreamInterface is no longer accepted); BaseEndpoint no longer depends on a StreamFactoryInterface
  • BC-breaking [OpenApi] No-throw parity with PSR-18 is now implemented through Symfony's per-method $throw flags: the runtime consumes responses with getHeaders(false) / getContent(false) so status-code mapping stays in the generated code. The historical 'throw' => false request option is not used (it no longer exists in symfony/http-client 8.x); raw responses returned by executeRawEndpoint() keep Symfony's default $throw = true semantics on explicit reads
  • [OpenApi] Redirects keep Symfony's default (max_redirects: 20), matching the historical HTTPlug behavior

Fixed

  • [JsonSchema] [OpenApi] Generated denormalizers for format: date-time (and inline oneOf/anyOf union branches) no longer reject valid RFC 3339 values that the strict \DateTimeInterface::RFC3339 format cannot parse: a Z designator instead of a numeric offset, and optional fractional seconds (2026-08-31T15:39:33.601Z threw InvalidDateException). When the input format is the default, the strict parse failure is retried with a bare new \DateTime(...) gated by a strict RFC 3339 shape regex, and the union condition routes matching values to the date branch so relative date strings (tomorrow) can never reach the fallback; values outside the shape keep the same clean InvalidDateException, and a custom date-input-format keeps the fully strict behavior. The validation generator emits a Symfony Regex constraint with the same RFC 3339 shape for default-format date-time properties instead of the strict DateTime(format) constraint, so validators and denormalizers accept and reject the same values (well-shaped but impossible values such as 2026-02-30T25:61:61Z are rolled over by new \DateTime without exception on both sides). (ported from 7.x, GH#1102, shipped in v7.14.4)
  • [OpenApi] The runtime BaseEndpoint no longer percent-encodes nested query parameter keys twice. encodeArrayValue(), encodeFormStyle() and flattenBracketPairs() pre-encoded each sub-key before appending it to the bracketed key, which encodeStringValue() / encodeIntValue() then encoded again: a sub-key containing a reserved character was emitted as queryParam%5Bunit%253Amm%5D=width instead of queryParam%5Bunit%3Amm%5D=width, so after the server's own URL-decoding the sub-key arrived as the literal string unit%3Amm rather than unit:mm. Sub-keys are now appended raw and encoded once, by the single rawurlencode() of the assembled key, matching http_build_query(..., PHP_QUERY_RFC3986). Regressed in 7.14.0 for style / explode / deepObject parameters and in 7.10.4 (GH#907, GH#908) for bracketed arrays; keys made only of unreserved characters are unaffected (ported from 7.x, #1077, shipped in v7.14.3)
  • [JsonSchema] [OpenApi] whitelisted-paths no longer prunes models that are referenced only through a oneOf / anyOf union, a nested array, a map, or additionalProperties / patternProperties: the model relations that drive the pruning now follow every generated class a property type can reach, so the normalizers of a whitelisted operation stop targeting classes that were never generated (NotNormalizableValueException: … no supporting normalizer found on a valid response). ConstraintReferencesTest is retired: the Mago gate reports every dangling class reference (#1066, non-existent-class-like)
  • [OpenApi3] [OpenApi31] whitelisted-paths no longer prunes the request body model of a multipart/form-data operation: the relations of a whitelisted operation followed application/json, *+json and application/x-www-form-urlencoded bodies only, so an upload endpoint degraded to \stdClass $requestBody and its body could not be normalized by the generated JaneObjectNormalizer (NotNormalizableValueException on every upload unless a Symfony ObjectNormalizer was registered as an additional normalizer)
  • [OpenApi2] [OpenApi3] [OpenApi31] Generated endpoint constructors and client methods now document their $queryParameters / $headerParameters / $formParameters arrays with a PHPDoc array shape that parses: OpenAPI 2 output used the phpDocumentor 2 @param array $queryParameters { @var int $keep-storage ... } inline-tag form, and multi-line parameter descriptions in OpenAPI 3 / 3.1 output continued outside the // comment. Either one makes PHPStan, Mago and IDEs drop the whole docblock (@throws and @return included). All three components now share one emitter: @param array{ "keep-storage"?: int, //description ... } $queryParameters, with every further description line on its own // line
  • [OpenApi] The runtime Client::stream() now streams a single ResponseInterface argument instead of iterating over it as an object, which streamed nothing
  • [OpenApi] A specification without operations no longer generates a runtime Client referencing an Endpoint interface that is never generated: the Client template declares the dependency
  • [OpenApi] Generated clients are cleaner for static analysers: Client::create() documents $additionalPlugins as list<callable(HttpClientInterface): HttpClientInterface> and $additionalNormalizers as normalizer instances, and the runtime FormEncoder initialises the parse_str() output variable (the runtime-template family of the Mago baseline, #1066)
  • [OpenApi31] multipart/form-data file parts declared the OpenAPI 3.1 way are recognized again. OpenAPI 3.1 (JSON Schema 2020-12) dropped format: binary and spells a binary payload type: string + contentMediaType: <media type>, but the multipart generator only detected the 3.0 spelling: such a property produced no $partOptions entry at all, so the part went on the wire without a filename in its Content-Disposition header — the filename-less part servers like FastAPI or Spring reject as "not a file" (GH#1036). A type: string property carrying a contentMediaType now gets the property-name filename fallback exactly like a format: binary one, and composes with the per-part Content-Type emitted from the media type's encoding object (that path was already independent of the binary detection and is unchanged). A contentEncoding is deliberately not required: JSON Schema 2020-12 defines contentMediaType without it as the string already being the raw content of that media type. Specifications using format: binary — including 3.1 documents converted from 3.0 — generate byte-identical code, and the guessed model property type is untouched
  • [JsonSchema] [OpenApi] Generating with validation enabled no longer aborts with TypeError: PhpParser\Node\ArrayItem::__construct(): Argument #1 ($value) must be of type PhpParser\Node\Expr, null given when an array-valued constraint argument holds a null member, as enum: [a, b, null] does: ValidatorGenerator now emits that member as an explicit null choice, so a value the specification allows stays valid instead of the whole generation crashing. A constraint argument that is itself null keeps its meaning of "unset" and is still left out, so the constraint keeps its own default
  • [OpenApi2] Generating from a Swagger 2.0 specification whose response schema declares neither type nor enum — or a number without a format and without bounds — no longer fatals with Typed property Jane\Component\OpenApi2\JsonSchema\Model\Schema::$enum must not be accessed before initialization. Deriving the scalar return type of an endpoint now reads type, enum, format, default, minimum, maximum and multipleOf through the same ?? null guard as the OpenAPI 3.x counterpart: the schema model only assigns the keywords the document declares, so every other typed property stays uninitialized (surfaced by the corpus smoke job of #1080 on the public Slack Web API 2.0 specification)
  • [OpenApi31] Generating from a 3.1 specification whose anyOf / oneOf union references a schema declaring no allOf keyword no longer fatals with Typed property Jane\Component\JsonSchema\JsonSchema\Model\JsonSchema::$allOf must not be accessed before initialization. The 3.1 union guessers inspect each resolved branch to decide whether it carries denormalizable content, and read its allOf through the same ?? null guard as the neighbouring type / anyOf checks: the schema model only assigns the keywords the document declares, so every other typed property stays uninitialized (surfaced by the corpus smoke job of #1080 on the public OpenAI 3.1 specification)
  • [OpenApi3] Generated endpoint constructors and client operation methods no longer emit empty doc-comment lines for blank lines of the operation description: symfony/yaml 7.4.20 / 8.1.8 fixed folded-scalar blank-line handling (YAML 1.2 §8.1.3), which made generated phpDoc gain extra blank comment lines depending on the installed symfony/yaml version and broke the issue-669 fixture comparison. Blank description lines are now skipped when rendering docblocks, making the generated output independent of the installed symfony/yaml version