Bug Description
When an OpenAPI schema uses additionalProperties: true and the request body example includes fields that come from additionalProperties (not explicitly defined in the schema), the generated wire tests fail. The test generator uses the full example as the expected request body, but the generated typed builder only exposes methods for the explicit schema properties — so the actual serialized request never includes the additional fields from the example.
Reproduction
Given a schema like:
FHIRResource:
type: object
required:
- resourceType
properties:
resourceType:
type: string
id:
type: string
additionalProperties: true
And a request body example like:
requestBody:
content:
application/fhir+json:
schema:
$ref: '#/components/schemas/FHIRResource'
examples:
create_patient:
value:
resourceType: "Patient"
name:
- family: "Doe"
given: ["Jane"]
gender: "female"
birthDate: "1990-01-01"
The generated wire test expects the full example body (resourceType, name, gender, birthDate), but the generated builder call only sets resourceType:
FhirResource.builder()
.resourceType("Patient")
.build()
The builder does support .additionalProperty(key, value), but the test generator doesn't use it for the extra example fields.
Expected Behavior
Either:
- The test generator should use
.additionalProperty() to set example fields that aren't explicit schema properties, or
- The expected request body in wire tests should only include fields that the builder actually sets
Environment
- Fern CLI: 4.54.1
- Java SDK generator: 4.0.9
enable-wire-tests: true
Workaround
We worked around this by removing additionalProperties fields from our OpenAPI examples, so the examples only reference explicitly-defined schema properties.
Bug Description
When an OpenAPI schema uses
additionalProperties: trueand the request body example includes fields that come fromadditionalProperties(not explicitly defined in the schema), the generated wire tests fail. The test generator uses the full example as the expected request body, but the generated typed builder only exposes methods for the explicit schema properties — so the actual serialized request never includes the additional fields from the example.Reproduction
Given a schema like:
And a request body example like:
The generated wire test expects the full example body (
resourceType,name,gender,birthDate), but the generated builder call only setsresourceType:The builder does support
.additionalProperty(key, value), but the test generator doesn't use it for the extra example fields.Expected Behavior
Either:
.additionalProperty()to set example fields that aren't explicit schema properties, orEnvironment
enable-wire-tests: trueWorkaround
We worked around this by removing
additionalPropertiesfields from our OpenAPI examples, so the examples only reference explicitly-defined schema properties.