Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions swagger/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Swagger Plugin
==============

Based on [OpenAPI Specification 3.0.0](https://swagger.io/specification/#oasDocument)
Based on [OpenAPI Specification 3.0.1](https://swagger.io/specification/#oasDocument)

fixed files for swagger-annotations are in io.swagger.oas.annotations (Hidden + Operation)

How to use in RestExpress

Expand Down Expand Up @@ -86,7 +85,7 @@ private static void configurePlugins(Configuration config, RestExpress server) {
```
@Operation(
tags = {"HR :: Employees"},
summary = "Search employee by firstname || lastname",
summary = "Search employee by firstname || lastname",
description = "",
security = @SecurityRequirement(name = "Authorization"),
parameters = {
Expand Down
7 changes: 4 additions & 3 deletions swagger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
</parent>

<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.0.0-rc2</version>
<version>2.0.7</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public void process(RouteBuilder routeBuilder) {
Operation operation;
Method m = route.getAction();

if (m.isAnnotationPresent(io.swagger.oas.annotations.Operation.class)) {
operation = new Operation(m.getAnnotation(io.swagger.oas.annotations.Operation.class));
if (m.isAnnotationPresent(io.swagger.v3.oas.annotations.Operation.class)) {
operation = new Operation(m.getAnnotation(io.swagger.v3.oas.annotations.Operation.class));
} else {
operation = new Operation();
}
Expand All @@ -166,8 +166,8 @@ public void process(RouteBuilder routeBuilder) {

private boolean isRouteHidden(Route route) {
Method method = route.getAction();
if (method.isAnnotationPresent(io.swagger.oas.annotations.Operation.class)) {
return (method.isAnnotationPresent(io.swagger.oas.annotations.Hidden.class));
if (method.isAnnotationPresent(io.swagger.v3.oas.annotations.Operation.class)) {
return (method.isAnnotationPresent(io.swagger.v3.oas.annotations.Hidden.class));
}

return shouldShowAnnotatedOnly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class Encoding {
private Boolean explode;
private Boolean allowReserved;

public Encoding(io.swagger.oas.annotations.media.Encoding e) {
public Encoding(io.swagger.v3.oas.annotations.media.Encoding e) {
setContentType(OpenApi.nullIfEmpty(e.contentType()));
for(io.swagger.oas.annotations.headers.Header h : e.headers()) {
for(io.swagger.v3.oas.annotations.headers.Header h : e.headers()) {
getHeaders().put(e.name(), new Header(h));
}
setStyle(OpenApi.nullIfEmpty(e.style()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public Example(String ref) {
super(ref);
}

public Example(io.swagger.oas.annotations.media.ExampleObject e) {
public Example(io.swagger.v3.oas.annotations.media.ExampleObject e) {
setSummary(OpenApi.nullIfEmpty(e.summary()));
//TODO: description in annotation missing setDescription(OpenApi.nullIfEmpty(e.description()));
setValue(OpenApi.nullIfEmpty(e.value()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ExternalDocumentation(String url) {
setUrl(url);
}

public ExternalDocumentation(io.swagger.oas.annotations.ExternalDocumentation externalDocs) {
public ExternalDocumentation(io.swagger.v3.oas.annotations.ExternalDocumentation externalDocs) {
setDescription(OpenApi.nullIfEmpty(externalDocs.description()));
setUrl(OpenApi.nullIfEmpty(externalDocs.url()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class Header extends Reference{
private String description;
private Boolean required;
private Boolean deprecated;
private Boolean allowEmptyValue;

private Schema schema;
private String example;
Expand All @@ -17,18 +16,16 @@ public Header(String ref) {
super(ref);
}

public Header(io.swagger.oas.annotations.headers.Header h) {
public Header(io.swagger.v3.oas.annotations.headers.Header h) {
setName(OpenApi.nullIfEmpty(h.name()));
setDescription(OpenApi.nullIfEmpty(h.description()));
setRequired(h.required());
setDeprecated(h.deprecated());
setAllowEmptyValue(h.allowEmptyValue());

setSchema(new Schema(h.schema()));
if(!getSchema().isValid()){
setSchema(null);
}
//TODO annotation.example is missing setExample(OpenApi.nullIfEmpty(p.example()));
}

public String getName() {
Expand Down Expand Up @@ -63,14 +60,6 @@ public void setDeprecated(Boolean deprecated) {
this.deprecated = deprecated;
}

public Boolean getAllowEmptyValue() {
return allowEmptyValue;
}

public void setAllowEmptyValue(Boolean allowEmptyValue) {
this.allowEmptyValue = allowEmptyValue;
}

public Schema getSchema() {
return schema;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public Link(String ref) {
super(ref);
}

public Link(io.swagger.oas.annotations.links.Link l) {
public Link(io.swagger.v3.oas.annotations.links.Link l) {
setOperationRef(OpenApi.nullIfEmpty(l.operationRef()));
setOperationId(OpenApi.nullIfEmpty(l.operationId()));

for(io.swagger.oas.annotations.links.LinkParameter lp: l.parameters()) {
for(io.swagger.v3.oas.annotations.links.LinkParameter lp: l.parameters()) {
String name = OpenApi.nullIfEmpty(lp.name());
if(name != null) {
getParameters().put(name, new LinkParameter(lp));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class LinkParameter {
private String name;
private String expression;

public LinkParameter(io.swagger.oas.annotations.links.LinkParameter lp) {
public LinkParameter(io.swagger.v3.oas.annotations.links.LinkParameter lp) {
setName(OpenApi.nullIfEmpty(lp.name()));
setExpression(OpenApi.nullIfEmpty(lp.expression()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ public class MediaType {
private Map<String, Example> examples;
private Map<String, Encoding> encoding;

public MediaType(io.swagger.oas.annotations.media.Content c) {
public MediaType(io.swagger.v3.oas.annotations.media.Content c) {
setSchema(new Schema(c.schema()));
if(!getSchema().isValid()){
setSchema(null);
}

//TODO: setExample(); ??

for(io.swagger.oas.annotations.media.ExampleObject e : c.examples()) {
for(io.swagger.v3.oas.annotations.media.ExampleObject e : c.examples()) {
getExamples().put(e.name(), new Example(e));
}

for(io.swagger.oas.annotations.media.Encoding e : c.encoding()) {
for(io.swagger.v3.oas.annotations.media.Encoding e : c.encoding()) {
getEncoding().put(e.name(), new Encoding(e));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Operation() {

}

public Operation(io.swagger.oas.annotations.Operation op) {
public Operation(io.swagger.v3.oas.annotations.Operation op) {
setTags(Arrays.asList(op.tags()));
setSummary(OpenApi.nullIfEmpty(op.summary()));
setDescription(OpenApi.nullIfEmpty(op.description()));
Expand All @@ -37,7 +37,7 @@ public Operation(io.swagger.oas.annotations.Operation op) {
}
setOperationId(OpenApi.nullIfEmpty(op.operationId()));

for(io.swagger.oas.annotations.Parameter p : op.parameters()) {
for(io.swagger.v3.oas.annotations.Parameter p : op.parameters()) {
getParameters().add(new Parameter(p));
}

Expand All @@ -46,7 +46,7 @@ public Operation(io.swagger.oas.annotations.Operation op) {
setRequestBody(null);
}

for(io.swagger.oas.annotations.responses.ApiResponse r : op.responses()) {
for(io.swagger.v3.oas.annotations.responses.ApiResponse r : op.responses()) {
if(OpenApi.nullIfEmpty(r.responseCode()) != null) {
getResponses().put(r.responseCode(), new Response(r));
}
Expand All @@ -56,15 +56,15 @@ public Operation(io.swagger.oas.annotations.Operation op) {

setDeprecated(op.deprecated());

for(io.swagger.oas.annotations.security.SecurityRequirement sr : op.security()) {
for(io.swagger.v3.oas.annotations.security.SecurityRequirement sr : op.security()) {
if(OpenApi.nullIfEmpty(sr.name()) != null) {
Map<String, String[]> sec = new HashMap<String, String[]>();
sec.put(sr.name(), sr.scopes());
getSecurity().add(sec);
}
}

for(io.swagger.oas.annotations.servers.Server s : op.servers()) {
for(io.swagger.v3.oas.annotations.servers.Server s : op.servers()) {
getServers().add(new Server(s));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.HashMap;
import java.util.Map;

import io.swagger.oas.annotations.enums.Explode;
import io.swagger.v3.oas.annotations.enums.Explode;

/**
* @see https://swagger.io/specification/#parameterObject
Expand All @@ -27,23 +27,23 @@ public Parameter(String ref) {
super(ref);
}

public Parameter(io.swagger.oas.annotations.Parameter p) {
public Parameter(io.swagger.v3.oas.annotations.Parameter p) {
setName(OpenApi.nullIfEmpty(p.name()));
setIn(OpenApi.nullIfEmpty(p.in()));
setIn(OpenApi.nullIfEmpty(p.in().toString()));
setDescription(OpenApi.nullIfEmpty(p.description()));
setRequired(p.required());
setDeprecated(p.deprecated());
setAllowEmptyValue(p.allowEmptyValue());

setStyle(OpenApi.nullIfEmpty(p.style()));
setStyle(OpenApi.nullIfEmpty(p.style().toString()));
setExplode(p.explode() == Explode.TRUE);
setAllowReserved(p.allowReserved());
setSchema(new Schema(p.schema()));
if(!getSchema().isValid()){
setSchema(null);
}
setExample(OpenApi.nullIfEmpty(p.example()));
for(io.swagger.oas.annotations.media.ExampleObject e : p.examples()) {
for(io.swagger.v3.oas.annotations.media.ExampleObject e : p.examples()) {
if(e.name().length() > 0) {
getExamples().put(e.name(), new Example(e));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public RequestBody(String ref) {
super(ref);
}

public RequestBody(io.swagger.oas.annotations.parameters.RequestBody rb) {
public RequestBody(io.swagger.v3.oas.annotations.parameters.RequestBody rb) {
setDescription(OpenApi.nullIfEmpty(rb.description()));
for(io.swagger.oas.annotations.media.Content c : rb.content()) {
for(io.swagger.v3.oas.annotations.media.Content c : rb.content()) {
if(OpenApi.nullIfEmpty(c.mediaType()) != null) {
getContent().put(c.mediaType(), new MediaType(c));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.HashMap;
import java.util.Map;

import io.swagger.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponse;

/**
* @see https://swagger.io/specification/#responsesObject
Expand All @@ -19,21 +19,21 @@ public class Response {
public Response(ApiResponse r) {
setDescription(OpenApi.nullIfEmpty(r.description()));

for(io.swagger.oas.annotations.headers.Header h : r.headers()) {
for(io.swagger.v3.oas.annotations.headers.Header h : r.headers()) {
String name = OpenApi.nullIfEmpty(h.name());
if(name != null) {
getHeaders().put(name, new Header(h));
}
}

for(io.swagger.oas.annotations.media.Content c : r.content()) {
for(io.swagger.v3.oas.annotations.media.Content c : r.content()) {
String name = OpenApi.nullIfEmpty(c.mediaType());
if(name != null) {
getContent().put(c.mediaType(), new MediaType(c));
}
}

for(io.swagger.oas.annotations.links.Link l : r.links()) {
for(io.swagger.v3.oas.annotations.links.Link l : r.links()) {
String name = OpenApi.nullIfEmpty(l.name());
if(name != null) {
getLinks().put(name, new Link(l));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Schema(String ref) {
super(ref);
}

public Schema(io.swagger.oas.annotations.media.Schema schema) {
public Schema(io.swagger.v3.oas.annotations.media.Schema schema) {
setRef(OpenApi.nullIfEmpty(schema.ref()));
setTitle(OpenApi.nullIfEmpty(schema.title()));
setMultipleOf(schema.multipleOf());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public Server(String url, String description) {
setDescription(description);
}

public Server(io.swagger.oas.annotations.servers.Server s) {
public Server(io.swagger.v3.oas.annotations.servers.Server s) {
setUrl(OpenApi.nullIfEmpty(s.url()));
setDescription(OpenApi.nullIfEmpty(s.description()));

for(io.swagger.oas.annotations.servers.ServerVariable sv : s.variables()) {
for(io.swagger.v3.oas.annotations.servers.ServerVariable sv : s.variables()) {
String name = OpenApi.nullIfEmpty(sv.name());
if(name != null) {
getVariables().put(name, new ServerVariable(sv));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ServerVariable(String defaultValue) {
setDefault(defaultValue);
}

public ServerVariable(io.swagger.oas.annotations.servers.ServerVariable sv) {
public ServerVariable(io.swagger.v3.oas.annotations.servers.ServerVariable sv) {
if(sv.allowableValues() != null && sv.allowableValues().length > 0) {
setEnumVar(Arrays.asList(sv.allowableValues()));
}
Expand Down
13 changes: 0 additions & 13 deletions swagger/src/main/java/io/swagger/oas/annotations/Hidden.java

This file was deleted.

Loading