本文整理了Java中io.swagger.v3.oas.models.headers.Header
类的一些代码示例,展示了Header
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header
类的具体详情如下:
包路径:io.swagger.v3.oas.models.headers.Header
类名称:Header
[英]Header
[中]标题
代码示例来源:origin: swagger-api/swagger-core
for (String keyHeaders : response.getHeaders().keySet()) {
Header header = response.getHeaders().get(keyHeaders);
addSchemaRef(header.getSchema(), referencedDefinitions);
addContentSchemaRef(header.getContent(), referencedDefinitions);
代码示例来源:origin: swagger-api/swagger-core
Header headerObject = new Header();
boolean isEmpty = true;
if (StringUtils.isNotBlank(header.description())) {
headerObject.setDescription(header.description());
isEmpty = false;
headerObject.set$ref(header.ref());
isEmpty = false;
headerObject.setDeprecated(header.deprecated());
headerObject.setRequired(header.required());
isEmpty = false;
headerObject.setStyle(Header.StyleEnum.SIMPLE);
AnnotationsUtils.getSchemaFromAnnotation(header.schema(), jsonViewAnnotation).ifPresent(schema -> {
if (StringUtils.isNotBlank(schema.getType())) {
headerObject.setSchema(schema);
代码示例来源:origin: org.openapitools.swagger.parser/swagger-parser-v3
Header header = new Header();
String mungedRef = mungedRef(ref.textValue());
if (mungedRef != null) {
header.set$ref(mungedRef);
}else{
header.set$ref(ref.textValue());
header.setDescription(value);
header.setRequired(required);
header.setDeprecated(deprecated);
header.setExplode(explode);
} else {
header.setExplode(Boolean.FALSE);
header.setStyle(Header.StyleEnum.SIMPLE);
header.setSchema(getSchema(headerObject, location, result));
header.setExamples(getExamples(examplesObject, location, result));
header.setExample(example);
header.setContent(getContent(contentNode,String.format("%s.%s", location, "content"),result));
header.setExtensions(extensions);
代码示例来源:origin: swagger-api/swagger-parser
public void processHeader(Header header) {
if(header.get$ref() != null){
RefFormat refFormat = computeRefFormat(header.get$ref());
String $ref = header.get$ref();
if (isAnExternalRefFormat(refFormat)){
final String newRef = externalRefProcessor.processRefToExternalHeader($ref, refFormat);
if (newRef != null) {
header.set$ref(newRef);
if (header.getSchema() != null) {
schemaProcessor.processSchema(header.getSchema());
if (header.getExamples() != null){
if (header.getExamples() != null) {
Map<String,Example> examples = header.getExamples();
for (String key : examples.keySet()){
exampleProcessor.processExample(header.getExamples().get(key));
if(header.getContent() != null) {
Map<String,MediaType> content = header.getContent();
for( String mediaName : content.keySet()) {
MediaType mediaType = content.get(mediaName);
代码示例来源:origin: quen2404/openapi-diff
@Override
protected Optional<ChangedHeader> computeDiff(
HashSet<String> refSet, Header left, Header right, DiffContext context) {
left = refPointer.resolveRef(leftComponents, left, left.get$ref());
right = refPointer.resolveRef(rightComponents, right, right.get$ref());
.setRequired(getBooleanDiff(left.getRequired(), right.getRequired()))
.setDeprecated(
!Boolean.TRUE.equals(left.getDeprecated())
&& Boolean.TRUE.equals(right.getDeprecated()))
.setStyle(!Objects.equals(left.getStyle(), right.getStyle()))
.setExplode(getBooleanDiff(left.getExplode(), right.getExplode()));
openApiDiff
.getMetadataDiff()
.diff(left.getDescription(), right.getDescription(), context)
.ifPresent(changedHeader::setDescription);
openApiDiff
.getSchemaDiff()
.diff(new HashSet<>(), left.getSchema(), right.getSchema(), context.copyWithRequired(true))
.ifPresent(changedHeader::setSchema);
openApiDiff
.getContentDiff()
.diff(left.getContent(), right.getContent(), context)
.ifPresent(changedHeader::setContent);
openApiDiff
.getExtensionsDiff()
.diff(left.getExtensions(), right.getExtensions(), context)
.ifPresent(changedHeader::setExtensions);
return isChanged(changedHeader);
代码示例来源:origin: swagger-api/swagger-parser
private Header convertHeader(Property property) {
Schema schema = convert(property);
schema.setDescription(null);
Header header = new Header();
header.setDescription(property.getDescription());
header.setSchema(schema);
return header;
}
代码示例来源:origin: org.tomitribe/swagger2markup
descriptionBuilder.newLine(true);
Header headerProperty = header.getValue();
String headerDescription = markupDescription(config.getSwaggerMarkupLanguage(), markupDocBuilder, headerProperty.getDescription());
if (headerProperty.getSchema() != null) {
headerSchema = headerProperty.getSchema();
} else {
headerSchema = new StringSchema();
headerSchema.setName(header.getKey());
headerSchema.setDescription(headerProperty.getDescription());
headerSchema.setRequired(Stream.of(header.getKey()).collect(Collectors.toList()));
headerSchema.setDeprecated(headerProperty.getDeprecated());
代码示例来源:origin: swagger-api/swagger-parser
private void resolveHeaders(Map<String, Header> headers) {
if (headers == null || headers.isEmpty()) {
return;
}
for (Map.Entry<String, Header> header : headers.entrySet()) {
Header value = header.getValue();
Header resolvedValue = value.get$ref() != null ? resolveHeader(value) : value;
Map<String, Example> examples = resolvedValue.getExamples();
if(examples != null) {
Map<String,Example> resolved = resolveExample(examples);
resolvedValue.setExamples(resolved);
}
header.setValue(resolvedValue);
}
}
代码示例来源:origin: swagger-api/swagger-parser
if(existingHeader.get$ref() != null) {
if (header.get$ref() != null) {
RefFormat format = computeRefFormat(header.get$ref());
if (isAnExternalRefFormat(format)) {
header.set$ref(processRefToExternalHeader(header.get$ref(), format));
} else {
processRefToExternalHeader(file + header.get$ref(), RefFormat.RELATIVE);
代码示例来源:origin: org.openapitools/openapi-generator
/**
* Add headers to codegen property
*
* @param response API response
* @param properties list of codegen property
*/
private void addHeaders(OpenAPI openAPI, ApiResponse response, List<CodegenProperty> properties) {
if (response.getHeaders() != null) {
for (Map.Entry<String, Header> headers : response.getHeaders().entrySet()) {
String description = headers.getValue().getDescription();
// follow the $ref
Header header = ModelUtils.getReferencedHeader(openAPI, headers.getValue());
CodegenProperty cp = fromProperty(headers.getKey(), header.getSchema());
cp.setDescription(escapeText(description));
cp.setUnescapedDescription(description);
properties.add(cp);
}
}
}
代码示例来源:origin: io.swagger/swagger-codegen-generators
private void addHeaders(ApiResponse response, List<CodegenProperty> target) {
if (response.getHeaders() != null) {
for (Map.Entry<String, Header> headers : response.getHeaders().entrySet()) {
target.add(fromProperty(headers.getKey(), headers.getValue().getSchema()));
}
}
}
代码示例来源:origin: com.atlassian.oai/swagger-request-validator-core
@Nonnull
private ValidationReport validateHeader(final ApiOperation apiOperation,
final String headerName,
final Header apiHeader,
final Collection<String> propertyValues) {
if (propertyValues.isEmpty() && TRUE.equals(apiHeader.getRequired())) {
return ValidationReport.singleton(
messages.get("validation.response.header.missing", headerName, apiOperation.getApiPath().original())
);
}
return propertyValues
.stream()
.map(v -> schemaValidator.validate(v, apiHeader.getSchema(), "response.header"))
.reduce(ValidationReport.empty(), ValidationReport::merge);
}
}
代码示例来源:origin: ppdai-incubator/raptor
/**
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#headerObject
*
* @return
*/
protected Header getHeader() {
Header header = new Header();
return header;
}
代码示例来源:origin: org.apache.syncope.core/syncope-core-rest-cxf
headers.put(
RESTHeaders.ERROR_CODE,
new Header().schema(new Schema<>().type("string")).description("Error code"));
headers.put(
RESTHeaders.ERROR_INFO,
new Header().schema(new Schema<>().type("string")).description("Error message"));
代码示例来源:origin: quen2404/openapi-diff
public Optional<ChangedHeader> diff(Header left, Header right, DiffContext context) {
return cachedDiff(new HashSet<>(), left, right, left.get$ref(), right.get$ref(), context);
}
代码示例来源:origin: swagger-api/swagger-core
public Header $ref(String $ref) {
set$ref($ref);
return this;
}
代码示例来源:origin: quen2404/openapi-diff
protected String itemHeader(String title, String name, Header header) {
return this.itemHeader(title, name, header.getDescription());
}
代码示例来源:origin: swagger-api/swagger-parser
Header header = new Header();
String mungedRef = mungedRef(ref.textValue());
if (mungedRef != null) {
header.set$ref(mungedRef);
}else{
header.set$ref(ref.textValue());
header.setDescription(value);
header.setRequired(required);
header.setDeprecated(deprecated);
header.setExplode(explode);
} else {
header.setExplode(Boolean.FALSE);
header.setStyle(Header.StyleEnum.SIMPLE);
header.setSchema(getSchema(headerObject, location, result));
header.setExamples(getExamples(examplesObject, location, result));
header.setExample(example);
header.setContent(getContent(contentNode,String.format("%s.%s", location, "content"),result));
header.setExtensions(extensions);
代码示例来源:origin: io.swagger.parser.v3/swagger-parser-v3
public void processHeader(Header header) {
if(header.get$ref() != null){
RefFormat refFormat = computeRefFormat(header.get$ref());
String $ref = header.get$ref();
if (isAnExternalRefFormat(refFormat)){
final String newRef = externalRefProcessor.processRefToExternalHeader($ref, refFormat);
if (newRef != null) {
header.set$ref(newRef);
if (header.getSchema() != null) {
schemaProcessor.processSchema(header.getSchema());
if (header.getExamples() != null){
if (header.getExamples() != null) {
Map<String,Example> examples = header.getExamples();
for (String key : examples.keySet()){
exampleProcessor.processExample(header.getExamples().get(key));
if(header.getContent() != null) {
Map<String,MediaType> content = header.getContent();
for( String mediaName : content.keySet()) {
MediaType mediaType = content.get(mediaName);
代码示例来源:origin: org.openapitools.swagger.parser/swagger-parser-v2-converter
private Header convertHeader(Property property) {
Schema schema = convert(property);
schema.setDescription(null);
Header header = new Header();
header.setDescription(property.getDescription());
header.setSchema(schema);
return header;
}
内容来源于网络,如有侵权,请联系作者删除!