Skip to content

Prevent the need for repetition in sample definitions#2

Merged
txels merged 1 commit intomasterfrom
txels/inheritable-properties
Sep 17, 2015
Merged

Prevent the need for repetition in sample definitions#2
txels merged 1 commit intomasterfrom
txels/inheritable-properties

Conversation

@txels
Copy link
Copy Markdown
Member

@txels txels commented Sep 12, 2015

Allow one to skip repeating the request URL in all samples, which is the case when the URL of the endpoint under tests is fixed (contains no variable parts).

E.g. this is an example from a project I'm working on:

{
    "description": "Retrieve profile of logged in user",
    "url": "/accounts/me",
    "method": "GET",
    "examples": {
        "OK": {
            "response": {
                "status": 200,
                "body": {
                    "id": 1,
                    "username": "user-0",
                    "first_name": "",
                    "last_name": "",
                    "email": "user-0@example.com"
                }
            }
        },
        "unauthenticated": {
            "description": "I am not logged in",
            "response": {
                "status": 403,
                "body": {
                    "detail": "Authentication credentials were not provided."
                }
            }
        }
    }
}

Before this PR, I had to write:

{
    "description": "Retrieve profile of logged in user",
    "url": "/accounts/me",
    "method": "GET",
    "examples": {
        "OK": {
            "request": {
                "url": "/accounts/me"
            },
            "response": {
                "status": 200,
                "body": {
                    "id": 1,
                    "username": "user-0",
                    "first_name": "",
                    "last_name": "",
                    "email": "user-0@example.com"
                }
            }
        },
        "unauthenticated": {
            "description": "I am not logged in",
            "request": {
                "url": "/accounts/me"
            },
            "response": {
                "status": 403,
                "body": {
                    "detail": "Authentication credentials were not provided."
                }
            }
        }
    }
}

...which includes some tedious repetition.

@txels
Copy link
Copy Markdown
Member Author

txels commented Sep 12, 2015

@nwhite89 this change somehow modifies the semantics of an ABE file, as it defines the meaning when a request section is missing.

This made me realise that in ABE-spec, we need to document better what all fields mean, what is optional and mandatory, etc.

Also, this PR may imply a change in the format version and as such we need to update the JS packages that use the format.

Let me know what you think. Maybe we want to start with a PR to the spec?

txels added a commit that referenced this pull request Sep 17, 2015
Prevent the need for repetition in sample definitions
@txels txels merged commit ee3992f into master Sep 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant