
jmms.testing.generators.SwaggerOp Maven / Gradle / Ivy
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jmms.testing.generators;
import jmms.core.model.MetaEntity;
import jmms.core.modules.EntityModule;
import leap.lang.Strings;
import leap.lang.json.JsonObject;
import leap.web.api.meta.model.MApiModel;
import leap.web.api.meta.model.MApiOperation;
import leap.web.api.meta.model.MApiResponse;
final class SwaggerOp {
final String pathTemplate;
final String method;
final MApiOperation metaOperation;
final JsonObject jsonOperation;
final MApiResponse successResponse;
String crud;
EntityModule entityModule;
MApiModel metaModel;
JsonObject jsonModel;
public SwaggerOp(String pathTemplate, MApiOperation metaOperation, JsonObject jsonOperation) {
this.pathTemplate = pathTemplate;
this.method = metaOperation.getMethod().name();
this.metaOperation = metaOperation;
this.jsonOperation = jsonOperation;
MApiResponse sr = null;
for (MApiResponse r : metaOperation.getResponses()) {
if (null != r.getStatus() && r.getStatus() >= 200 && r.getStatus() < 300) {
sr = r;
}
}
successResponse = sr;
}
public String getPathTemplate() {
return pathTemplate;
}
public String getMethod() {
return method;
}
public MApiOperation getMetaOperation() {
return metaOperation;
}
public JsonObject getJsonOperation() {
return jsonOperation;
}
public MApiResponse getSuccessResponse() {
return successResponse;
}
public boolean isCrud() {
return !Strings.isEmpty(crud);
}
public String getCrud() {
return crud;
}
public EntityModule getEntityModule() {
return entityModule;
}
public MetaEntity getMetaEntity() {
return null == entityModule ? null : entityModule.getMeta();
}
public MApiModel getMetaModel() {
return metaModel;
}
public JsonObject getJsonModel() {
return jsonModel;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy