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

Array of Object Response Changes Not Detected #21

Open
stt19 opened this issue Feb 25, 2019 · 3 comments
Open

Array of Object Response Changes Not Detected #21

stt19 opened this issue Feb 25, 2019 · 3 comments

Comments

@stt19
Copy link

stt19 commented Feb 25, 2019

For example, if in petstore_v2_1.json and petstore_v2_2.json you change lines ~723 and ~722 respectively from
"schema": { "$ref": "#/definitions/User" }
to
"schema": { "type" : "array", "items" : { "$ref" : "#/definitions/User" } }
it will no longer detect that there was a change, even though it previously was caught (GET /user/{username}) when it was only a single object being returned. This is pretty important if you only return a certain object type from an endpoint as an array.

@stt19
Copy link
Author

stt19 commented Feb 26, 2019

I think this is the fix for the array-to-array comparison. It works for me as far as I can tell. In SpecificationDiff.java:

Original:

private static Property getResponseProperty(Operation operation) {
    Map<String, Response> responses = operation.getResponses();
    // temporary workaround for missing response messages
    if (responses == null) return null;
    Response response = responses.get("200");
    return null == response ? null : response.getSchema();
}

Refactor to handle array:

private static Property getResponseProperty(Operation operation) {
    Map<String, Response> responses = operation.getResponses();
    // temporary workaround for missing response messages
    if (responses == null) return null;
    Response response = responses.get("200");
    if(response != null && response.getSchema() instanceof ArrayProperty) {
        ArrayProperty prop = (ArrayProperty)response.getSchema();
        return prop.getItems();
    }
    return null == response ? null : response.getSchema();
}

@herve-brun
Copy link

Hi ! This issue is a blocker for us ...

@Sayi Do you plan to merge #30 anytime soon ?

@nmische
Copy link

nmische commented Jan 15, 2021

@Sayi - Any plans to merge and release an update with this fix? I see this was merged in v1.2.2, however I do not see this difference in the HTML report. I will take another look at this and file a separate issue around HTML reporting if needed.

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

No branches or pull requests

3 participants