-
Notifications
You must be signed in to change notification settings - Fork 0
Improves OpenAPI spec names and types and error reporting #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
OwenGraves
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
| 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| "UTCTime" -> setSchemaInfoFormat "date-time" $ mkPrimitiveSchema "string" OpenApi.OpenApiString | ||
| "Day" -> setSchemaInfoFormat "date" $ mkPrimitiveSchema "string" OpenApi.OpenApiString |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
This uses the new
json-fleeceAPI to improve the names and typesgiven 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.