kotlin-openapi3-dsl icon indicating copy to clipboard operation
kotlin-openapi3-dsl copied to clipboard

ENHANCEMENT: extend components section for all allowed types

Open bitkid opened this issue 2 years ago • 2 comments

it would be nice to be able to define all reusable components (parameters, responses ..) in the components section

and make it possible to reference them ... maybe like parameterRef("myParam")

would that be a useful feature?

bitkid avatar Feb 24 '23 13:02 bitkid

Hi bitkid,

thanks four your issue.

can you please provide a bit more information? How should it look in the code? I must admit, that I currently not creating OAS3 Apis often. I'm also open to merge a PR.

derveloper avatar Apr 24 '23 16:04 derveloper

i use something along these lines .. not sure if its worth a PR

fun Components.parameter(init: Parameter.() -> Unit) { val parameter = Parameter() parameter.init() if (parameter.name.isNullOrBlank()) error("parameter name has to be set") addParameters(parameter.name, parameter) }

fun Operation.parameterRef(name: String) { addParametersItem(Parameter().apply { $ref = name }) }

bitkid avatar May 03 '23 11:05 bitkid