Skip to content

Conversation

@qxjit
Copy link
Member

@qxjit qxjit commented Dec 12, 2025

This uses the new json-fleece API to improve the names and types
given to OpenAPI specs.

This includes a change that restricts the characters allowed in the name
of an OpenAPI spec. This default is to allow alphanumeric characters, plus
'.' and '_'. The list of allowed characters can be specified both via
the various functions that build OpenAPI specs and the default command
line generation command.

This also improves the error reporting when schemas have conflicts or
bad names to try to provide context of where the offending spec is
contained within the spec definitions so that the developer can more
easily locate the offending specs within the code.

This uses the new `json-fleece` API to improve the names and types
given to OpenAPI specs.

This includes a change that restricts the characters allowed in the name
of an OpenAPI spec. This default is to allow alphanumeric characters, plus
'.' and '_'. The list of allowed characters can be specified both via
the various functions that build OpenAPI specs and the default command
line generation command.

This also improves the error reporting when schemas have conflicts or
bad names to try to provide context of where the offending spec is
contained within the spec definitions so that the developer can more
easily locate the offending specs within the code.
Copy link

@OwenGraves OwenGraves left a comment

Choose a reason for hiding this comment

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

🎉

Comment on lines +1060 to +1069
FleeceOpenApi $ Right . mkPrimitiveSchema "number" OpenApi.OpenApiNumber

text =
FleeceOpenApi . Right $ mkPrimitiveSchema "text" OpenApi.OpenApiString
FleeceOpenApi $ Right . mkPrimitiveSchema "text" OpenApi.OpenApiString

boolean =
FleeceOpenApi . Right $ mkPrimitiveSchema "boolean" OpenApi.OpenApiBoolean
FleeceOpenApi $ Right . mkPrimitiveSchema "boolean" OpenApi.OpenApiBoolean

null =
FleeceOpenApi . Right $ mkPrimitiveSchema "null" OpenApi.OpenApiNull
FleeceOpenApi $ Right . mkPrimitiveSchema "null" OpenApi.OpenApiNull

Choose a reason for hiding this comment

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

Just out of curiosity, what's the motivation for this swap?

Copy link
Member Author

Choose a reason for hiding this comment

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

The type of FleeceOpenApi changed from Either OpenApiError SchemaInfo to Path -> Either OpenApiError SchemaInfo. To accommodate that change here mkPrimitiveSchema now takes the Path as its last parameter. For the types to work out here, Right needs to be composed with mkPrimitiveSchema to make the Path -> Either OpenApiError SchemaInfo function that FleeceOpenApi now takes as its argument. Composing FleeceOpenApi . Right no longer works with the new types.

Comment on lines -1162 to -1163
"UTCTime" -> setSchemaInfoFormat "date-time" $ mkPrimitiveSchema "string" OpenApi.OpenApiString
"Day" -> setSchemaInfoFormat "date" $ mkPrimitiveSchema "string" OpenApi.OpenApiString

Choose a reason for hiding this comment

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

Where did this behavior get refactored to, is it inside of fleece now?

Choose a reason for hiding this comment

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

Ah, I see the other pr now

@qxjit qxjit merged commit e4b2490 into main Dec 12, 2025
5 checks passed
@qxjit qxjit deleted the qxjit/improve-open-api-names branch December 12, 2025 20:42
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.

3 participants