本文整理了Java中io.swagger.models.Swagger.getProduces()
方法的一些代码示例,展示了Swagger.getProduces()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.getProduces()
方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:getProduces
暂无
代码示例来源:origin: apache/servicecomb-java-chassis
private void correctProduces() {
List<String> produces = swagger.getProduces();
if (produces == null || produces.isEmpty()) {
produces = Arrays.asList(MediaType.APPLICATION_JSON);
swagger.setProduces(produces);
}
}
代码示例来源:origin: Swagger2Markup/swagger2markup
/**
* Builds the overview MarkupDocument.
*
* @return the overview MarkupDocument
*/
@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, OverviewDocument.Parameters params) {
Swagger swagger = params.swagger;
Info info = swagger.getInfo();
buildDocumentTitle(markupDocBuilder, info.getTitle());
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_BEFORE, markupDocBuilder));
buildOverviewTitle(markupDocBuilder, labels.getLabel(Labels.OVERVIEW));
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_BEGIN, markupDocBuilder));
buildDescriptionParagraph(markupDocBuilder, info.getDescription());
buildVersionInfoSection(markupDocBuilder, info);
buildContactInfoSection(markupDocBuilder, info.getContact());
buildLicenseInfoSection(markupDocBuilder, info);
buildUriSchemeSection(markupDocBuilder, swagger);
buildTagsSection(markupDocBuilder, swagger.getTags());
buildConsumesSection(markupDocBuilder, swagger.getConsumes());
buildProducesSection(markupDocBuilder, swagger.getProduces());
buildExternalDocsSection(markupDocBuilder, swagger.getExternalDocs());
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_END, markupDocBuilder));
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_AFTER, markupDocBuilder));
return markupDocBuilder;
}
代码示例来源:origin: apache/servicecomb-java-chassis
private void processProduces(Api api, Swagger swagger) {
List<String> validProducesList = getValidStringList(api.produces());
if (isBlank(swagger.getProduces()) && !validProducesList.isEmpty()) {
swagger.setProduces(validProducesList);
}
}
代码示例来源:origin: apache/servicecomb-java-chassis
@Override
public Property process(OperationGenerator operationGenerator) {
// Response完全表达应答类型
// 如果produces是text,那么可以假设是string,否则只能报错
List<String> produces = operationGenerator.getOperation().getProduces();
if (produces == null) {
produces = operationGenerator.getSwagger().getProduces();
}
if (produces != null) {
if (produces.contains(MediaType.TEXT_PLAIN)) {
Type responseType = String.class;
ParamUtils.addDefinitions(operationGenerator.getSwagger(), responseType);
return ModelConverters.getInstance().readAsProperty(responseType);
}
}
throw new Error("Use ApiOperation or ApiResponses to declare response type");
}
}
代码示例来源:origin: apache/servicecomb-java-chassis
public void init(OperationMeta operationMeta) {
this.operationMeta = operationMeta;
Swagger swagger = operationMeta.getSchemaMeta().getSwagger();
Operation operation = operationMeta.getSwaggerOperation();
this.produces = operation.getProduces();
if (produces == null) {
this.produces = swagger.getProduces();
}
this.downloadFile = checkDownloadFileFlag();
this.createProduceProcessors();
Method method = operationMeta.getMethod();
Type[] genericParamTypes = method.getGenericParameterTypes();
if (genericParamTypes.length != operation.getParameters().size()) {
throw new Error("Param count is not equal between swagger and method, path=" + absolutePath
+ ";operation=" + operationMeta.getMicroserviceQualifiedName());
}
// 初始化所有rest param
for (int idx = 0; idx < genericParamTypes.length; idx++) {
Parameter parameter = operation.getParameters().get(idx);
Type genericParamType = genericParamTypes[idx];
if ("formData".equals(parameter.getIn())) {
formData = true;
}
RestParam param = new RestParam(idx, parameter, genericParamType);
addParam(param);
}
setAbsolutePath(concatPath(swagger.getBasePath(), operationMeta.getOperationPath()));
}
代码示例来源:origin: org.apache.servicecomb/swagger-generator-core
private void correctProduces() {
List<String> produces = swagger.getProduces();
if (produces == null || produces.isEmpty()) {
produces = Arrays.asList(MediaType.APPLICATION_JSON);
swagger.setProduces(produces);
}
}
代码示例来源:origin: RobWin/assertj-swagger
List<String> getActualProduces(Operation op) {
return getListWithFallback(op.getProduces(), actual.getProduces());
}
代码示例来源:origin: AresS31/swurg
private List<String> buildHeaders(
Swagger swagger, Map.Entry<String, Path> path, Map.Entry<HttpMethod, Operation> operation
) {
List<String> headers = new ArrayList<>();
headers.add(
operation.getKey().toString() + " " + swagger.getBasePath() + path.getKey() + " HTTP/1.1");
headers.add("Host: " + swagger.getHost().split(":")[0]);
if (CollectionUtils.isNotEmpty(operation.getValue().getProduces())) {
headers.add("Accept: " + String.join(",", operation.getValue().getProduces()));
} else if (CollectionUtils.isNotEmpty(swagger.getProduces())) {
headers.add("Accept: " + String.join(",", swagger.getProduces()));
}
if (CollectionUtils.isNotEmpty(operation.getValue().getConsumes())) {
headers.add("Content-Type: " + String.join(",", operation.getValue().getConsumes()));
} else if (CollectionUtils.isNotEmpty(swagger.getConsumes())) {
headers.add("Content-Type: " + String.join(",", swagger.getConsumes()));
}
return headers;
}
代码示例来源:origin: RobWin/assertj-swagger
List<String> getExpectedProduces(Operation op) {
return getListWithFallback(op.getProduces(), expected.getProduces());
}
代码示例来源:origin: org.apache.servicecomb/swagger-generator-core
private void processProduces(Api api, Swagger swagger) {
List<String> validProducesList = getValidStringList(api.produces());
if (isBlank(swagger.getProduces()) && !validProducesList.isEmpty()) {
swagger.setProduces(validProducesList);
}
}
代码示例来源:origin: io.syndesis.server/server-connector-generator
@Override
public DataShape createShapeFromResponse(final ObjectNode json, final Swagger swagger, final Operation operation) {
if (supports(APPLICATION_JSON, swagger.getProduces(), operation.getProduces())) {
return JSON.createShapeFromResponse(json, swagger, operation);
} else if (supports(APPLICATION_XML, swagger.getProduces(), operation.getProduces())) {
return XML.createShapeFromResponse(json, swagger, operation);
} else {
// most likely a body-less request, i.e. only with parameters, we'll
// use JSON to define those parameters
return JSON.createShapeFromResponse(json, swagger, operation);
}
}
代码示例来源:origin: io.syndesis.server/server-api-generator
@Override
public DataShape createShapeFromResponse(final ObjectNode json, final Swagger swagger, final Operation operation) {
if (supports(APPLICATION_JSON, swagger.getProduces(), operation.getProduces())) {
return JSON.createShapeFromResponse(json, swagger, operation);
} else if (supports(APPLICATION_XML, swagger.getProduces(), operation.getProduces())) {
return XML.createShapeFromResponse(json, swagger, operation);
} else {
// most likely a body-less request, i.e. only with parameters, we'll
// use JSON to define those parameters
return JSON.createShapeFromResponse(json, swagger, operation);
}
}
代码示例来源:origin: io.syndesis.rest/rest-connector-generator
@Override
public DataShape createShapeFromResponse(final String specification, final Swagger swagger, final Operation operation) {
if (supports(APPLICATION_JSON, swagger.getProduces(), operation.getProduces())) {
return JSON.createShapeFromResponse(specification, swagger, operation);
} else if (supports(APPLICATION_XML, swagger.getProduces(), operation.getProduces())) {
return XML.createShapeFromResponse(specification, swagger, operation);
} else {
// most likely a body-less request, i.e. only with parameters, we'll
// use JSON to define those parameters
return JSON.createShapeFromResponse(specification, swagger, operation);
}
}
代码示例来源:origin: amazon-archives/aws-apigateway-importer
@Override
public void updateApi(String apiId, Swagger swagger) {
this.swagger = swagger;
this.processedModels.clear();
RestApi api = getApi(apiId);
Optional<Resource> rootResource = getRootResource(api);
updateModels(api, swagger.getDefinitions(), swagger.getProduces());
updateResources(api, rootResource.get(), swagger.getBasePath(), swagger.getPaths(), swagger.getProduces());
updateMethods(api, swagger.getBasePath(), swagger.getPaths(), swagger.getProduces());
cleanupMethods(api, swagger.getBasePath(), swagger.getPaths());
cleanupResources(api, swagger.getBasePath(), swagger.getPaths());
cleanupModels(api, this.processedModels);
}
代码示例来源:origin: amazon-archives/aws-apigateway-importer
@Override
public String createApi(Swagger swagger, String name) {
this.swagger = swagger;
this.processedModels.clear();
final RestApi api = createApi(getApiName(swagger, name), swagger.getInfo().getDescription());
LOG.info("Created API "+api.getId());
try {
final Resource rootResource = getRootResource(api).get();
deleteDefaultModels(api);
createModels(api, swagger.getDefinitions(), swagger.getProduces());
createResources(api, rootResource, swagger.getBasePath(), swagger.getProduces(), swagger.getPaths(), true);
} catch (Throwable t) {
LOG.error("Error creating API, rolling back", t);
rollback(api);
throw t;
}
return api.getId();
}
代码示例来源:origin: com.reprezen.genflow/genflow-api
@Override
public void operation(HttpMethod httpMethod, Operation operation) {
if (operation.getConsumes() == null) {
operation.setConsumes(model.getConsumes());
}
if (operation.getProduces() == null) {
operation.setProduces(model.getProduces());
}
}
});
代码示例来源:origin: org.apache.servicecomb/swagger-generator-jaxrs
@Override
public Property process(OperationGenerator operationGenerator) {
// Response完全表达应答类型
// 如果produces是text,那么可以假设是string,否则只能报错
List<String> produces = operationGenerator.getOperation().getProduces();
if (produces == null) {
produces = operationGenerator.getSwagger().getProduces();
}
if (produces != null) {
if (produces.contains(MediaType.TEXT_PLAIN)) {
Type responseType = String.class;
ParamUtils.addDefinitions(operationGenerator.getSwagger(), responseType);
return ModelConverters.getInstance().readAsProperty(responseType);
}
}
throw new Error("Use ApiOperation or ApiResponses to declare response type");
}
}
代码示例来源:origin: io.servicecomb/common-rest
public void init(OperationMeta operationMeta) {
this.operationMeta = operationMeta;
Swagger swagger = operationMeta.getSchemaMeta().getSwagger();
Operation operation = operationMeta.getSwaggerOperation();
this.produces = operation.getProduces();
if (produces == null) {
this.produces = swagger.getProduces();
}
this.createProduceProcessors();
Method method = operationMeta.getMethod();
Type[] genericParamTypes = method.getGenericParameterTypes();
if (genericParamTypes.length != operation.getParameters().size()) {
throw new Error("Param count is not equal between swagger and method, path=" + absolutePath);
}
// 初始化所有rest param
for (int idx = 0; idx < genericParamTypes.length; idx++) {
Parameter parameter = operation.getParameters().get(idx);
Type genericParamType = genericParamTypes[idx];
if ("formData".equals(parameter.getIn())) {
formData = true;
}
RestParam param = new RestParam(idx, parameter, genericParamType);
addParam(param);
}
setAbsolutePath(concatPath(swagger.getBasePath(), operationMeta.getOperationPath()));
}
代码示例来源:origin: com.github.phillip-kruger/apiee-core
private Swagger createSwagger(final Set<Class<?>> classes,final URL url){
Swagger swagger = new Reader(new Swagger()).read(classes);
Info info = getSwaggerInfo(swagger);
if(info!=null)swagger.setInfo(info);
Map<String, SecuritySchemeDefinition> securityDefinitions = getSecurityDefinitions(swagger);
if(securityDefinitions!=null)swagger.setSecurityDefinitions(securityDefinitions);
String consumes = whiteLabel.getProperty(CONSUMES, null);
if(anyIsSet(consumes))swagger.setConsumes(toList(swagger.getConsumes(),consumes));
String produces = whiteLabel.getProperty(PRODUCES, null);
if(anyIsSet(produces))swagger.setProduces(toList(swagger.getProduces(),produces));
String basePath = whiteLabel.getProperty(BASE_PATH, getBasePath(swagger.getBasePath(), url));
if(anyIsSet(basePath))swagger.setBasePath(basePath);
String schemes = whiteLabel.getProperty(SCHEMES, url.getProtocol().toUpperCase());
if(anyIsSet(schemes))swagger.setSchemes(toSchemeList(swagger.getSchemes(),schemes));
String host = whiteLabel.getProperty(HOST, url.getHost() + DOUBLE_POINT + url.getPort());
if(anyIsSet(host))swagger.setHost(host);
String tags = whiteLabel.getProperty(TAGS, null);
if(anyIsSet(tags))swagger.setTags(toTagList(swagger.getTags(),tags));
return swagger;
}
代码示例来源:origin: com.reprezen.genflow/genflow-api
@Override
public void swagger(Swagger swagger) {
swagger.setSchemes(fillList(swagger.getSchemes()));
swagger.setConsumes(fillList(swagger.getConsumes()));
swagger.setProduces(fillList(swagger.getProduces()));
swagger.setPaths(fillMap(swagger.getPaths()));
swagger.setDefinitions(fillMap(swagger.getDefinitions()));
swagger.setParameters(fillMap(swagger.getParameters()));
swagger.setResponses(fillMap(swagger.getResponses()));
swagger.setSecurityDefinitions(fillMap(swagger.getSecurityDefinitions()));
swagger.setSecurity(fillList(swagger.getSecurity()));
swagger.setTags(fillList(swagger.getTags()));
}
内容来源于网络,如有侵权,请联系作者删除!