jackson-databind-nullable icon indicating copy to clipboard operation
jackson-databind-nullable copied to clipboard

The openapi swagger codegen generates JsonNullable type fields if the type attribute in swagger is not mentioned. How to overcome this without modifying the swagger. I want JsonNullable for other fields except few.

Open gayatrivgk opened this issue 2 years ago • 1 comments

The openapi swagger codegen generates JsonNullable type fields if the type attribute in swagger is not mentioned. How to overcome this without modifying the swagger. I want JsonNullable for other fields except few.

Sample Swagger: openapi: 3.0.3 components: schemas: Filter: required: - name - value type: object properties: name: title: Name type: string value: title: Value

In the above sample swagger, the value field is generated as JsonNullable. But i want it to be created as Object type. How to handle this without changing the swagger. Also i dont want to disable JsonNullable for entire swagger. is there a way to achieve this?

gayatrivgk avatar Oct 10 '23 09:10 gayatrivgk

This project is only used for interactions with a class that already has JsonNullable attached to it. This is an issue you would need to discuss with the maintainers for whatever tool you're using to generate the Java classes.

Assuming you're using https://github.com/OpenAPITools/openapi-generator, I'm not aware of a trivial way to do what you're requesting. You could use probably custom templates and add your own configuration option with an exclude list of property names. But again, that's something you would need to review with the tool you're using to generate your classes and likely consult something like https://stackoverflow.com/ for questions on how to do what you're requesting.

nrayburn-tech avatar Sep 24 '25 16:09 nrayburn-tech