Skip to content

Commit 959f2d1

Browse files
committed
Merge remote-tracking branch 'origin/apispark-3.11' into 2.3
2 parents a4c03cd + 1aae130 commit 959f2d1

7 files changed

Lines changed: 44 additions & 16 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin

modules/org.restlet.ext.apispark/src/org/restlet/ext/apispark/Introspector.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public static void process(String[] args) throws TranslationException {
238238

239239
if (StringUtils.isNullOrEmpty(ulogin)
240240
|| StringUtils.isNullOrEmpty(upwd)) {
241-
failWithErrorMessage("You should specify your API spark login and password with -U (--username) and -p (--password). ");
241+
failWithErrorMessage("You should specify your API spark login and password with -u (--username) and -p (--password). ");
242242
}
243243

244244
if (StringUtils.isNullOrEmpty(defSource) && jaxRsResources.isEmpty()) {
@@ -293,12 +293,9 @@ public boolean isLoggable(LogRecord record) {
293293
// TODO implement introspection of Restlet based JaxRs
294294
// (org.restlet.ext.jaxrs.JaxRsApplication)
295295
if (Application.class.isAssignableFrom(clazz)) {
296-
Application application = ApplicationIntrospector
297-
.getApplication(defSource);
298-
Component component = ComponentIntrospector
299-
.getComponent(compName);
300-
Reference baseRef = endpoint != null ? new Reference(
301-
endpoint) : null;
296+
Application application = ApplicationIntrospector.getApplication(defSource);
297+
Component component = ComponentIntrospector.getComponent(compName);
298+
Reference baseRef = endpoint != null ? new Reference(endpoint) : null;
302299
if (applicationName != null) {
303300
application.setName(applicationName);
304301
}

modules/org.restlet.ext.apispark/src/org/restlet/ext/apispark/internal/conversion/swagger/v2_0/Swagger2Reader.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ private static void fillDeclaredParameters(Swagger swagger, Definition definitio
6666
parameters.put(key, queryParameter);
6767

6868
} else if (swaggerParameter instanceof PathParameter) {
69-
org.restlet.ext.apispark.internal.model.PathVariable pathVariable =
70-
new org.restlet.ext.apispark.internal.model.PathVariable();
69+
PathVariable pathVariable = new PathVariable();
7170
fillRwadefPathVariable(pathVariable, (PathParameter) swaggerParameter);
7271
parameters.put(key, pathVariable);
7372

@@ -360,7 +359,32 @@ private static void fillRwadefParameters(Operation swaggerOperation,
360359
}
361360

362361
for (Parameter swaggerParameter : swaggerOperation.getParameters()) {
363-
if (swaggerParameter instanceof QueryParameter) {
362+
363+
if (swaggerParameter instanceof RefParameter) {
364+
RefParameter refParameter = (RefParameter) swaggerParameter;
365+
Object rwadefParameter = parameters.get(refParameter.getSimpleRef());
366+
367+
if (rwadefParameter == null) {
368+
LOGGER.warning("The parameter " + refParameter.getName()
369+
+ " was not found in the list of declared parameters.");
370+
} else if (rwadefParameter instanceof Header) {
371+
operation.getHeaders().add((Header) rwadefParameter);
372+
} else if (rwadefParameter instanceof PathVariable) {
373+
resource.addPathVariable((PathVariable) rwadefParameter);
374+
375+
} else if (rwadefParameter instanceof org.restlet.ext.apispark.internal.model.QueryParameter) {
376+
operation.getQueryParameters().add(
377+
(org.restlet.ext.apispark.internal.model.QueryParameter) rwadefParameter);
378+
379+
} else if (rwadefParameter instanceof PayLoad) {
380+
operation.setInputPayLoad((PayLoad) rwadefParameter);
381+
382+
} else {
383+
LOGGER.warning("The type of declared parameter " + refParameter.getName() + ", " +
384+
rwadefParameter.getClass() + " is not supported.");
385+
}
386+
387+
} else if (swaggerParameter instanceof QueryParameter) {
364388
org.restlet.ext.apispark.internal.model.QueryParameter queryParameter =
365389
new org.restlet.ext.apispark.internal.model.QueryParameter();
366390
QueryParameter swaggerQueryParameter = (QueryParameter) swaggerParameter;

modules/org.restlet.ext.apispark/src/org/restlet/ext/apispark/internal/introspection/application/ApplicationIntrospector.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ public static Definition getDefinition(Application application,
143143
Contract contract = new Contract();
144144
contract.setDescription(StringUtils.nullToEmpty(application
145145
.getDescription()));
146-
if (StringUtils.isNullOrEmpty(application.getName())) {
146+
if (application.toString().equals(application.getName())) {
147147
LOGGER.log(Level.WARNING,
148-
"Please provide a name to your application, used "
149-
+ contract.getName() + " by default.");
150-
contract.setName(application.getClass().getName());
148+
"Please provide a name to your application by overriding its method getName. Used "
149+
+ application.getClass().getSimpleName() + " by default.");
150+
contract.setName(application.getClass().getSimpleName());
151151
} else {
152152
contract.setName(application.getName());
153153
}

modules/org.restlet.ext.apispark/src/org/restlet/ext/apispark/internal/model/Endpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void setPort(Integer port) {
136136
if (port != null && port != -1) {
137137
this.port = port;
138138
} else {
139-
port = null;
139+
this.port = null;
140140
}
141141
}
142142

modules/org.restlet.ext.apispark/src/org/restlet/ext/apispark/internal/model/Resource.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ public Operation getOperation(String name) {
8080
return null;
8181
}
8282

83+
public void addPathVariable(PathVariable pathVariable) {
84+
if (getPathVariable(pathVariable.getName()) == null) {
85+
pathVariables.add(pathVariable);
86+
}
87+
}
88+
8389
@JsonInclude(Include.NON_EMPTY)
8490
public List<Operation> getOperations() {
8591
return operations;

modules/org.restlet/src/org/restlet/data/Conditions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public Status getStatus(Method method, boolean entityExists, Tag tag,
305305
}
306306
} else {
307307
matched = (getNoneMatch().size() > 0)
308-
&& getNoneMatch().get(0).equals(Tag.ALL);
308+
&& Tag.ALL.equals(getNoneMatch().get(0));
309309
}
310310
}
311311

0 commit comments

Comments
 (0)