org.openapi4j.parser.validation.v3.ResponseValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-parser Show documentation
Show all versions of openapi-parser Show documentation
openapi4j schema parser & validator
package org.openapi4j.parser.validation.v3;
import org.openapi4j.core.validation.ValidationResults;
import org.openapi4j.parser.model.v3.OpenApi3;
import org.openapi4j.parser.model.v3.Response;
import org.openapi4j.parser.validation.ValidationContext;
import org.openapi4j.parser.validation.Validator;
import static org.openapi4j.parser.validation.v3.OAI3Keywords.$REF;
import static org.openapi4j.parser.validation.v3.OAI3Keywords.CONTENT;
import static org.openapi4j.parser.validation.v3.OAI3Keywords.DESCRIPTION;
import static org.openapi4j.parser.validation.v3.OAI3Keywords.EXTENSIONS;
import static org.openapi4j.parser.validation.v3.OAI3Keywords.HEADERS;
import static org.openapi4j.parser.validation.v3.OAI3Keywords.LINKS;
class ResponseValidator extends Validator3Base {
private static final Validator INSTANCE = new ResponseValidator();
private ResponseValidator() {
}
public static Validator instance() {
return INSTANCE;
}
@Override
public void validate(ValidationContext context, OpenApi3 api, Response response, ValidationResults results) {
if (response.isRef()) {
validateReference(context, api, response, results, $REF, ResponseValidator.instance(), Response.class);
} else {
validateRequired(response.getDescription(), results, true, DESCRIPTION);
validateMap(context, api, response.getHeaders(), results, false, HEADERS, null, HeaderValidator.instance());
validateMap(context, api, response.getContentMediaTypes(), results, false, CONTENT, Regexes.NOEXT_REGEX, MediaTypeValidator.instance());
validateMap(context, api, response.getLinks(), results, false, LINKS, Regexes.NOEXT_NAME_REGEX, LinkValidator.instance());
validateMap(context, api, response.getExtensions(), results, false, EXTENSIONS, Regexes.EXT_REGEX, null);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy