Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
jeaf.OpenAPIChecks.chk Maven / Gradle / Ivy
import uml;
import JMM;
extension java::Naming;
extension java::GeneratorCommons;
extension java::OpenAPIFunctions;
extension jeaf::RESTFunctions;
extension functions::ClassifierTemplateParameter;
// Checks for stereotype RESTResource
context RESTResource if runChecks("RESTResource") && ignore() == false ERROR this.getErrorMessage("9104", {name}): this.hasValidRESTResourcePath() == true;
context RESTResource if runChecks("RESTResource") && ignore() == false ERROR this.getErrorMessage("9130", {"RESTResource", name}): ownedOperation.forAll( e | e.hasOnlySupportedParamaterTypes());
// Checks for stereotype RESTOperation
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9105", {((NamedElement)owner).name + "." + name}): this.hasValidRESTResourcePath() == true;
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9106", {((NamedElement)owner).name + "." + name}): this.hasValidOperationPath() == true;
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9107", {((NamedElement)owner).name + "." + name}): httpMethods.size > 0;
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9108", {this.getStatusCodeName()}): isJAXRSStatusCode(this.getStatusCodeName()) == true;
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9109", {((NamedElement)owner).name + "." + name}): unifyMediaTypes(((JMM::RESTResource)this.owner).consumes, this.consumes).size > 0;
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9110", {((NamedElement)owner).name + "." + name}): unifyMediaTypes(((JMM::RESTResource)this.owner).produces, this.produces).size > 0;
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9111", {((NamedElement)owner).name + "." + name}): this.areAllInputParametersNamed() == true;
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9112", {((NamedElement)owner).name + "." + name, this.getBodyParamNames().toString()}): this.getBodyParamNames().size < 2 ;
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9113", {((NamedElement)owner).name + "." + name, httpMethods.toString()}): this.hasUnsupportedRequestBody() == false ;
context RESTOperation if runChecks("RESTOperation") && ignore() == false ERROR this.getErrorMessage("9165", {this.detectMissingRESTPathParams().toString(", "), this.path, ((NamedElement)owner).name + "." + name}): this.detectMissingRESTPathParams().isEmpty == true ;
context RESTOperation if runChecks("RESTOperation") && ignore() == false WARNING this.getWarningMessage("9101", {((NamedElement)owner).name + "." + name, this.getOpenAPIIncomaptibleParameterTypes().asParamErrorMessage().toString()}): this.getOpenAPIIncomaptibleParameterTypes().size == 0;
context RESTOperation if runChecks("RESTOperation") && ignore() == false WARNING this.getWarningMessage("9166", {((NamedElement)owner).name + "." + name, this.path, this.detectDeadRESTPathParams().toString(", ")}): this.detectDeadRESTPathParams().isEmpty == true ;
// Global checks for OpenAPI3Specification
context Model if runChecks() ERROR this.getErrorMessage("9114", {}): this.hasValidOneGlobalDefaultErrorResponse() == false;
// Check is no longer correct
//context OpenAPI3Specification if runChecks("OpenAPI3Specification") ERROR "Error: <> " + this.name + " has " + this.getCustomResponses().size + " error responses.": this.getCustomResponses().size < 2;
// Checks for stereotype OpenAPIResponse
context OpenAPIResponse if runChecks("OpenAPIResponse") && ignore() == false ERROR this.getErrorMessage("9115", {name}): this.getResponseTypes().size == 1;
// Checks for stereotype OpenAPIType
context OpenAPIType if runChecks("OpenAPIType") && ignore() == false ERROR this.getErrorMessage("9124", {"OpenAPIType", name}): ownedAttribute.select(e|e.isPropertySuppressed() == false).forAll( a | a.type != null);
context OpenAPIType if runChecks("OpenAPIType") && ignore() == false ERROR this.getErrorMessage("9125", {"OpenAPIType", name}): ownedAttribute.select(e|e.isPropertySuppressed() == false).forAll( a | a.name.length > 0);
context OpenAPIType if runChecks("OpenAPIType") && ignore() == false WARNING this.getWarningMessage("9122", {"OpenAPIType", name}): ownedComment.size > 0;
// Checks for stereotype OpenAPIDataType
context OpenAPIDataType if runChecks("OpenDataAPIType") && ignore() == false ERROR this.getErrorMessage("9124", {"OpenAPIDataType", name}): ownedAttribute.select(e|e.isPropertySuppressed() == false).forAll( a | a.type != null);
context OpenAPIDataType if runChecks("OpenAPIDataType") && ignore() == false && this.compositeDataType == false ERROR this.getErrorMessage("9116", {name}): this.ownedAttribute.select(e|e.isStatic == false).size == 1;
context OpenAPIDataType if runChecks("OpenAPIDataType") && ignore() == false && this.compositeDataType == false ERROR this.getErrorMessage("9117", {name}): this.ownedAttribute.get(0).type.isBasicOpenAPIType() == true;
context OpenAPIDataType if runChecks("OpenAPIDataType") && ignore() == false && this.compositeDataType == false ERROR this.getErrorMessage("9118", {name}): this.ownedAttribute.get(0).isMultivalued() == false;
context OpenAPIDataType if runChecks("OpenAPIDataType") && ignore() == false ERROR this.getErrorMessage("9119", {name}): this.superClass.size == 0;
context OpenAPIDataType if runChecks("OpenAPIDataType") && ignore() == false WARNING this.getWarningMessage("9122", {"OpenAPIDataType", name}): ownedComment.size > 0;
context OpenAPIDataType if runChecks("OpenAPIDataType") && ignore() == false WARNING this.getWarningMessage("9159", {name}): attribute.select(e|e.isReadOnly()) == 0;
// Checks for stereotype PathParam
context PathParam if runChecks("PathParam") && ignore() == false ERROR this.getErrorMessage("9120", {this.fqn()}): this.lower == 1;
context PathParam if runChecks("PathParam") && ignore() == false ERROR this.getErrorMessage("9120", {this.fqn()}): this.isMultivalued() == false;
// Checks for stereotype HeaderParam
context HeaderParam if runChecks("HeaderParam") && ignore() == false WARNING this.getWarningMessage("9153", {((NamedElement)owner).fqn(), this.getRESTHeaderParamName(), name}): this.isIgnoredHeaderParam() == false;
context HeaderParam if runChecks("HeaderParam") && ignore() == false ERROR this.getErrorMessage("9155", {((NamedElement)owner).fqn(), this.getRESTHeaderParamName(), name}): !(isRESTLibraryJAXRS() && generateRESTResources() && this.isMultivalued() && this.getCollectionType() == "java.util.Collection");
// Checks for stereotype QueryParam
context QueryParam if runChecks("QueryParam") && ignore() == false ERROR this.getErrorMessage("9156", {((NamedElement)owner).fqn(), this.getRESTQueryParamName(), name}): !(isRESTLibraryJAXRS() && generateRESTResources() && this.isMultivalued() && this.getCollectionType() == "java.util.Collection");
// Checks for stereotype BeanParam
context BeanParam if runChecks("RESTOperation") && ignore() == false WARNING this.getWarningMessage("9103", {this.fqn(), this.getOpenAPIIncompatibleBeanProperties().asPropertyErrorMessage().toString()}): this.getOpenAPIIncompatibleBeanProperties().size == 0;
// Checks for deprecations that are not supported by OpenAPI
context Property if ((NamedElement)owner).runChecks("OpenAPIType") && ignore() == false WARNING this.getWarningMessage("9154", {((NamedElement)owner).name + "." + name}): !(this.isMultivalued() == false && this.type.isClassifierTemplateParameter()== true && this.type.isBasicOpenAPIType() == false && this.isDeprecated() && owner.isStereotypeApplied("OpenAPIType"));