Closed alemhnan closed 7 years ago
What do you mean by parameters? validation rules?
No sorry, my bad. I mean the inputs of the command. In your cqrs-sample, for createItem
it will be id
, command
, and payload.text
.
As input yes. There you need to know a priori the structure of the command for every command in your system. What I would like is to have that structure (pretty much the json schemas defined in your command library I think) in the getInfo()
method.
Probably I do not fully understand... Can you do a little example on what you would expect?
Sure, I'll provide a small example tomorrow morning.
The getInfo
of your example returns this:
{
name: 'createItem',
version: 0,
preConditions: [],
preLoadConditions: []
}
Here I cannot inspect the payload structure. I would like something like this:
{
name: 'createItem',
version: 0,
preConditions: [],
preLoadConditions: [],
payload: {
type: "object",
properties: {
text: { type: "string" }
},
required: ["text"]
}
}
Now with that information, I can programmatically feed another representation (like Swagger for instance). The end goal is to generate a swagger interface like this:
Hence I need the name of the command and the payload to pass along (and hopefully nothing more but I'm still working on it).
Does it make sense?
So basically a part (the payload) of the validationRule... The problem is, this is very specific... In theory a command does not need to have a property 'payload', it can be anything... the structure of the message is not strict
But on your specific implementation you can extend it on your own...
Ok, thanks for the answer. I'll look into it. Where do you suggest to look to extend for this use case?
directly after receiving the result of the getInfo function
This is more a feature request than a bug. I am wiring the commands into HTTP module using Swagger (with LoopBack). I would like to create one route for each command automatically and to specify as well the parameters needed.
Using getInfo, I can get the command names, but I do not have access to the parameters needed (or at least it does not seem so).
Is there a way to get that information at runtime? Otherwise, I will be happy to provide a PR (if you think that makes sense to have that). In such case could you point me the relevant codebase?