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

[Gradle Plugin]: openApiValidate - how to validate multiple yaml files ? #4643

Closed
rolandg333 opened this issue Nov 28, 2019 · 2 comments
Closed

Comments

@rolandg333
Copy link

Description

i can validate a single .yaml file using

openApiValidate {
inputSpec = 'file.yaml'
}

But my project has several .yaml files.
I would like to validate them all before packing them up into a .zip artifact on a build step.

How ?

openapi-generator version

id 'org.openapi.generator' version '4.2.1'

@jimschubert
Copy link
Member

jimschubert commented Jan 30, 2020

Hey. Sorry, just getting caught up on a huge backlog of issues/questions that we accrued over the holidays.

You've probably already figured this one out, but I wanted to comment for anyone else who might find your question.

task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
    inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
}

task validateBadSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
    inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
}

task validateSpecs(dependsOn: ['validateGoodSpec', 'validateBadSpec'])

The openApiValidate definition you've shown in your description is a project extension which has an identical task. All tasks in the plugin can be defined explicitly as I've done above. There are multiple examples in the local-spec sample.

If there's interest, we can add the example to our readme or sample script. I'm hesitant to do this because we already have examples of customizing GenerateTask, and I think it'll add little value and possibly make the readme harder to follow if each project extension includes an example of how to extend the underlying task. In that regard, I hope you don't mind that I'll close the issue?

@jimschubert
Copy link
Member

I decided to add docs in #5167. I figured if you had the question, others probably do as well.

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