Skip to content
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

Respect allOf when generating mocked responses. #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sammarks
Copy link

In my usage of this library, I'll run into something similar to the following schema:

{
    "type": "object",
    "required": ["name", "photoUrls"],
    "allOf": [
        {
            "type": "object",
            "properties": {
                "test-one": {
                    "type": "integer",
                    "format": "int64"
                }
            }
        },
        {
            "type": "object",
            "properties": {
                "test-two": {
                    "type": "integer",
                    "format": "int64",
                    "example": 20
                }
            }
        }
    ],
    "properties": {
        "id": {
            "type": "integer",
            "format": "int64"
        },
        "category": {
            "$ref": "#/definitions/Category"
        },
        "name": {
            "type": "string",
            "example": "doggie"
        },
        "photoUrls": {
            "type": "array",
            "xml": {
                "name": "photoUrl",
                "wrapped": true
            },
            "items": {
                "type": "string"
            }
        },
        "tags": {
            "type": "array",
            "minItems": 2,
            "maxItems": 5,
            "xml": {
                "name": "tag",
                "wrapped": true
            },
            "items": {
                "$ref": "#/definitions/Tag"
            }
        },
        "status": {
            "type": "string",
            "description": "pet status in the store",
            "enum": ["available", "pending", "sold"]
        }
    },
    "xml": {
        "name": "Pet"
    }
}

Currently, the library doesn't generate values for test-one or test-two since they're hidden inside the allOf clause of the schema. This PR updates the response mocker to respect the allOf clause and generate values for it as well.

@enmand
Copy link

enmand commented Sep 13, 2018

Any change on getting this merged in, and a new NPM release up? 🙏

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.

2 participants