
com.mangofactory.swagger.models.dto.Operation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swagger-models Show documentation
Show all versions of swagger-models Show documentation
This project integrates swagger with the Spring Web MVC framework
The newest version!
package com.mangofactory.swagger.models.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.google.common.base.Function;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Lists.*;
import static com.google.common.collect.Maps.*;
@JsonPropertyOrder({
"method", "summary", "notes", "type", "nickname", "produces",
"consumes", "parameters", "responseMessages", "deprecated"
})
public class Operation {
private final String method;
private final String summary;
private final String notes;
@JsonIgnore
private final String responseClass;
@JsonProperty
@JsonUnwrapped
private final SwaggerDataType dataType;
private final String nickname;
@JsonIgnore
private final int position;
private final List produces;
private final List consumes;
@JsonIgnore
private final List protocol;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private final Map> authorizations;
private final List parameters;
private final Set responseMessages;
private final String deprecated;
public Operation(String method, String summary, String notes, String responseClass, String nickname, int position,
List produces, List consumes, List protocol,
List
authorizations, List parameters, Set responseMessages, String
deprecated) {
this.method = method;
this.summary = summary;
this.notes = notes;
this.responseClass = responseClass;
this.dataType = new DataType(responseClass);
this.nickname = nickname;
this.position = position;
this.produces = produces;
this.consumes = consumes;
this.protocol = protocol;
this.authorizations = toAuthorizationsMap(authorizations);
this.parameters = parameters;
this.responseMessages = responseMessages;
this.deprecated = deprecated;
}
private Map> toAuthorizationsMap(List authorizations) {
return transformEntries(uniqueIndex(authorizations, byType()), toScopes());
}
private EntryTransformer super String, ? super Authorization, List> toScopes() {
return new EntryTransformer>() {
@Override
public List transformEntry(String key, Authorization value) {
return newArrayList(value.getScopes());
}
};
}
private Function super Authorization, String> byType() {
return new Function() {
@Override
public String apply(Authorization input) {
return input.getType();
}
};
}
public String getMethod() {
return method;
}
public String getSummary() {
return summary;
}
public String getNotes() {
return notes;
}
public String getResponseClass() {
return responseClass;
}
public String getNickname() {
return nickname;
}
public int getPosition() {
return position;
}
public List getProduces() {
return produces;
}
public List getConsumes() {
return consumes;
}
public List getProtocol() {
return protocol;
}
public Map> getAuthorizations() {
return authorizations;
}
public List getParameters() {
return parameters;
}
public Set getResponseMessages() {
return responseMessages;
}
public String getDeprecated() {
return deprecated;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy