diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache
index 4cf875c207f4..153867a0a971 100644
--- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache
@@ -472,11 +472,13 @@ public class ApiClient {
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
+ * application/vnd.company+json
* @param mime MIME
* @return True if MIME type is boolean
*/
public boolean isJsonMime(String mime) {
- return mime != null && mime.matches("(?i)application\\/json(;.*)?");
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && mime.matches(jsonMime);
}
/**
diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
index 5eecde916640..d44d724454eb 100644
--- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
@@ -436,11 +436,13 @@ public class ApiClient {
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
+ * application/vnd.company+json
* @param mime MIME
* @return True if the MIME type is JSON
*/
public boolean isJsonMime(String mime) {
- return mime != null && mime.matches("(?i)application\\/json(;.*)?");
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && mime.matches(jsonMime);
}
/**
diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
index 3aea0ecf917c..719b13da25bc 100644
--- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
@@ -535,12 +535,13 @@ public class ApiClient {
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
- *
+ * application/vnd.company+json
* @param mime MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public boolean isJsonMime(String mime) {
- return mime != null && mime.matches("(?i)application\\/json(;.*)?");
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && mime.matches(jsonMime);
}
/**
diff --git a/modules/swagger-codegen/src/main/resources/elixir/api.mustache b/modules/swagger-codegen/src/main/resources/elixir/api.mustache
index 7a10537b5fac..799a4c31c089 100644
--- a/modules/swagger-codegen/src/main/resources/elixir/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/elixir/api.mustache
@@ -10,6 +10,13 @@ defmodule {{#modulized}}{{appName}}{{/modulized}}.Api.{{classname}} do
{{#operations}}
{{#operation}}
+ @doc """
+ {{summary}}
+ {{^notes.isEmpty}}
+
+ {{notes}}
+ {{/notes.isEmpty}}
+ """
def {{#underscored}}{{operationId}}{{/underscored}}({{#allParams}}{{^-first}}, {{/-first}}{{#underscored}}{{paramName}}{{/underscored}}{{/allParams}}) do
method = [method: :{{#underscored}}{{httpMethod}}{{/underscored}}]
url = [url: "{{replacedPathName}}"]
diff --git a/modules/swagger-codegen/src/main/resources/nodejs/index.mustache b/modules/swagger-codegen/src/main/resources/nodejs/index.mustache
index 397661d4d523..a462b154e1dd 100644
--- a/modules/swagger-codegen/src/main/resources/nodejs/index.mustache
+++ b/modules/swagger-codegen/src/main/resources/nodejs/index.mustache
@@ -1,25 +1,28 @@
'use strict';
+var fs = require('fs'),
+ path = require('path'),
+ http = require('http');
+
var app = require('connect')();
-var http = require('http');
var swaggerTools = require('swagger-tools');
var jsyaml = require('js-yaml');
-var fs = require('fs');
var serverPort = {{serverPort}};
// swaggerRouter configuration
var options = {
- swaggerUi: '/swagger.json',
- controllers: './controllers',
- useStubs: process.env.NODE_ENV === 'development' ? true : false // Conditionally turn on stubs (mock mode)
+ swaggerUi: path.join(__dirname, '/swagger.json'),
+ controllers: path.join(__dirname, './controllers'),
+ useStubs: process.env.NODE_ENV === 'development' // Conditionally turn on stubs (mock mode)
};
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
-var spec = fs.readFileSync('./api/swagger.yaml', 'utf8');
+var spec = fs.readFileSync(path.join(__dirname,'api/swagger.yaml'), 'utf8');
var swaggerDoc = jsyaml.safeLoad(spec);
// Initialize the Swagger middleware
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
+
// Interpret Swagger resources and attach metadata to request - must be first in swagger-tools middleware chain
app.use(middleware.swaggerMetadata());
@@ -37,4 +40,5 @@ swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort);
console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort);
});
+
});
diff --git a/samples/client/petstore-security-test/java/okhttp-gson/pom.xml b/samples/client/petstore-security-test/java/okhttp-gson/pom.xml
index be07768b92eb..9ab87a8691c2 100644
--- a/samples/client/petstore-security-test/java/okhttp-gson/pom.xml
+++ b/samples/client/petstore-security-test/java/okhttp-gson/pom.xml
@@ -6,8 +6,10 @@
jar
swagger-petstore-okhttp-gson
1.0.0
+ https://github.com/swagger-api/swagger-codegen
+ Swagger Java
- scm:git:git@github.com:swagger-api/swagger-mustache.git
+ scm:git:git@github.com:swagger-api/swagger-codegen.git
scm:git:git@github.com:swagger-api/swagger-codegen.git
https://github.com/swagger-api/swagger-codegen
@@ -22,7 +24,16 @@
repo
-
+
+
+
+ Swagger
+ apiteam@swagger.io
+ Swagger
+ http://swagger.io
+
+
+
@@ -108,9 +119,55 @@
org.apache.maven.plugins
maven-javadoc-plugin
2.10.4
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.2.1
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+
+ sign-artifacts
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.5
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+
+
+
+
io.swagger
@@ -149,7 +206,7 @@
1.7
${java.version}
${java.version}
- 1.5.9
+ 1.5.12
2.7.5
2.6.2
2.9.3
diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java
index 6a443dd2a9f6..fcc2693df502 100644
--- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java
@@ -139,6 +139,7 @@ public class ApiClient {
public ApiClient() {
httpClient = new OkHttpClient();
+
verifyingSsl = true;
json = new JSON(this);
@@ -725,12 +726,13 @@ public class ApiClient {
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
- *
+ * application/vnd.company+json
* @param mime MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public boolean isJsonMime(String mime) {
- return mime != null && mime.matches("(?i)application\\/json(;.*)?");
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && mime.matches(jsonMime);
}
/**
diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/GzipRequestInterceptor.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/GzipRequestInterceptor.java
new file mode 100644
index 000000000000..179abb3a5403
--- /dev/null
+++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/GzipRequestInterceptor.java
@@ -0,0 +1,81 @@
+/*
+ * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
+ *
+ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
+ * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
+ *
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen.git
+ * Do not edit the class manually.
+ */
+
+
+package io.swagger.client;
+
+import com.squareup.okhttp.*;
+import okio.Buffer;
+import okio.BufferedSink;
+import okio.GzipSink;
+import okio.Okio;
+
+import java.io.IOException;
+
+/**
+ * Encodes request bodies using gzip.
+ *
+ * Taken from https://github.com/square/okhttp/issues/350
+ */
+class GzipRequestInterceptor implements Interceptor {
+ @Override public Response intercept(Chain chain) throws IOException {
+ Request originalRequest = chain.request();
+ if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
+ return chain.proceed(originalRequest);
+ }
+
+ Request compressedRequest = originalRequest.newBuilder()
+ .header("Content-Encoding", "gzip")
+ .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
+ .build();
+ return chain.proceed(compressedRequest);
+ }
+
+ private RequestBody forceContentLength(final RequestBody requestBody) throws IOException {
+ final Buffer buffer = new Buffer();
+ requestBody.writeTo(buffer);
+ return new RequestBody() {
+ @Override
+ public MediaType contentType() {
+ return requestBody.contentType();
+ }
+
+ @Override
+ public long contentLength() {
+ return buffer.size();
+ }
+
+ @Override
+ public void writeTo(BufferedSink sink) throws IOException {
+ sink.write(buffer.snapshot());
+ }
+ };
+ }
+
+ private RequestBody gzip(final RequestBody body) {
+ return new RequestBody() {
+ @Override public MediaType contentType() {
+ return body.contentType();
+ }
+
+ @Override public long contentLength() {
+ return -1; // We don't know the compressed length in advance!
+ }
+
+ @Override public void writeTo(BufferedSink sink) throws IOException {
+ BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));
+ body.writeTo(gzipSink);
+ gzipSink.close();
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java
index 8a4e08dc244a..40a7942e682e 100644
--- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java
+++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java
@@ -9,159 +9,166 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
-
-
-package io.swagger.client.api;
-
-import io.swagger.client.ApiCallback;
-import io.swagger.client.ApiClient;
-import io.swagger.client.ApiException;
-import io.swagger.client.ApiResponse;
-import io.swagger.client.Configuration;
-import io.swagger.client.Pair;
-import io.swagger.client.ProgressRequestBody;
-import io.swagger.client.ProgressResponseBody;
-
-import com.google.gson.reflect.TypeToken;
-
-import java.io.IOException;
-
-
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class FakeApi {
- private ApiClient apiClient;
-
- public FakeApi() {
- this(Configuration.getDefaultApiClient());
- }
-
- public FakeApi(ApiClient apiClient) {
- this.apiClient = apiClient;
- }
-
- public ApiClient getApiClient() {
- return apiClient;
- }
-
- public void setApiClient(ApiClient apiClient) {
- this.apiClient = apiClient;
- }
-
- /* Build call for testCodeInjectEndRnNR */
- private com.squareup.okhttp.Call testCodeInjectEndRnNRCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
- Object localVarPostBody = null;
-
- // create path and map variables
- String localVarPath = "/fake".replaceAll("\\{format\\}","json");
-
- List localVarQueryParams = new ArrayList();
-
- Map localVarHeaderParams = new HashMap();
-
- Map localVarFormParams = new HashMap();
- if (testCodeInjectEndRnNR != null)
- localVarFormParams.put("test code inject */ ' " =end -- \r\n \n \r", testCodeInjectEndRnNR);
-
- final String[] localVarAccepts = {
- "application/json", "*_/ ' =end -- "
- };
- final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
- if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
-
- final String[] localVarContentTypes = {
- "application/json", "*_/ ' =end -- "
- };
- final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
- localVarHeaderParams.put("Content-Type", localVarContentType);
-
- if(progressListener != null) {
- apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
- @Override
- public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
- com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
- return originalResponse.newBuilder()
- .body(new ProgressResponseBody(originalResponse.body(), progressListener))
- .build();
- }
- });
- }
-
- String[] localVarAuthNames = new String[] { };
- return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
- }
-
- @SuppressWarnings("rawtypes")
- private com.squareup.okhttp.Call testCodeInjectEndRnNRValidateBeforeCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
-
-
- com.squareup.okhttp.Call call = testCodeInjectEndRnNRCall(testCodeInjectEndRnNR, progressListener, progressRequestListener);
- return call;
-
-
-
-
-
- }
-
- /**
- * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
- *
- * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
- * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
- */
- public void testCodeInjectEndRnNR(String testCodeInjectEndRnNR) throws ApiException {
- testCodeInjectEndRnNRWithHttpInfo(testCodeInjectEndRnNR);
- }
-
- /**
- * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
- *
- * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
- * @return ApiResponse<Void>
- * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
- */
- public ApiResponse testCodeInjectEndRnNRWithHttpInfo(String testCodeInjectEndRnNR) throws ApiException {
- com.squareup.okhttp.Call call = testCodeInjectEndRnNRValidateBeforeCall(testCodeInjectEndRnNR, null, null);
- return apiClient.execute(call);
- }
-
- /**
- * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (asynchronously)
- *
- * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
- * @param callback The callback to be executed when the API call finishes
- * @return The request call
- * @throws ApiException If fail to process the API call, e.g. serializing the request body object
- */
- public com.squareup.okhttp.Call testCodeInjectEndRnNRAsync(String testCodeInjectEndRnNR, final ApiCallback callback) throws ApiException {
-
- ProgressResponseBody.ProgressListener progressListener = null;
- ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
-
- if (callback != null) {
- progressListener = new ProgressResponseBody.ProgressListener() {
- @Override
- public void update(long bytesRead, long contentLength, boolean done) {
- callback.onDownloadProgress(bytesRead, contentLength, done);
- }
- };
-
- progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
- @Override
- public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
- callback.onUploadProgress(bytesWritten, contentLength, done);
- }
- };
- }
-
- com.squareup.okhttp.Call call = testCodeInjectEndRnNRValidateBeforeCall(testCodeInjectEndRnNR, progressListener, progressRequestListener);
- apiClient.executeAsync(call, callback);
- return call;
- }
-}
+
+
+package io.swagger.client.api;
+
+import io.swagger.client.ApiCallback;
+import io.swagger.client.ApiClient;
+import io.swagger.client.ApiException;
+import io.swagger.client.ApiResponse;
+import io.swagger.client.Configuration;
+import io.swagger.client.Pair;
+import io.swagger.client.ProgressRequestBody;
+import io.swagger.client.ProgressResponseBody;
+
+import com.google.gson.reflect.TypeToken;
+
+import java.io.IOException;
+
+
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class FakeApi {
+ private ApiClient apiClient;
+
+ public FakeApi() {
+ this(Configuration.getDefaultApiClient());
+ }
+
+ public FakeApi(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ public ApiClient getApiClient() {
+ return apiClient;
+ }
+
+ public void setApiClient(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ /**
+ * Build call for testCodeInjectEndRnNR
+ * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
+ * @param progressListener Progress listener
+ * @param progressRequestListener Progress request listener
+ * @return Call to execute
+ * @throws ApiException If fail to serialize the request body object
+ */
+ public com.squareup.okhttp.Call testCodeInjectEndRnNRCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
+ Object localVarPostBody = null;
+
+ // create path and map variables
+ String localVarPath = "/fake";
+
+ List localVarQueryParams = new ArrayList();
+
+ Map localVarHeaderParams = new HashMap();
+
+ Map localVarFormParams = new HashMap();
+ if (testCodeInjectEndRnNR != null)
+ localVarFormParams.put("test code inject */ ' " =end -- \r\n \n \r", testCodeInjectEndRnNR);
+
+ final String[] localVarAccepts = {
+ "application/json", "*_/ ' =end -- "
+ };
+ final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
+
+ final String[] localVarContentTypes = {
+ "application/json", "*_/ ' =end -- "
+ };
+ final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+ localVarHeaderParams.put("Content-Type", localVarContentType);
+
+ if(progressListener != null) {
+ apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
+ @Override
+ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
+ com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
+ return originalResponse.newBuilder()
+ .body(new ProgressResponseBody(originalResponse.body(), progressListener))
+ .build();
+ }
+ });
+ }
+
+ String[] localVarAuthNames = new String[] { };
+ return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private com.squareup.okhttp.Call testCodeInjectEndRnNRValidateBeforeCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
+
+
+ com.squareup.okhttp.Call call = testCodeInjectEndRnNRCall(testCodeInjectEndRnNR, progressListener, progressRequestListener);
+ return call;
+
+
+
+
+
+ }
+
+ /**
+ * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
+ *
+ * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
+ * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
+ */
+ public void testCodeInjectEndRnNR(String testCodeInjectEndRnNR) throws ApiException {
+ testCodeInjectEndRnNRWithHttpInfo(testCodeInjectEndRnNR);
+ }
+
+ /**
+ * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
+ *
+ * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
+ * @return ApiResponse<Void>
+ * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
+ */
+ public ApiResponse testCodeInjectEndRnNRWithHttpInfo(String testCodeInjectEndRnNR) throws ApiException {
+ com.squareup.okhttp.Call call = testCodeInjectEndRnNRValidateBeforeCall(testCodeInjectEndRnNR, null, null);
+ return apiClient.execute(call);
+ }
+
+ /**
+ * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (asynchronously)
+ *
+ * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
+ * @param callback The callback to be executed when the API call finishes
+ * @return The request call
+ * @throws ApiException If fail to process the API call, e.g. serializing the request body object
+ */
+ public com.squareup.okhttp.Call testCodeInjectEndRnNRAsync(String testCodeInjectEndRnNR, final ApiCallback callback) throws ApiException {
+
+ ProgressResponseBody.ProgressListener progressListener = null;
+ ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
+
+ if (callback != null) {
+ progressListener = new ProgressResponseBody.ProgressListener() {
+ @Override
+ public void update(long bytesRead, long contentLength, boolean done) {
+ callback.onDownloadProgress(bytesRead, contentLength, done);
+ }
+ };
+
+ progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
+ @Override
+ public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
+ callback.onUploadProgress(bytesWritten, contentLength, done);
+ }
+ };
+ }
+
+ com.squareup.okhttp.Call call = testCodeInjectEndRnNRValidateBeforeCall(testCodeInjectEndRnNR, progressListener, progressRequestListener);
+ apiClient.executeAsync(call, callback);
+ return call;
+ }
+}
diff --git a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelReturn.java
index 7e26fef904c0..55a24114ddd7 100644
--- a/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelReturn.java
+++ b/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelReturn.java
@@ -36,7 +36,7 @@ public class ModelReturn {
* property description *_/ ' \" =end -- \\r\\n \\n \\r
* @return _return
**/
- @ApiModelProperty(example = "null", value = "property description *_/ ' \" =end -- \\r\\n \\n \\r")
+ @ApiModelProperty(value = "property description *_/ ' \" =end -- \\r\\n \\n \\r")
public Integer getReturn() {
return _return;
}
diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex
index ebf4327576f6..9698a6dd4162 100644
--- a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex
+++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex
@@ -8,6 +8,11 @@ defmodule SwaggerPetstore.Api.Fake do
plug Tesla.Middleware.BaseUrl, "http://petstore.swagger.io:80/v2"
plug Tesla.Middleware.JSON
+ @doc """
+ To test \"client\" model
+
+ To test \"client\" model
+ """
def test_client_model(body) do
method = [method: :patch]
url = [url: "/fake"]
@@ -22,6 +27,11 @@ defmodule SwaggerPetstore.Api.Fake do
request(options)
end
+ @doc """
+ Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
+
+ Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
+ """
def test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, date, date_time, password, callback) do
method = [method: :post]
url = [url: "/fake"]
@@ -36,6 +46,11 @@ defmodule SwaggerPetstore.Api.Fake do
request(options)
end
+ @doc """
+ To test enum parameters
+
+ To test enum parameters
+ """
def test_enum_parameters(enum_form_string_array, enum_form_string, enum_header_string_array, enum_header_string, enum_query_string_array, enum_query_string, enum_query_integer, enum_query_double) do
method = [method: :get]
url = [url: "/fake"]
diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex
index b4a9e0faf0cd..e68fb0ceaed1 100644
--- a/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex
+++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex
@@ -8,6 +8,9 @@ defmodule SwaggerPetstore.Api.Pet do
plug Tesla.Middleware.BaseUrl, "http://petstore.swagger.io:80/v2"
plug Tesla.Middleware.JSON
+ @doc """
+ Add a new pet to the store
+ """
def add_pet(body) do
method = [method: :post]
url = [url: "/pet"]
@@ -22,6 +25,9 @@ defmodule SwaggerPetstore.Api.Pet do
request(options)
end
+ @doc """
+ Deletes a pet
+ """
def delete_pet(pet_id, api_key) do
method = [method: :delete]
url = [url: "/pet/#{pet_id}"]
@@ -36,6 +42,11 @@ defmodule SwaggerPetstore.Api.Pet do
request(options)
end
+ @doc """
+ Finds Pets by status
+
+ Multiple status values can be provided with comma separated strings
+ """
def find_pets_by_status(status) do
method = [method: :get]
url = [url: "/pet/findByStatus"]
@@ -50,6 +61,11 @@ defmodule SwaggerPetstore.Api.Pet do
request(options)
end
+ @doc """
+ Finds Pets by tags
+
+ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+ """
def find_pets_by_tags(tags) do
method = [method: :get]
url = [url: "/pet/findByTags"]
@@ -64,6 +80,11 @@ defmodule SwaggerPetstore.Api.Pet do
request(options)
end
+ @doc """
+ Find pet by ID
+
+ Returns a single pet
+ """
def get_pet_by_id(pet_id) do
method = [method: :get]
url = [url: "/pet/#{pet_id}"]
@@ -78,6 +99,9 @@ defmodule SwaggerPetstore.Api.Pet do
request(options)
end
+ @doc """
+ Update an existing pet
+ """
def update_pet(body) do
method = [method: :put]
url = [url: "/pet"]
@@ -92,6 +116,9 @@ defmodule SwaggerPetstore.Api.Pet do
request(options)
end
+ @doc """
+ Updates a pet in the store with form data
+ """
def update_pet_with_form(pet_id, name, status) do
method = [method: :post]
url = [url: "/pet/#{pet_id}"]
@@ -106,6 +133,9 @@ defmodule SwaggerPetstore.Api.Pet do
request(options)
end
+ @doc """
+ uploads an image
+ """
def upload_file(pet_id, additional_metadata, file) do
method = [method: :post]
url = [url: "/pet/#{pet_id}/uploadImage"]
diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/store.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/store.ex
index 0bb53ca1d576..a37ac36b2f70 100644
--- a/samples/client/petstore/elixir/lib/swagger_petstore/api/store.ex
+++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/store.ex
@@ -8,6 +8,11 @@ defmodule SwaggerPetstore.Api.Store do
plug Tesla.Middleware.BaseUrl, "http://petstore.swagger.io:80/v2"
plug Tesla.Middleware.JSON
+ @doc """
+ Delete purchase order by ID
+
+ For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ """
def delete_order(order_id) do
method = [method: :delete]
url = [url: "/store/order/#{order_id}"]
@@ -22,6 +27,11 @@ defmodule SwaggerPetstore.Api.Store do
request(options)
end
+ @doc """
+ Returns pet inventories by status
+
+ Returns a map of status codes to quantities
+ """
def get_inventory() do
method = [method: :get]
url = [url: "/store/inventory"]
@@ -36,6 +46,11 @@ defmodule SwaggerPetstore.Api.Store do
request(options)
end
+ @doc """
+ Find purchase order by ID
+
+ For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ """
def get_order_by_id(order_id) do
method = [method: :get]
url = [url: "/store/order/#{order_id}"]
@@ -50,6 +65,9 @@ defmodule SwaggerPetstore.Api.Store do
request(options)
end
+ @doc """
+ Place an order for a pet
+ """
def place_order(body) do
method = [method: :post]
url = [url: "/store/order"]
diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/user.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/user.ex
index 6bccbea13318..9ebb200f0f09 100644
--- a/samples/client/petstore/elixir/lib/swagger_petstore/api/user.ex
+++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/user.ex
@@ -8,6 +8,11 @@ defmodule SwaggerPetstore.Api.User do
plug Tesla.Middleware.BaseUrl, "http://petstore.swagger.io:80/v2"
plug Tesla.Middleware.JSON
+ @doc """
+ Create user
+
+ This can only be done by the logged in user.
+ """
def create_user(body) do
method = [method: :post]
url = [url: "/user"]
@@ -22,6 +27,9 @@ defmodule SwaggerPetstore.Api.User do
request(options)
end
+ @doc """
+ Creates list of users with given input array
+ """
def create_users_with_array_input(body) do
method = [method: :post]
url = [url: "/user/createWithArray"]
@@ -36,6 +44,9 @@ defmodule SwaggerPetstore.Api.User do
request(options)
end
+ @doc """
+ Creates list of users with given input array
+ """
def create_users_with_list_input(body) do
method = [method: :post]
url = [url: "/user/createWithList"]
@@ -50,6 +61,11 @@ defmodule SwaggerPetstore.Api.User do
request(options)
end
+ @doc """
+ Delete user
+
+ This can only be done by the logged in user.
+ """
def delete_user(username) do
method = [method: :delete]
url = [url: "/user/#{username}"]
@@ -64,6 +80,9 @@ defmodule SwaggerPetstore.Api.User do
request(options)
end
+ @doc """
+ Get user by user name
+ """
def get_user_by_name(username) do
method = [method: :get]
url = [url: "/user/#{username}"]
@@ -78,6 +97,9 @@ defmodule SwaggerPetstore.Api.User do
request(options)
end
+ @doc """
+ Logs user into the system
+ """
def login_user(username, password) do
method = [method: :get]
url = [url: "/user/login"]
@@ -92,6 +114,9 @@ defmodule SwaggerPetstore.Api.User do
request(options)
end
+ @doc """
+ Logs out current logged in user session
+ """
def logout_user() do
method = [method: :get]
url = [url: "/user/logout"]
@@ -106,6 +131,11 @@ defmodule SwaggerPetstore.Api.User do
request(options)
end
+ @doc """
+ Updated user
+
+ This can only be done by the logged in user.
+ """
def update_user(username, body) do
method = [method: :put]
url = [url: "/user/#{username}"]
diff --git a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/ApiClient.java
index 5686c7950e0a..43bafe380999 100644
--- a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/ApiClient.java
@@ -465,11 +465,13 @@ public class ApiClient {
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
+ * application/vnd.company+json
* @param mime MIME
* @return True if MIME type is boolean
*/
public boolean isJsonMime(String mime) {
- return mime != null && mime.matches("(?i)application\\/json(;.*)?");
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && mime.matches(jsonMime);
}
/**
diff --git a/samples/client/petstore/java/jersey1/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/jersey1/src/test/java/io/swagger/client/ApiClientTest.java
index 19b55257d0c0..c88245473033 100644
--- a/samples/client/petstore/java/jersey1/src/test/java/io/swagger/client/ApiClientTest.java
+++ b/samples/client/petstore/java/jersey1/src/test/java/io/swagger/client/ApiClientTest.java
@@ -40,15 +40,26 @@ public class ApiClientTest {
@Test
public void testIsJsonMime() {
- assertFalse(apiClient.isJsonMime(null));
- assertFalse(apiClient.isJsonMime(""));
- assertFalse(apiClient.isJsonMime("text/plain"));
- assertFalse(apiClient.isJsonMime("application/xml"));
- assertFalse(apiClient.isJsonMime("application/jsonp"));
+ assertFalse(apiClient.isJsonMime(null));
+ assertFalse(apiClient.isJsonMime(""));
+ assertFalse(apiClient.isJsonMime("text/plain"));
+ assertFalse(apiClient.isJsonMime("application/xml"));
+ assertFalse(apiClient.isJsonMime("application/jsonp"));
+ assertFalse(apiClient.isJsonMime("example/json"));
+ assertFalse(apiClient.isJsonMime("example/foo+bar+jsonx"));
+ assertFalse(apiClient.isJsonMime("example/foo+bar+xjson"));
- assertTrue(apiClient.isJsonMime("application/json"));
- assertTrue(apiClient.isJsonMime("application/json; charset=UTF8"));
- assertTrue(apiClient.isJsonMime("APPLICATION/JSON"));
+ assertTrue(apiClient.isJsonMime("application/json"));
+ assertTrue(apiClient.isJsonMime("application/json; charset=UTF8"));
+ assertTrue(apiClient.isJsonMime("APPLICATION/JSON"));
+
+ assertTrue(apiClient.isJsonMime("application/problem+json"));
+ assertTrue(apiClient.isJsonMime("APPLICATION/PROBLEM+JSON"));
+ assertTrue(apiClient.isJsonMime("application/json\t"));
+ assertTrue(apiClient.isJsonMime("example/foo+bar+json"));
+ assertTrue(apiClient.isJsonMime("example/foo+json;x;y"));
+ assertTrue(apiClient.isJsonMime("example/foo+json\t;"));
+ assertTrue(apiClient.isJsonMime("Example/fOO+JSON"));
}
@Test
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/ApiClient.java
index 74d0376e7351..31c5d60d626a 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/ApiClient.java
@@ -431,11 +431,13 @@ public class ApiClient {
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
+ * application/vnd.company+json
* @param mime MIME
* @return True if the MIME type is JSON
*/
public boolean isJsonMime(String mime) {
- return mime != null && mime.matches("(?i)application\\/json(;.*)?");
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && mime.matches(jsonMime);
}
/**
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java
index 2ebc1336a986..2878363c9803 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java
@@ -431,11 +431,13 @@ public class ApiClient {
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
+ * application/vnd.company+json
* @param mime MIME
* @return True if the MIME type is JSON
*/
public boolean isJsonMime(String mime) {
- return mime != null && mime.matches("(?i)application\\/json(;.*)?");
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && mime.matches(jsonMime);
}
/**
diff --git a/samples/client/petstore/java/jersey2-java8/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/jersey2-java8/src/test/java/io/swagger/client/ApiClientTest.java
index 19b55257d0c0..c88245473033 100644
--- a/samples/client/petstore/java/jersey2-java8/src/test/java/io/swagger/client/ApiClientTest.java
+++ b/samples/client/petstore/java/jersey2-java8/src/test/java/io/swagger/client/ApiClientTest.java
@@ -40,15 +40,26 @@ public class ApiClientTest {
@Test
public void testIsJsonMime() {
- assertFalse(apiClient.isJsonMime(null));
- assertFalse(apiClient.isJsonMime(""));
- assertFalse(apiClient.isJsonMime("text/plain"));
- assertFalse(apiClient.isJsonMime("application/xml"));
- assertFalse(apiClient.isJsonMime("application/jsonp"));
+ assertFalse(apiClient.isJsonMime(null));
+ assertFalse(apiClient.isJsonMime(""));
+ assertFalse(apiClient.isJsonMime("text/plain"));
+ assertFalse(apiClient.isJsonMime("application/xml"));
+ assertFalse(apiClient.isJsonMime("application/jsonp"));
+ assertFalse(apiClient.isJsonMime("example/json"));
+ assertFalse(apiClient.isJsonMime("example/foo+bar+jsonx"));
+ assertFalse(apiClient.isJsonMime("example/foo+bar+xjson"));
- assertTrue(apiClient.isJsonMime("application/json"));
- assertTrue(apiClient.isJsonMime("application/json; charset=UTF8"));
- assertTrue(apiClient.isJsonMime("APPLICATION/JSON"));
+ assertTrue(apiClient.isJsonMime("application/json"));
+ assertTrue(apiClient.isJsonMime("application/json; charset=UTF8"));
+ assertTrue(apiClient.isJsonMime("APPLICATION/JSON"));
+
+ assertTrue(apiClient.isJsonMime("application/problem+json"));
+ assertTrue(apiClient.isJsonMime("APPLICATION/PROBLEM+JSON"));
+ assertTrue(apiClient.isJsonMime("application/json\t"));
+ assertTrue(apiClient.isJsonMime("example/foo+bar+json"));
+ assertTrue(apiClient.isJsonMime("example/foo+json;x;y"));
+ assertTrue(apiClient.isJsonMime("example/foo+json\t;"));
+ assertTrue(apiClient.isJsonMime("Example/fOO+JSON"));
}
@Test
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java
index 2ebc1336a986..2878363c9803 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java
@@ -431,11 +431,13 @@ public class ApiClient {
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
+ * application/vnd.company+json
* @param mime MIME
* @return True if the MIME type is JSON
*/
public boolean isJsonMime(String mime) {
- return mime != null && mime.matches("(?i)application\\/json(;.*)?");
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && mime.matches(jsonMime);
}
/**
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java
index 19b55257d0c0..c88245473033 100644
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java
+++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java
@@ -40,15 +40,26 @@ public class ApiClientTest {
@Test
public void testIsJsonMime() {
- assertFalse(apiClient.isJsonMime(null));
- assertFalse(apiClient.isJsonMime(""));
- assertFalse(apiClient.isJsonMime("text/plain"));
- assertFalse(apiClient.isJsonMime("application/xml"));
- assertFalse(apiClient.isJsonMime("application/jsonp"));
+ assertFalse(apiClient.isJsonMime(null));
+ assertFalse(apiClient.isJsonMime(""));
+ assertFalse(apiClient.isJsonMime("text/plain"));
+ assertFalse(apiClient.isJsonMime("application/xml"));
+ assertFalse(apiClient.isJsonMime("application/jsonp"));
+ assertFalse(apiClient.isJsonMime("example/json"));
+ assertFalse(apiClient.isJsonMime("example/foo+bar+jsonx"));
+ assertFalse(apiClient.isJsonMime("example/foo+bar+xjson"));
- assertTrue(apiClient.isJsonMime("application/json"));
- assertTrue(apiClient.isJsonMime("application/json; charset=UTF8"));
- assertTrue(apiClient.isJsonMime("APPLICATION/JSON"));
+ assertTrue(apiClient.isJsonMime("application/json"));
+ assertTrue(apiClient.isJsonMime("application/json; charset=UTF8"));
+ assertTrue(apiClient.isJsonMime("APPLICATION/JSON"));
+
+ assertTrue(apiClient.isJsonMime("application/problem+json"));
+ assertTrue(apiClient.isJsonMime("APPLICATION/PROBLEM+JSON"));
+ assertTrue(apiClient.isJsonMime("application/json\t"));
+ assertTrue(apiClient.isJsonMime("example/foo+bar+json"));
+ assertTrue(apiClient.isJsonMime("example/foo+json;x;y"));
+ assertTrue(apiClient.isJsonMime("example/foo+json\t;"));
+ assertTrue(apiClient.isJsonMime("Example/fOO+JSON"));
}
@Test
diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java
index 0168569326fd..366044b374ba 100644
--- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java
@@ -516,12 +516,13 @@ public class ApiClient {
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
- *
+ * application/vnd.company+json
* @param mime MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public boolean isJsonMime(String mime) {
- return mime != null && mime.matches("(?i)application\\/json(;.*)?");
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && mime.matches(jsonMime);
}
/**
diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java
index df6cff4ecb79..625c2764b700 100644
--- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java
+++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java
@@ -23,15 +23,26 @@ public class ApiClientTest {
@Test
public void testIsJsonMime() {
- assertFalse(apiClient.isJsonMime(null));
- assertFalse(apiClient.isJsonMime(""));
- assertFalse(apiClient.isJsonMime("text/plain"));
- assertFalse(apiClient.isJsonMime("application/xml"));
- assertFalse(apiClient.isJsonMime("application/jsonp"));
+ assertFalse(apiClient.isJsonMime(null));
+ assertFalse(apiClient.isJsonMime(""));
+ assertFalse(apiClient.isJsonMime("text/plain"));
+ assertFalse(apiClient.isJsonMime("application/xml"));
+ assertFalse(apiClient.isJsonMime("application/jsonp"));
+ assertFalse(apiClient.isJsonMime("example/json"));
+ assertFalse(apiClient.isJsonMime("example/foo+bar+jsonx"));
+ assertFalse(apiClient.isJsonMime("example/foo+bar+xjson"));
- assertTrue(apiClient.isJsonMime("application/json"));
- assertTrue(apiClient.isJsonMime("application/json; charset=UTF8"));
- assertTrue(apiClient.isJsonMime("APPLICATION/JSON"));
+ assertTrue(apiClient.isJsonMime("application/json"));
+ assertTrue(apiClient.isJsonMime("application/json; charset=UTF8"));
+ assertTrue(apiClient.isJsonMime("APPLICATION/JSON"));
+
+ assertTrue(apiClient.isJsonMime("application/problem+json"));
+ assertTrue(apiClient.isJsonMime("APPLICATION/PROBLEM+JSON"));
+ assertTrue(apiClient.isJsonMime("application/json\t"));
+ assertTrue(apiClient.isJsonMime("example/foo+bar+json"));
+ assertTrue(apiClient.isJsonMime("example/foo+json;x;y"));
+ assertTrue(apiClient.isJsonMime("example/foo+json\t;"));
+ assertTrue(apiClient.isJsonMime("Example/fOO+JSON"));
}
@Test
diff --git a/samples/server/petstore/nodejs-google-cloud-functions/api/swagger.yaml b/samples/server/petstore/nodejs-google-cloud-functions/api/swagger.yaml
index a2b8cd0f5ccd..ced8e85705be 100644
--- a/samples/server/petstore/nodejs-google-cloud-functions/api/swagger.yaml
+++ b/samples/server/petstore/nodejs-google-cloud-functions/api/swagger.yaml
@@ -108,11 +108,11 @@ paths:
type: "array"
items:
type: "string"
+ default: "available"
enum:
- "available"
- "pending"
- "sold"
- default: "available"
collectionFormat: "csv"
responses:
200:
diff --git a/samples/server/petstore/nodejs/api/swagger.yaml b/samples/server/petstore/nodejs/api/swagger.yaml
index a2b8cd0f5ccd..ced8e85705be 100644
--- a/samples/server/petstore/nodejs/api/swagger.yaml
+++ b/samples/server/petstore/nodejs/api/swagger.yaml
@@ -108,11 +108,11 @@ paths:
type: "array"
items:
type: "string"
+ default: "available"
enum:
- "available"
- "pending"
- "sold"
- default: "available"
collectionFormat: "csv"
responses:
200:
diff --git a/samples/server/petstore/nodejs/index.js b/samples/server/petstore/nodejs/index.js
index aaa873a128ae..2310e7b2fd85 100644
--- a/samples/server/petstore/nodejs/index.js
+++ b/samples/server/petstore/nodejs/index.js
@@ -1,25 +1,28 @@
'use strict';
+var fs = require('fs'),
+ path = require('path'),
+ http = require('http');
+
var app = require('connect')();
-var http = require('http');
var swaggerTools = require('swagger-tools');
var jsyaml = require('js-yaml');
-var fs = require('fs');
var serverPort = 8080;
// swaggerRouter configuration
var options = {
- swaggerUi: '/swagger.json',
- controllers: './controllers',
- useStubs: process.env.NODE_ENV === 'development' ? true : false // Conditionally turn on stubs (mock mode)
+ swaggerUi: path.join(__dirname, '/swagger.json'),
+ controllers: path.join(__dirname, './controllers'),
+ useStubs: process.env.NODE_ENV === 'development' // Conditionally turn on stubs (mock mode)
};
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
-var spec = fs.readFileSync('./api/swagger.yaml', 'utf8');
+var spec = fs.readFileSync(path.join(__dirname,'api/swagger.yaml'), 'utf8');
var swaggerDoc = jsyaml.safeLoad(spec);
// Initialize the Swagger middleware
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
+
// Interpret Swagger resources and attach metadata to request - must be first in swagger-tools middleware chain
app.use(middleware.swaggerMetadata());
@@ -37,4 +40,5 @@ swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort);
console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort);
});
+
});