-
Notifications
You must be signed in to change notification settings - Fork 4
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
Please add step-by-step example of posting the contract to the endpoint #135
Comments
Hello, I used https://github.com/HLTech/judge-d-contract-publisher-gradle-plugin to put the sample contract into judge-d-server. This is what I get from {
"name": "judge-d-example",
"version": "1.0-SNAPSHOT",
"capabilities": {
"rest": {
"value": "{\"swagger\":\"2.0\",\"info\":{\"description\":\"Api Documentation\",\"version\":\"1.0\",\"title\":\"Api Documentation\",\"termsOfService\":\"urn:tos\",\"contact\":{},\"license\":{\"name\":\"Apache 2.0\",\"url\":\"http://www.apache.org/licenses/LICENSE-2.0\"}},\"host\":\"localhost\",\"basePath\":\"/\",\"tags\":[{\"name\":\"environment-controller\",\"description\":\"Environment Controller\"}],\"paths\":{\"/environments/{name}\":{\"put\":{\"tags\":[\"environment-controller\"],\"summary\":\"Update the environment\",\"operationId\":\"update environment\",\"consumes\":[\"application/json\"],\"produces\":[\"*/*\"],\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"description\":\"name\",\"required\":true,\"type\":\"string\"},{\"in\":\"body\",\"name\":\"services\",\"description\":\"services\",\"required\":true,\"schema\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/ServiceForm\"}}}],\"responses\":{\"200\":{\"description\":\"Success\"},\"201\":{\"description\":\"Created\"},\"401\":{\"description\":\"Unauthorized\"},\"403\":{\"description\":\"Forbidden\"},\"404\":{\"description\":\"Not Found\"},\"500\":{\"description\":\"Failure\"}}}}},\"definitions\":{\"ServiceForm\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"version\":{\"type\":\"string\"}}}}}",
"mimeType": "application/json"
}
},
"expectations": {
"judge-d-server": {
"rest": {
"value": "{\"provider\":{\"name\":\"judge-d-server\"},\"consumer\":{\"name\":\"judge-d-agent\"},\"interactions\":[{\"description\":\"publish request; 200 OK response\",\"request\":{\"method\":\"PUT\",\"path\":\"environments/El2ukVED6J\",\"headers\":{},\"query\":\"\",\"body\":[{\"name\":\"ZAEkD_yJJf\",\"version\":\"cttO3Djh8X\"}]},\"response\":{\"status\":\"200\",\"headers\":{}}}],\"metadata\":{\"pactSpecificationVersion\":\"1.0.0\"}}",
"mimeType": "application/json"
}
}
}
} Now, how do I validate this sample contract? Calling [
{
"service": {
"name": "judge-d-example",
"version": "1.0-SNAPSHOT"
},
"validationReports": [
{
"consumerAndProvider": {
"consumerName": "judge-d-example",
"consumerVersion": "1.0-SNAPSHOT",
"providerName": "judge-d-server",
"providerVersion": null
},
"interactions": [
{
"communicationInterface": "rest",
"interactionName": "any",
"validationResult": "FAILED",
"errors": [
"provider not available"
]
}
]
}
]
}
] |
OK, so now I have also registered contract with the environment, which I have not done earlier, so the request to {
"environment": "sample",
"serviceContracts": [
{
"name": "judge-d-example",
"version": "1.0-SNAPSHOT",
"capabilities": {
"rest": {
"value": "{\"swagger\":\"2.0\",\"info\":{\"description\":\"Api Documentation\",\"version\":\"1.0\",\"title\":\"Api Documentation\",\"termsOfService\":\"urn:tos\",\"contact\":{},\"license\":{\"name\":\"Apache 2.0\",\"url\":\"http://www.apache.org/licenses/LICENSE-2.0\"}},\"host\":\"localhost\",\"basePath\":\"/\",\"tags\":[{\"name\":\"environment-controller\",\"description\":\"Environment Controller\"}],\"paths\":{\"/environments/{name}\":{\"put\":{\"tags\":[\"environment-controller\"],\"summary\":\"Update the environment\",\"operationId\":\"update environment\",\"consumes\":[\"application/json\"],\"produces\":[\"*/*\"],\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"description\":\"name\",\"required\":true,\"type\":\"string\"},{\"in\":\"body\",\"name\":\"services\",\"description\":\"services\",\"required\":true,\"schema\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/ServiceForm\"}}}],\"responses\":{\"200\":{\"description\":\"Success\"},\"201\":{\"description\":\"Created\"},\"401\":{\"description\":\"Unauthorized\"},\"403\":{\"description\":\"Forbidden\"},\"404\":{\"description\":\"Not Found\"},\"500\":{\"description\":\"Failure\"}}}}},\"definitions\":{\"ServiceForm\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"version\":{\"type\":\"string\"}}}}}",
"mimeType": "application/json"
}
},
"expectations": {
"judge-d-server": {
"rest": {
"value": "{\"provider\":{\"name\":\"judge-d-server\",\"version\":\"1.0\"},\"consumer\":{\"name\":\"judge-d-agent\"},\"interactions\":[{\"description\":\"publish request; 200 OK response\",\"request\":{\"method\":\"PUT\",\"path\":\"environments/El2ukVED6J\",\"headers\":{},\"query\":\"\",\"body\":[{\"name\":\"ZAEkD_yJJf\",\"version\":\"cttO3Djh8X\"}]},\"response\":{\"status\":\"200\",\"headers\":{}}}],\"metadata\":{\"pactSpecificationVersion\":\"1.0.0\"}}",
"mimeType": "application/json"
}
}
}
}
]
} But the request to |
OK, I think I'm getting somewhere. First, I did a {
"capabilities": {
"rest": {
"value": "{\"swagger\":\"2.0\",\"info\":{\"description\":\"Api Documentation\",\"version\":\"1.0\",\"title\":\"Api Documentation\",\"termsOfService\":\"urn:tos\",\"contact\":{},\"license\":{\"name\":\"Apache 2.0\",\"url\":\"http://www.apache.org/licenses/LICENSE-2.0\"}},\"host\":\"localhost\",\"basePath\":\"/\",\"tags\":[{\"name\":\"environment-controller\",\"description\":\"Environment Controller\"}],\"paths\":{\"/environments/{name}\":{\"put\":{\"tags\":[\"environment-controller\"],\"summary\":\"Update the environment\",\"operationId\":\"update environment\",\"consumes\":[\"application/json\"],\"produces\":[\"*/*\"],\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"description\":\"name\",\"required\":true,\"type\":\"string\"},{\"in\":\"body\",\"name\":\"services\",\"description\":\"services\",\"required\":true,\"schema\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/ServiceForm\"}}}],\"responses\":{\"200\":{\"description\":\"Success\"},\"201\":{\"description\":\"Created\"},\"401\":{\"description\":\"Unauthorized\"},\"403\":{\"description\":\"Forbidden\"},\"404\":{\"description\":\"Not Found\"},\"500\":{\"description\":\"Failure\"}}}}},\"definitions\":{\"ServiceForm\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"version\":{\"type\":\"string\"}}}}}",
"mimeType": "application/json"
}
},
"expectations": {
"judge-d-server": {
"rest": {
"value": "{\"provider\":{\"name\":\"judge-d-server\",\"version\":\"1.0\"},\"consumer\":{\"name\":\"judge-d-agent\"},\"interactions\":[{\"description\":\"publish request; 200 OK response\",\"request\":{\"method\":\"PUT\",\"path\":\"environments/El2ukVED6J\",\"headers\":{},\"query\":\"\",\"body\":[{\"name\":\"ZAEkD_yJJf\",\"version\":\"cttO3Djh8X\"}]},\"response\":{\"status\":\"200\",\"headers\":{}}}],\"metadata\":{\"pactSpecificationVersion\":\"1.0.0\"}}",
"mimeType": "application/json"
}
}
}
} Second, I did a [
{
"service": {
"name": "judge-d-server",
"version": "1.0"
},
"validationReports": [
{
"consumerAndProvider": {
"consumerName": "judge-d-server",
"consumerVersion": "1.0",
"providerName": "judge-d-server",
"providerVersion": "1.0"
},
"interactions": [
{
"communicationInterface": "rest",
"interactionName": "publish request; 200 OK response",
"validationResult": "OK",
"errors": []
},
{
"communicationInterface": "rest",
"interactionName": "publish request; 200 OK response",
"validationResult": "OK",
"errors": []
}
]
}
]
}
] I don'like that |
Hi, |
Hi, Now I get it. I need to specify POST {{baseUrl}}/contracts/services/judge-d-server/versions/1.0 {
"capabilities": {
"rest": {
"value": "{\"swagger\":\"2.0\",\"info\":{\"description\":\"Api Documentation\",\"version\":\"1.0\",\"title\":\"Api Documentation\",\"termsOfService\":\"urn:tos\",\"contact\":{},\"license\":{\"name\":\"Apache 2.0\",\"url\":\"http://www.apache.org/licenses/LICENSE-2.0\"}},\"host\":\"localhost\",\"basePath\":\"/\",\"tags\":[{\"name\":\"environment-controller\",\"description\":\"Environment Controller\"}],\"paths\":{\"/environments/{name}\":{\"put\":{\"tags\":[\"environment-controller\"],\"summary\":\"Update the environment\",\"operationId\":\"update environment\",\"consumes\":[\"application/json\"],\"produces\":[\"*/*\"],\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"description\":\"name\",\"required\":true,\"type\":\"string\"},{\"in\":\"body\",\"name\":\"services\",\"description\":\"services\",\"required\":true,\"schema\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/ServiceForm\"}}}],\"responses\":{\"200\":{\"description\":\"Success\"},\"201\":{\"description\":\"Created\"},\"401\":{\"description\":\"Unauthorized\"},\"403\":{\"description\":\"Forbidden\"},\"404\":{\"description\":\"Not Found\"},\"500\":{\"description\":\"Failure\"}}}}},\"definitions\":{\"ServiceForm\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"version\":{\"type\":\"string\"}}}}}",
"mimeType": "application/json"
}
},
"expectations": {}
} POST {{baseUrl}}/contracts/services/judge-d-example/versions/1.0 {
"capabilities": {},
"expectations": {
"judge-d-server": {
"rest": {
"value": "{\"provider\":{\"name\":\"judge-d-server\",\"version\":\"1.0\"},\"consumer\":{\"name\":\"judge-d-example\"},\"interactions\":[{\"description\":\"publish request; 200 OK response\",\"request\":{\"method\":\"PUT\",\"path\":\"environments/El2ukVED6J\",\"headers\":{},\"query\":\"\",\"body\":[{\"name\":\"ZAEkD_yJJf\",\"version\":\"cttO3Djh8X\"}]},\"response\":{\"status\":\"200\",\"headers\":{}}}],\"metadata\":{\"pactSpecificationVersion\":\"1.0.0\"}}",
"mimeType": "application/json"
}
}
}
} PUT {{baseUrl}}/environments/sample [
{
"name": "judge-d-example",
"version": "1.0"
},
{
"name": "judge-d-server",
"version": "1.0"
}
] GET {{baseUrl}}/environment-compatibility-report?services=judge-d-example:1.0&environment=sample [
{
"service": {
"name": "judge-d-example",
"version": "1.0"
},
"validationReports": [
{
"consumerAndProvider": {
"consumerName": "judge-d-example",
"consumerVersion": "1.0",
"providerName": "judge-d-server",
"providerVersion": "1.0"
},
"interactions": [
{
"communicationInterface": "rest",
"interactionName": "publish request; 200 OK response",
"validationResult": "OK",
"errors": []
}
]
}
]
}
] Thanks for support! |
Perfect:). I will keep this task open and we will verify here README. Maybe we can add better description there. |
Hello,
I am trying to understand how to interact with Judge D. Could you please explain how to feed the REST endpoints with the pact and swagger files described in the README.md? I've run through the tests to see how this would be done, but they are based on very simple (to say the least) data, which doesn't shed much light. I've also tried to use judge-d-ui, but the heroku page gives an error message, and the docker-compose version I put up on my machine gave no response to my browser's request to localhost:8081.
Best regards,
Piotr
The text was updated successfully, but these errors were encountered: