mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 08:46:10 +00:00
[cli][gradle] Validate now uses parseOptions w/setResolve (#5471)
* [cli] Validate now uses parseOptions w/setResolve The validate command now uses ParseOptions#setResolve(true) to match how we parse in CodegenConfigurator and online's Generate. Without this option, the OpenAPI 3 parser skips the "resolve" block, which made lead to validations in the command not matching validations during generation. * [gradle] Validate now uses parseOptions w/setResolve The Graldle validate command now uses ParseOptions#setResolve(true) to match how we parse in CodegenConfigurator and online's Generate. Without this option, the OpenAPI 3 parser skips the "resolve" block, which made lead to validations in the command not matching validations during generation.
This commit is contained in:
@@ -22,6 +22,7 @@ import io.airlift.airline.Option;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
import io.swagger.v3.parser.core.models.SwaggerParseResult;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.openapitools.codegen.validation.ValidationResult;
|
||||
@@ -45,8 +46,9 @@ public class Validate implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Validating spec (" + spec + ")");
|
||||
|
||||
SwaggerParseResult result = new OpenAPIParser().readLocation(spec, null, null);
|
||||
ParseOptions options = new ParseOptions();
|
||||
options.setResolve(true);
|
||||
SwaggerParseResult result = new OpenAPIParser().readLocation(spec, null, options);
|
||||
List<String> messageList = result.getMessages();
|
||||
Set<String> errors = new HashSet<>(messageList);
|
||||
Set<String> warnings = new HashSet<>();
|
||||
|
||||
Reference in New Issue
Block a user