Skip to content

Fix OpenAPI schemas and request header sizing - #107

Merged
eviltester merged 1 commit into
masterfrom
codex/openapi-schema-and-header-sizing
Aug 7, 2026
Merged

Fix OpenAPI schemas and request header sizing#107
eviltester merged 1 commit into
masterfrom
codex/openapi-schema-and-header-sizing

Conversation

@eviltester

Copy link
Copy Markdown
Owner

Summary

  • Emit OpenAPI examples using JSON values that match their schema types, so numeric and boolean examples are not serialized as strings.
  • Describe collection response schemas as the JSON wrapper object returned by the API, e.g. { "items": [...] }, with required fields on returned item objects.
  • Add configurable Javalin request header sizing for large browser cookie/header requests.
  • Add regression coverage for OpenAPI schema examples, collection wrapper schemas, and request header sizing.

Validation

  • mvn -pl thingifier "-Dtest=Swaggerizer*Test,OpenApi32FinalizerTest,SwaggerUiPageTest" test passed: 16 tests.
  • mvn install "-DskipTests=true" "-Dcheckstyle.skip=true" "-Dpmd.skip=true" passed and installed all reactor modules to local Maven.

Notes

A full mvn install currently fails on pre-existing project-FQN Checkstyle violations outside this change. Running with static checks skipped and tests enabled reached thingifier-crud-ui integration tests, where two existing e2e assertions failed (DELETE expected 200 but received 204, and Swagger UI no longer contains the word Explore).

Copilot AI lite review requested due to automatic review settings August 7, 2026 14:21
@eviltester
eviltester merged commit e1cec61 into master Aug 7, 2026
4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb0138bf2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +624 to +625
for (String propertyName : object.getProperties().keySet()) {
object.addRequiredItem(propertyName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep optional response fields optional

When an entity defines an optional DATE or OBJECT field without a default, JsonThing.asFieldJsonObject omits that field because InstanceFields.getFieldValue returns null, but this loop now marks every defined property as required. Collection responses containing such entities therefore fail validation against the generated OpenAPI schema and generated clients assume fields that may be absent; only fields guaranteed to be rendered should be added to required.

Useful? React with 👍 / 👎.

Comment on lines 611 to +614
XML xml = new XML();
xml.setWrapped(true);
arrayObject.setXml(xml);
collectionObject.setXml(xml);
collectionObject.addProperties(objectSchemaDefinition.getPlural(), arrayObject);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the XML collection shape

For application/xml collection responses, this object property adds another plural-named layer to the schema: the endpoint emits <items><item>...</item></items>, while the new object schema has an outer collection object containing an items property. Setting wrapped on the outer object does not flatten that property because XML wrapping applies to arrays, and responseContentWith uses this same component for both JSON and XML, so XML client generation and validation no longer match the actual response.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Thingifier OpenAPI/Swagger generation and Javalin/Jetty server configuration to better match real API behavior and support larger browser-originated request headers.

Changes:

  • Update Swaggerizer to emit OpenAPI schema examples using correctly-typed JSON values (numbers/booleans not serialized as strings).
  • Update collection response schemas to describe the { "<plural>": [...] } wrapper object returned by the API.
  • Add configurable Jetty request header size in the Javalin adapter, with regression tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
thingifier/src/test/java/uk/co/compendiumdev/thingifier/swaggerizer/SwaggerizerSchemaExampleTest.java Adds regression tests for typed examples and collection-wrapper response schemas.
thingifier/src/test/java/uk/co/compendiumdev/thingifier/adapter/javalin/JavalinHttpServerTest.java Adds tests for request header size defaults/configuration and acceptance of large Cookie headers.
thingifier/src/main/java/uk/co/compendiumdev/thingifier/swaggerizer/Swaggerizer.java Adjusts schema generation for collection wrappers, required fields, and example typing.
thingifier/src/main/java/uk/co/compendiumdev/thingifier/adapter/javalin/JavalinHttpServer.java Adds Jetty HttpConfiguration customization for request header sizing via property/env/default.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 611 to +615
XML xml = new XML();
xml.setWrapped(true);
arrayObject.setXml(xml);
collectionObject.setXml(xml);
collectionObject.addProperties(objectSchemaDefinition.getPlural(), arrayObject);
collectionObject.addRequiredItem(objectSchemaDefinition.getPlural());
Comment on lines +620 to 629
private static ObjectSchema asRequiredResponseObjectSchema(
EntityDefinition objectSchemaDefinition) {
ObjectSchema object = asObjectSchema(objectSchemaDefinition);
if (object.getProperties() != null) {
for (String propertyName : object.getProperties().keySet()) {
object.addRequiredItem(propertyName);
}
}
return object;
}
Comment on lines 351 to 353
// add list response for entity plural
ArraySchema arrayObject = asArrayObjectSchema(objectSchemaDefinition);
ObjectSchema arrayObject = asArrayObjectSchema(objectSchemaDefinition);
components.addSchemas(objectSchemaDefinition.getPlural(), arrayObject);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants