Closed lns-ross closed 1 year ago
Hi,
this is a limitation of the dsl and currently not possible. I'm looking into a possible solution. My current idea would be to allow also specifying whether the body of the given schema is a single object or an array. The options would then look a bit like this:
body("myRequestData")
- specifies a single object of the given custom schema (current implementation)body(obj("myRequestData"))
- specifies a single object of the given custom schema (same as body("myRequestData")
)body(array("myRequestData"))
- specifies an array of objects of the given custom schemaI would appreciate your opinion, feedback or other suggestions :)
Thx for the quick response!
That definitely looks like it would get the job done. The only other way I can think of doing it would be to set an isArray
indicator in the request/response "builder" to indicate it directly. Your suggestion would be a lot more concise.
Since we had no way to intercept the body generator to do the wrapping the work-around we used was to register both "myCustomSchema" and "[myCustomSchema]" (which was an ArraySchema().items = customSchemaSpec
) and then reference the appropriate one. Clunky but it achieved a usable result.
With your suggested change the body generator will now be capable of doing the wrapping which will remove a lot of redundant schema data (for us) and reduce the work we need do in the registration section. ... And it will look a lot nicer too.
Nice. :grin:
Works like a charm! :partying_face:
Thx.
Hi! I may not have found the secret sauce for this if it exists ...
I was unable to specify a custom schema item by id in the
schemas
section of the plugin config and then use that for a response body that was a collection of that item, i.e. the equivalent ofbody<List<ABC>>()
or something similar.I was able to do it by defining a second schema that wrapped the first as an array item but that ended up replicating the base schema into the components section of the
api.json
with a simple array specifier.Am I missing something? Or is this a limitation of the DSL for now?
TIA.