@Test void givenSecurityScheme_whenItIsSerializingToJson_thenEnumTypesShouldPrintedLowercase() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); Writer jsonWriter = new StringWriter(); JsonGenerator jsonGenerator = new JsonFactory().createGenerator(jsonWriter); jsonGenerator.setCodec(objectMapper); SerializerProvider provider = objectMapper.getSerializerProvider(); new SecuritySchemeSerializer().serialize(getDummyScheme(), jsonGenerator, provider); jsonGenerator.flush(); assertEquals("{\"type\":\"http\",\"description\":\"desc\",\"name\":\"name\",\"$ref\":\"#/components/securitySchemes/ref\",\"in\":\"cookie\",\"scheme\":\"scheme\",\"bearerFormat\":\"format\",\"flows\":{},\"openIdConnectUrl\":\"url\",\"extensions\":{}}", jsonWriter.toString()); }
@Override public void serialize(SecurityScheme value, JsonGenerator jGen, SerializerProvider serializers) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String securitySchemeContent = objectMapper.writeValueAsString(value); ObjectNode jsonNode = objectMapper.readValue(securitySchemeContent, ObjectNode.class); SecurityScheme.Type securitySchemeType = value.getType(); if (securitySchemeType != null) { jsonNode.put("type", securitySchemeType.toString()); } SecurityScheme.In securitySchemeIn = value.getIn(); if (securitySchemeIn != null) { jsonNode.put("in", securitySchemeIn.toString()); } jGen.writeObject(jsonNode); }
SecuritySchemeSerializer extends JsonSerializer<SecurityScheme> { @Override public void serialize(SecurityScheme value, JsonGenerator jGen, SerializerProvider serializers) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String securitySchemeContent = objectMapper.writeValueAsString(value); ObjectNode jsonNode = objectMapper.readValue(securitySchemeContent, ObjectNode.class); SecurityScheme.Type securitySchemeType = value.getType(); if (securitySchemeType != null) { jsonNode.put("type", securitySchemeType.toString()); } SecurityScheme.In securitySchemeIn = value.getIn(); if (securitySchemeIn != null) { jsonNode.put("in", securitySchemeIn.toString()); } jGen.writeObject(jsonNode); } }
SecuritySchemeSerializer extends JsonSerializer<SecurityScheme> { @Override public void serialize(SecurityScheme value, JsonGenerator jGen, SerializerProvider serializers) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String securitySchemeContent = objectMapper.writeValueAsString(value); ObjectNode jsonNode = objectMapper.readValue(securitySchemeContent, ObjectNode.class); SecurityScheme.Type securitySchemeType = value.getType(); if (securitySchemeType != null) { jsonNode.put("type", securitySchemeType.toString()); } SecurityScheme.In securitySchemeIn = value.getIn(); if (securitySchemeIn != null) { jsonNode.put("in", securitySchemeIn.toString()); } jGen.writeObject(jsonNode); }  }
SecuritySchemeSerializer extends JsonSerializer<SecurityScheme> { @Override public void serialize(SecurityScheme value, JsonGenerator jGen, SerializerProvider serializers) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String securitySchemeContent = objectMapper.writeValueAsString(value); ObjectNode jsonNode = objectMapper.readValue(securitySchemeContent, ObjectNode.class); SecurityScheme.Type securitySchemeType = value.getType(); if (securitySchemeType != null) { jsonNode.put("type", securitySchemeType.toString()); } SecurityScheme.In securitySchemeIn = value.getIn(); if (securitySchemeIn != null) { jsonNode.put("in", securitySchemeIn.toString()); } jGen.writeObject(jsonNode); }  @Override void serialize(SecurityScheme value, JsonGenerator jGen, SerializerProvider serializers); }
SecuritySchemeSerializer extends JsonSerializer<SecurityScheme> { @Override public void serialize(SecurityScheme value, JsonGenerator jGen, SerializerProvider serializers) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String securitySchemeContent = objectMapper.writeValueAsString(value); ObjectNode jsonNode = objectMapper.readValue(securitySchemeContent, ObjectNode.class); SecurityScheme.Type securitySchemeType = value.getType(); if (securitySchemeType != null) { jsonNode.put("type", securitySchemeType.toString()); } SecurityScheme.In securitySchemeIn = value.getIn(); if (securitySchemeIn != null) { jsonNode.put("in", securitySchemeIn.toString()); } jGen.writeObject(jsonNode); }  @Override void serialize(SecurityScheme value, JsonGenerator jGen, SerializerProvider serializers);  }