class 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);
    }

}