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

ENHANCEMENT: extend components section for all allowed types #88

Open
bitkid opened this issue Feb 24, 2023 · 2 comments
Open

ENHANCEMENT: extend components section for all allowed types #88

bitkid opened this issue Feb 24, 2023 · 2 comments

Comments

@bitkid
Copy link

bitkid commented Feb 24, 2023

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?

@derveloper
Copy link
Owner

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.

@bitkid
Copy link
Author

bitkid commented May 3, 2023

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

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

2 participants