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

exampleSetFlag leaks in json output produced by ObjectMapper #3702

Closed
fstaudt opened this issue Sep 21, 2020 · 4 comments
Closed

exampleSetFlag leaks in json output produced by ObjectMapper #3702

fstaudt opened this issue Sep 21, 2020 · 4 comments

Comments

@fstaudt
Copy link

fstaudt commented Sep 21, 2020

Since 2.1.4, the field exampleSetFlag appears in json produced with ObjectMapper#writeValue(File, Object) when serializing an object of type OpenApi.

Using swagger-core 2.1.3 (OK) :

{
  "openapi" : "3.0.1",
  "paths" : {
    "/api/some" : {
      "get" : {
        "operationId" : "get-some",
        "responses" : {
          "400" : {
            "description" : "error",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components" : {
    "schemas" : {
      "error" : {
        "type" : "object",
        "properties" : {
          "returnCode" : {
            "type" : "string"
          }
        }
      }
    }
  }
}

Since swagger-core 2.1.4 (not OK):

{
  "openapi" : "3.0.1",
  "paths" : {
    "/api/some" : {
      "get" : {
        "operationId" : "get-some",
        "responses" : {
          "400" : {
            "description" : "error",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/error",
                  "exampleSetFlag" : false
                }
              }
            }
          }
        }
      }
    }
  },
  "components" : {
    "schemas" : {
      "error" : {
        "type" : "object",
        "properties" : {
          "returnCode" : {
            "type" : "string",
            "exampleSetFlag" : false
          }
        },
        "exampleSetFlag" : false
      }
    }
  }
}

It seems to me that the field exampleSetFlag is internal and should be ignored by jackson object mapper.

Could you update the class Schema to add annotation @JsonIgnore on field exampleSetFlag, like it is already done for field name ?

I can submit a PR if you're OK with it.

@frantuma
Copy link
Member

thanks for reporting this, please see this comment about using the correctly configured object mapper.

closing ticket, please reopen if you're still experiencing issues

@fstaudt
Copy link
Author

fstaudt commented Sep 29, 2020

@frantuma

thanks for pointing to this comment.

As you suggested, I added a MixIn class to my ObjectMapper to ignore the new field in JSON serialization.

@alebastrov
Copy link

This is not enough solution, see #4381

@TeemuKurki
Copy link

If anyone else is having this issue make sure you have imported ObjectMapper from io.swagger.v3.core.util.Json and not from io.swagger.util.Json.

Both have similar interfaces, but only io.swagger.v3.core.util.Json excludes exampleSetFlag

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

4 participants