aws-cloudformation / aws-cloudformation/cloudformation-cli

contract_tests: contract_create_read_success and primaryIdentifiers in responses

Open
#730 20 comments 0 reactions 0 assignees View on GitHub
contract tests
Dominant language
Python
Stars
336
Forks
172
Avg merge
3d 5m
Merged PRs (30d)
3

Description

When a customer wants to create a our resource, he sends a request like so:

```json
{
"ourObj": {
"someProp": "someValue"
}
}
```

And our API, upon successful creation, will return the following:

```json
{
"ourObj": {
"someProp": "someValue",
"id": "ourJustGeneratedObjId"
}
}
```

It seems that there is no way at all to pass the contract-tests with this schema. Passing a hard-coded value for `ourObj.id` does not make sense, as the delete test will fail.

I've worked around the `contract_create_delete` failure by copying `ourObj.id` to another property in the schema:

```json
{
"CfnId": "ourJustGeneratedObjId",
"ourObj": {
"someProp": "someValue",
"id": "ourJustGeneratedObjId"
}
}
```

`CfnId` is set as the `primaryIdentifier`.

This way, the model sent in the request is returned back in the response - none have the `ourObj.id`. However, our customers may be relying on the existence of this `id` inside `ourObj`.

What can be done about this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.