當前位置: 首頁>>代碼示例>>Java>>正文


Java Model類代碼示例

本文整理匯總了Java中com.amazonaws.services.apigateway.model.Model的典型用法代碼示例。如果您正苦於以下問題:Java Model類的具體用法?Java Model怎麽用?Java Model使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Model類屬於com.amazonaws.services.apigateway.model包,在下文中一共展示了Model類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getResponseSchema

import com.amazonaws.services.apigateway.model.Model; //導入依賴的package包/類
private static Property getResponseSchema(String responseModelName, boolean inlineResponseSchema,
		Swagger swagger, Map<String, Integer> modelRefCount) {
	Property schema = new RefProperty(responseModelName);
	if (inlineResponseSchema && !modelRefCount.containsKey(responseModelName)) {
		io.swagger.models.Model model = swagger.getDefinitions().get(responseModelName);
		//If empty model was generated for response type
		if (model instanceof ModelImpl) {
			Map<String, Property> modelProperties = ((ModelImpl) model).getProperties();
			if (modelProperties == null || modelProperties.isEmpty()) {
				String type = ((ModelImpl) model).getType();
				if (type != null) {
					Property property = PropertyBuilder.build(type, ((ModelImpl) model).getFormat(), null);
					if (property != null) {
						schema = property;
						swagger.getDefinitions().remove(responseModelName);
					}
				}
			}
		}
	}
	return schema;
}
 
開發者ID:isabinin,項目名稱:aws-apigateway-swagger-exporter,代碼行數:23,代碼來源:APIGExporter.java

示例2: getDefinitions

import com.amazonaws.services.apigateway.model.Model; //導入依賴的package包/類
private static Map<String, io.swagger.models.Model> getDefinitions(RestApi restApi)
		throws IOException, JsonParseException, JsonMappingException {
	Map<String, io.swagger.models.Model> result = new HashMap<String, io.swagger.models.Model>();
	for (Models models = restApi.getModels(); models != null; models = safeGetNext(models)) {
		for (Model modelItem : models.getItem()) {
			String content = modelItem.getSchema(); 
			io.swagger.models.Model model = 
					Json.mapper().readValue(content, io.swagger.models.Model.class);
			if (model instanceof ModelImpl) {
				((ModelImpl) model).setName(modelItem.getName());
			}
			model.setDescription(modelItem.getDescription());
			result.put(modelItem.getName(), model);
		}
	}
	return result;
}
 
開發者ID:isabinin,項目名稱:aws-apigateway-swagger-exporter,代碼行數:18,代碼來源:APIGExporter.java

示例3: processModelRefs

import com.amazonaws.services.apigateway.model.Model; //導入依賴的package包/類
private static void processModelRefs(io.swagger.models.Model model, Map<String, Integer> modelRefCount) {
	if (model instanceof RefModel) {
		String ref = ((RefModel) model).getSimpleRef();
		Integer count = modelRefCount.get(ref);
		modelRefCount.put(ref, count != null ? (count + 1) : 1);
	} else if (model instanceof ModelImpl) {
		processPropertyModelRefs(((ModelImpl) model).getProperties(), modelRefCount);
		processPropertyModelRefs(((ModelImpl) model).getAdditionalProperties(), modelRefCount);
	} else if (model instanceof ArrayModel) {
		processPropertyModelRefs(((ArrayModel) model).getProperties(), modelRefCount);
		processPropertyModelRefs(((ArrayModel) model).getItems(), modelRefCount);
	} else if (model instanceof ComposedModel) {
		processPropertyModelRefs(((ComposedModel) model).getProperties(), modelRefCount);
		processModelRefs(((ComposedModel) model).getChild(), modelRefCount);
		processModelRefs(((ComposedModel) model).getParent(), modelRefCount);
		processModelRefs(((ComposedModel) model).getAllOf(), modelRefCount);
		processModelRefs(((ComposedModel) model).getInterfaces(), modelRefCount);
	}
	
}
 
開發者ID:isabinin,項目名稱:aws-apigateway-swagger-exporter,代碼行數:21,代碼來源:APIGExporter.java

示例4: buildModelList

import com.amazonaws.services.apigateway.model.Model; //導入依賴的package包/類
protected List<Model> buildModelList(RestApi api) {
    List<Model> modelList = new ArrayList<>();

    Models models = api.getModels();
    modelList.addAll(models.getItem());

    while (models._isLinkAvailable("next")) {
        models = models.getNext();
        modelList.addAll(models.getItem());
    }

    return modelList;
}
 
開發者ID:awslabs,項目名稱:aws-apigateway-importer,代碼行數:14,代碼來源:ApiGatewaySdkApiImporter.java

示例5: cleanupModels

import com.amazonaws.services.apigateway.model.Model; //導入依賴的package包/類
protected void cleanupModels(RestApi api, Set<String> models) {
    List<Model> existingModels = buildModelList(api);
    Stream<Model> modelsToDelete = existingModels.stream().filter(model -> !models.contains(model.getName()));

    modelsToDelete.forEach(model -> {
        LOG.info("Removing deleted model " + model.getName());
        model.deleteModel();
    });
}
 
開發者ID:awslabs,項目名稱:aws-apigateway-importer,代碼行數:10,代碼來源:ApiGatewaySdkApiImporter.java

示例6: getModel

import com.amazonaws.services.apigateway.model.Model; //導入依賴的package包/類
protected Optional<Model> getModel(RestApi api, String modelName) {
    try {
        return Optional.of(api.getModelByName(modelName));
    } catch (Exception ignored) {
        return Optional.empty();
    }
}
 
開發者ID:awslabs,項目名稱:aws-apigateway-importer,代碼行數:8,代碼來源:ApiGatewaySdkApiImporter.java

示例7: setUp

import com.amazonaws.services.apigateway.model.Model; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    BasicConfigurator.configure();

    Injector injector = Guice.createInjector(new SwaggerApiImporterTestModule());

    client = injector.getInstance(ApiGateway.class);
    importer = injector.getInstance(SwaggerApiFileImporter.class);

    RestApis mockRestApis = mock(RestApis.class);
    Integration mockIntegration = Mockito.mock(Integration.class);

    Method mockMethod = Mockito.mock(Method.class);
    when(mockMethod.getHttpMethod()).thenReturn("GET");
    when(mockMethod.putIntegration(any())).thenReturn(mockIntegration);

    mockChildResource = Mockito.mock(Resource.class);
    when(mockChildResource.getPath()).thenReturn("/child");
    when(mockChildResource.putMethod(any(), any())).thenReturn(mockMethod);

    mockResource = Mockito.mock(Resource.class);
    when(mockResource.getPath()).thenReturn("/");
    when(mockResource.createResource(any())).thenReturn(mockChildResource);
    when(mockResource.putMethod(any(), any())).thenReturn(mockMethod);

    Resources mockResources = mock(Resources.class);
    when(mockResources.getItem()).thenReturn(Arrays.asList(mockResource));

    Model mockModel = Mockito.mock(Model.class);
    when(mockModel.getName()).thenReturn("test model");

    Models mockModels = mock(Models.class);
    when(mockModels.getItem()).thenReturn(Arrays.asList(mockModel));

    mockRestApi = mock(RestApi.class);
    when(mockRestApi.getResources()).thenReturn(mockResources);
    when(mockRestApi.getModels()).thenReturn(mockModels);
    when(mockRestApi.getResourceById(any())).thenReturn(mockResource);

    when(client.getRestApis()).thenReturn(mockRestApis);
    when(client.createRestApi(any())).thenReturn(mockRestApi);

    importer.importApi(getResourcePath(API_GATEWAY));
}
 
開發者ID:awslabs,項目名稱:aws-apigateway-importer,代碼行數:45,代碼來源:ApiGatewaySwaggerFileImporterTest.java


注:本文中的com.amazonaws.services.apigateway.model.Model類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。