rest-schemagen
rest-schemagen copied to clipboard
Schema does not contain information about all parameters
In LinkCreator.createFor
(line 133) the schema is only generated for the last resource on the path, information from previous resources is ignored.
Not sure if I understand your question correctly. If you have subresources, you have to give the full chain of resources so that the generator is able to create the path correctly. The method for which the link is created has to be on the last resource.
The path is generated correctly, but the schema is not. The full chain is given, but only the last segment of it is used at the code I mentioned.
Do you have an example of a case where this is wrong. Is it the case where a subresource method is not allowed and this is not considered here or do you miss query or path parameters from one of the subresource methods before?
I have one back at Mercateo, I will show you on Monday if you're interested. We had the issue with a path /api/shops/{shop id}/something/{something id}
. In the schema only the {something id}
was documented, but not {shop id}
.
There is a resource for /api/shops/
, and another resource for /api/shops/{shop id}/something/
.
What I miss is the schema information for {shop id}
. The path is correct. I fail do understand how to make this clearer, the very first word of this issue is "schema" after all.
So your path parameter shop_id
should be also contained in the input and/or output schema objects of the endpoint as well? Then it is not only a path parameter, but some kind of redundancy in the payload as well. This can be achieved by using an allowed value object (aka ENUM) with the shop_id being set to the desired value.
When i get it right he want's to have a template link with the parameter not set.
Then lets better base this on an example or a failing test.
This is the result created using the library. As you can see the schema contains the last path variable {id}, but not the one before {app-id}.
This issue is caused by the code line I mentioned above.
Does that help?
The problem is that in the method addSchemaIfNeeded only the lastScopedMethod
is used: https://github.com/Mercateo/rest-schemagen/blob/af1d28141c9f3b1ccf00c0a1da7196378bfe3598/src/main/java/com/mercateo/common/rest/schemagen/link/LinkCreator.java#L135