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

Change in lettercase results in error #495

Open
slorenzbmw opened this issue Mar 22, 2023 · 2 comments
Open

Change in lettercase results in error #495

slorenzbmw opened this issue Mar 22, 2023 · 2 comments

Comments

@slorenzbmw
Copy link

If i try to diff two files where only the following is different, i get the following error

Compare 1:
{ "name": "oneLine", "description": "***", "required": false, "in": "query", "type": "string" },
Compare 2:
{ "name": "online", "description": "***", "required": false, "in": "query", "type": "string" },
=> see the difference in "l" and "L" in the parameter "name"

Error:
Unexpected exception. Reason: Cannot invoke "String.isEmpty()" because "newParameterName" is null java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because "newParameterName" is null at org.openapitools.openapidiff.core.compare.ParametersDiff.pathUnchangedParametersChanged(ParametersDiff.java:102) at org.openapitools.openapidiff.core.compare.ParametersDiff.diff(ParametersDiff.java:88) at org.openapitools.openapidiff.core.compare.OperationDiff.diff(OperationDiff.java:78) at org.openapitools.openapidiff.core.compare.PathDiff.diff(PathDiff.java:39) at org.openapitools.openapidiff.core.compare.PathsDiff.lambda$diff$3(PathsDiff.java:90) at java.base/java.util.LinkedHashMap$LinkedKeySet.forEach(LinkedHashMap.java:589) at org.openapitools.openapidiff.core.compare.PathsDiff.diff(PathsDiff.java:47) at org.openapitools.openapidiff.core.compare.OpenApiDiff.compare(OpenApiDiff.java:96) at org.openapitools.openapidiff.core.compare.OpenApiDiff.compare(OpenApiDiff.java:64) at org.openapitools.openapidiff.core.OpenApiCompare.fromSpecifications(OpenApiCompare.java:102) at org.openapitools.openapidiff.core.OpenApiCompare.fromLocations(OpenApiCompare.java:91) at org.openapitools.openapidiff.cli.Main.main(Main.java:175)

I can trace it back to here:

@joschi
Copy link
Collaborator

joschi commented Mar 22, 2023

@slorenzbmw Thanks for reporting this!

I'm unable to reproduce your issue with a simple test:

--- core/src/test/resources/issue-495_1.yaml	2020-06-23 08:24:12
+++ core/src/test/resources/issue-495_2.yaml	2023-03-22 21:32:47
@@ -37,7 +37,7 @@
       description: Multiple status values can be provided with comma separated strings
       operationId: findPetsByStatus
       parameters:
-        - name: status
+        - name: Status
           in: query
           description: Status values that need to be considered for filter
           required: true

Could you please provide a minimal example to reproduce the issue?

@slorenzbmw
Copy link
Author

slorenzbmw commented Mar 23, 2023

Thanks for looking into this!
What i missed in my inital comment is that also a letter was added, but i could reproduce it both by changing the lettercase and removing / adding a letter to a parameter
i tested it on:

  • Java Zulu 11
  • Java Zulu 17

and could reproduce it with this minimum set:
old

{
  "swagger": "2.0",
  "info": {
    "title": "***",
    "version": "v1"
  },
  "host": "***",
  "basePath": "***",
  "schemes": [
    "https"
  ],
  "paths": {
    "/test": {
      "get": {
        "description": "***",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "online",
            "description": "***",
            "required": false,
            "in": "query",
            "type": "string"
          }
        ]
      }
    }
  }
}

new

{
  "swagger": "2.0",
  "info": {
    "title": "***",
    "version": "v1"
  },
  "host": "***",
  "basePath": "***",
  "schemes": [
    "https"
  ],
  "paths": {
    "/test": {
      "get": {
        "description": "***",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "oneLine",
            "description": "***",
            "required": false,
            "in": "query",
            "type": "string"
          }
        ]
      }
    }
  }
}

Any change on the parameter "name" results in a java.lang.NullPointerException for me

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

2 participants