diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java index 20f5c7b0a47..cfae5b1a588 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java @@ -393,7 +393,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code } else if (ModelUtils.isObjectSchema(p)) { example = example.isEmpty() ? "null" : example; } else { - example = super.toExampleValue(p); + example = getTypeDeclaration(p) + ".getExample()"; } return example; } @@ -462,7 +462,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code cm.vendorExtensions.put("propertyMappings", propertyMappings); if (!propertyMappings.isEmpty()) { - cm.interfaces.add("Swagger.MappedProperties"); + cm.interfaces.add("OAS.MappedProperties"); } return cm; } @@ -565,24 +565,6 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code @Override public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions, OpenAPI openAPI) { - /* TODO the following logic revised. Maybe we should simply use the consumes, produces provided by the spec - Boolean hasFormParams = false; - for (Parameter p : operation.getParameters()) { - if ("formData".equals(p.getIn())) { - hasFormParams = true; - break; - } - } - - // only support serialization into JSON and urlencoded forms for now - operation.setConsumes( - Collections.singletonList(hasFormParams - ? "application/x-www-form-urlencoded" - : "application/json")); - - // only support deserialization from JSON for now - operation.setProduces(Collections.singletonList("application/json")); - */ CodegenOperation op = super.fromOperation( path, httpMethod, operation, definitions, openAPI); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ApexClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ApexClientCodegen.java index 80a240cc3cb..8af857cc287 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ApexClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ApexClientCodegen.java @@ -36,7 +36,7 @@ public class ApexClientCodegen extends AbstractApexCodegen { private static final String BUILD_METHOD = "buildMethod"; private static final String NAMED_CREDENTIAL = "namedCredential"; private static final Logger LOGGER = LoggerFactory.getLogger(ApexClientCodegen.class); - private String classPrefix = "Swag"; + private String classPrefix = "OAS"; private String apiVersion = "42.0"; private String buildMethod = "sfdx"; private String namedCredential = classPrefix; @@ -69,12 +69,12 @@ public class ApexClientCodegen extends AbstractApexCodegen { cliOptions.add(CliOption.newString(BUILD_METHOD, "The build method for this package.")); cliOptions.add(CliOption.newString(NAMED_CREDENTIAL, "The named credential name for the HTTP callouts")); - supportingFiles.add(new SupportingFile("Swagger.cls", srcPath + "classes", "Swagger.cls")); - supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", "Swagger.cls-meta.xml")); - supportingFiles.add(new SupportingFile("SwaggerTest.cls", srcPath + "classes", "SwaggerTest.cls")); - supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", "SwaggerTest.cls-meta.xml")); - supportingFiles.add(new SupportingFile("SwaggerResponseMock.cls", srcPath + "classes", "SwaggerResponseMock.cls")); - supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", "SwaggerResponseMock.cls-meta.xml")); + supportingFiles.add(new SupportingFile("OAS.cls", srcPath + "classes", "OAS.cls")); + supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", "OAS.cls-meta.xml")); + supportingFiles.add(new SupportingFile("OASTest.cls", srcPath + "classes", "OASTest.cls")); + supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", "OASTest.cls-meta.xml")); + supportingFiles.add(new SupportingFile("OASResponseMock.cls", srcPath + "classes", "OASResponseMock.cls")); + supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", "OASResponseMock.cls-meta.xml")); typeMapping.put("BigDecimal", "Double"); typeMapping.put("binary", "String"); @@ -248,8 +248,6 @@ public class ApexClientCodegen extends AbstractApexCodegen { public void setBuildMethod(String buildMethod) { if (buildMethod.equals("ant")) { this.srcPath = "deploy/"; - } else { - this.srcPath = "src/"; } this.buildMethod = buildMethod; } diff --git a/modules/openapi-generator/src/main/resources/apex/Swagger.cls b/modules/openapi-generator/src/main/resources/apex/OAS.cls similarity index 99% rename from modules/openapi-generator/src/main/resources/apex/Swagger.cls rename to modules/openapi-generator/src/main/resources/apex/OAS.cls index bb4e44f7971..d7f4c6053ce 100644 --- a/modules/openapi-generator/src/main/resources/apex/Swagger.cls +++ b/modules/openapi-generator/src/main/resources/apex/OAS.cls @@ -1,4 +1,4 @@ -public class Swagger { +public class OAS { private static final String HEADER_CONTENT_TYPE = 'Content-Type'; private static final String HEADER_ACCEPT = 'Accept'; private static final String HEADER_ACCEPT_DELIMITER = ','; diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls b/modules/openapi-generator/src/main/resources/apex/OASResponseMock.cls similarity index 72% rename from samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls rename to modules/openapi-generator/src/main/resources/apex/OASResponseMock.cls index 7d3acb1a91f..a6931145c52 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls +++ b/modules/openapi-generator/src/main/resources/apex/OASResponseMock.cls @@ -1,9 +1,9 @@ @isTest -public class SwaggerResponseMock implements HttpCalloutMock { +public class OASResponseMock implements HttpCalloutMock { private final HttpResponse response; private HttpRequest request; - public SwaggerResponseMock(HttpResponse response) { + public OASResponseMock(HttpResponse response) { this.response = response; } diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls b/modules/openapi-generator/src/main/resources/apex/OASTest.cls similarity index 83% rename from samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls rename to modules/openapi-generator/src/main/resources/apex/OASTest.cls index d95e9b60aa8..e1c73d185e4 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls +++ b/modules/openapi-generator/src/main/resources/apex/OASTest.cls @@ -1,19 +1,19 @@ @isTest -private class SwaggerTest { +private class OASTest { @isTest private static void Param_urlEncodeKeyValuePairUtf8() { String toEncodeLeft = 'Hello +%-_.!~*\'()@'; String toEncodeRight = 'World +%-_.!~*\'()@'; String expected = 'Hello+%2B%25-_.%21%7E*%27%28%29%40=World+%2B%25-_.%21%7E*%27%28%29%40'; - String result = new Swagger.Param(toEncodeLeft, toEncodeRight).toString(); + String result = new OAS.Param(toEncodeLeft, toEncodeRight).toString(); System.assertEquals(expected, result); } @isTest private static void ApiKeyHeaderAuth_keyInHeaderWithGivenName() { Map headers = new Map(); - List query = new List(); - Swagger.ApiKeyHeaderAuth auth = new Swagger.ApiKeyHeaderAuth('X-Authenticate'); + List query = new List(); + OAS.ApiKeyHeaderAuth auth = new OAS.ApiKeyHeaderAuth('X-Authenticate'); auth.setApiKey('foo-bar-api-key'); auth.apply(headers, query); @@ -25,8 +25,8 @@ private class SwaggerTest { @isTest private static void ApiKeyQueryAuth_keyInQueryParamWithGivenName() { Map headers = new Map(); - List query = new List(); - Swagger.ApiKeyQueryAuth auth = new Swagger.ApiKeyQueryAuth('auth_token'); + List query = new List(); + OAS.ApiKeyQueryAuth auth = new OAS.ApiKeyQueryAuth('auth_token'); auth.setApiKey('foo-bar-api-key'); auth.apply(headers, query); @@ -38,8 +38,8 @@ private class SwaggerTest { @isTest private static void ApiClient_returnAuthenticationMatchingInput() { MockApiClient client = new MockApiClient(); - Swagger.ApiKeyHeaderAuth auth1 = new Swagger.ApiKeyHeaderAuth('foo'); - Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('foo'); + OAS.ApiKeyHeaderAuth auth1 = new OAS.ApiKeyHeaderAuth('foo'); + OAS.ApiKeyQueryAuth auth2 = new OAS.ApiKeyQueryAuth('foo'); client.authentications.put('auth1', auth1); client.authentications.put('auth2', auth2); @@ -51,8 +51,8 @@ private class SwaggerTest { @isTest private static void ApiClient_oneKeyValuePairForEachValueInList() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParams('foo', values); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParams('foo', values); System.assertEquals(5, params.size()); System.assertEquals('foo=bar', params.get(0).toString()); @@ -64,8 +64,8 @@ private class SwaggerTest { @isTest private static void ApiClient_nullMultiValuesListToEmptyParamsList() { - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParams('foo', null); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParams('foo', null); System.assert(params.isEmpty()); } @@ -73,8 +73,8 @@ private class SwaggerTest { @isTest private static void ApiClient_valuesListToSingleCsvKeyValuePair() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'csv'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', values, 'csv'); System.assertEquals(1, params.size()); System.assertEquals('foo=bar%2C4%2Cfalse%2C12.4%2C', params.get(0).toString()); @@ -83,8 +83,8 @@ private class SwaggerTest { @isTest private static void ApiClient_valuesListToSingleSsvKeyValuePair() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'ssv'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', values, 'ssv'); System.assertEquals(1, params.size()); System.assertEquals('foo=bar+4+false+12.4+', params.get(0).toString()); @@ -93,8 +93,8 @@ private class SwaggerTest { @isTest private static void ApiClient_valuesListToSingleTsvKeyValuePair() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'tsv'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', values, 'tsv'); System.assertEquals(1, params.size()); System.assertEquals('foo=bar%094%09false%0912.4%09', params.get(0).toString()); @@ -103,8 +103,8 @@ private class SwaggerTest { @isTest private static void ApiClient_valuesListToSinglePipeSeparatedKeyValuePair() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'pipes'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', values, 'pipes'); System.assertEquals(1, params.size()); System.assertEquals('foo=bar%7C4%7Cfalse%7C12.4%7C', params.get(0).toString()); @@ -112,16 +112,16 @@ private class SwaggerTest { @isTest private static void ApiClient_nullValuesListToEmptyParamsList() { - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', null, 'csv'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', null, 'csv'); System.assert(params.isEmpty()); } @isTest private static void ApiClient_paramsFromAnyPrimitiveTypeDiscardNull() { - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = new List(); + OAS.ApiClient client = new OAS.ApiClient(); + List params = new List(); params.addAll(client.makeParam('foo', 'bar')); params.addAll(client.makeParam('foo', 10)); params.addAll(client.makeParam('foo', 12.6)); @@ -141,13 +141,13 @@ private class SwaggerTest { @isTest private static void ApiClient_requiredParameterPasses() { - Swagger.ApiClient client = new Swagger.ApiClient(); + OAS.ApiClient client = new OAS.ApiClient(); client.assertNotNull('foo', 'bar'); } @isTest private static void ApiClient_requiredParameterFails() { - Swagger.ApiClient client = new Swagger.ApiClient(); + OAS.ApiClient client = new OAS.ApiClient(); try { client.assertNotNull(null, 'bar'); } catch (NullPointerException e) { @@ -217,7 +217,7 @@ private class SwaggerTest { '"bat":false' }; Set actual1 = new Set(client - .toBody('application/json', body1, new List()) + .toBody('application/json', body1, new List()) .removeStart('{') .removeEnd('}') .split(',') @@ -225,12 +225,12 @@ private class SwaggerTest { System.assertEquals(expected1, actual1); String body2 = 'Hello, World!'; - String actual2 = client.toBody('text/plain', body2, new List()); + String actual2 = client.toBody('text/plain', body2, new List()); System.assertEquals(body2, actual2); - List form = new List{ - new Swagger.Param('hello', 'world'), - new Swagger.Param('date', '2017-01-01 15:00:00') + List form = new List{ + new OAS.Param('hello', 'world'), + new OAS.Param('date', '2017-01-01 15:00:00') }; String expected3 = 'hello=world&date=2017-01-01+15%3A00%3A00'; String actual3 = client.toBody('application/x-www-form-urlencoded', '', form); @@ -288,9 +288,9 @@ private class SwaggerTest { MockApiClient client = new MockApiClient(); String path = '/departments/{department}'; Map params = new Map{'department' => 'finance'}; - List queryParams = new List{ - new Swagger.Param('foo', 'bar'), - new Swagger.Param('bat', '123') + List queryParams = new List{ + new OAS.Param('foo', 'bar'), + new OAS.Param('bat', '123') }; String expected = 'callout:Winkelmeyer/departments/finance?foo=bar&bat=123'; String actual = client.toEndpoint(path, params, queryParams); @@ -301,7 +301,7 @@ private class SwaggerTest { private static void ApiClient_returnParsedBody() { MockApiClient client = new MockApiClient(); HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); + OASResponseMock mock = new OASResponseMock(res); Test.setMock(HttpCalloutMock.class, mock); res.setStatus('OK'); @@ -314,8 +314,8 @@ private class SwaggerTest { Address a = (Address) client.invoke( 'GET', '/address', '', - new List(), - new List(), + new List(), + new List(), new Map(), new Map(), new List{'application/json'}, @@ -337,7 +337,7 @@ private class SwaggerTest { private static void ApiClient_noReturnTypeReturnsNull() { MockApiClient client = new MockApiClient(); HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); + OASResponseMock mock = new OASResponseMock(res); Test.setMock(HttpCalloutMock.class, mock); res.setStatus('OK'); @@ -345,8 +345,8 @@ private class SwaggerTest { Object o = client.invoke( 'POST', '/address', '', - new List(), - new List(), + new List(), + new List(), new Map(), new Map(), new List{'application/json'}, @@ -358,7 +358,7 @@ private class SwaggerTest { System.assertEquals(null, o); } - private class MockApiClient extends Swagger.ApiClient { + private class MockApiClient extends OAS.ApiClient { public MockApiClient() { basePath = 'https://blog.winkelmeyer.com'; calloutName = 'Winkelmeyer'; diff --git a/modules/openapi-generator/src/main/resources/apex/README_ant.mustache b/modules/openapi-generator/src/main/resources/apex/README_ant.mustache index 53f2bf4fc1f..6faaa3e55fe 100644 --- a/modules/openapi-generator/src/main/resources/apex/README_ant.mustache +++ b/modules/openapi-generator/src/main/resources/apex/README_ant.mustache @@ -116,7 +116,7 @@ HttpBasicAuth {{{name}}} = (HttpBasicAuth) client.getAuthentication('{{{name}}}' ApiKeyAuth {{{name}}} = (ApiKeyAuth) client.getAuthentication('{{{name}}}'); {{{name}}}.setApiKey('YOUR API KEY');{{/isApiKey}}{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} -Swagger.OAuth {{{name}}} = (Swagger.OAuth) client.getAuthentication('{{{name}}}'); +OAS.OAuth {{{name}}} = (OAS.OAuth) client.getAuthentication('{{{name}}}'); {{{name}}}.setAccessToken('YOUR ACCESS TOKEN');{{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} @@ -135,7 +135,7 @@ try { {{#returnType}} System.debug(result); {{/returnType}} -} catch (Swagger.ApiException e) { +} catch (OAS.ApiException e) { // ...handle your exceptions }{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} ``` diff --git a/modules/openapi-generator/src/main/resources/apex/README_sfdx.mustache b/modules/openapi-generator/src/main/resources/apex/README_sfdx.mustache index c65a0d10b77..82628bae77d 100644 --- a/modules/openapi-generator/src/main/resources/apex/README_sfdx.mustache +++ b/modules/openapi-generator/src/main/resources/apex/README_sfdx.mustache @@ -67,7 +67,7 @@ try { {{#returnType}} System.debug(result); {{/returnType}} -} catch (Swagger.ApiException e) { +} catch (OAS.ApiException e) { // ...handle your exceptions }{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} ``` diff --git a/modules/openapi-generator/src/main/resources/apex/api.mustache b/modules/openapi-generator/src/main/resources/apex/api.mustache index 700c66eb15c..7cd21f0ea79 100644 --- a/modules/openapi-generator/src/main/resources/apex/api.mustache +++ b/modules/openapi-generator/src/main/resources/apex/api.mustache @@ -25,7 +25,7 @@ public class {{classname}} { {{#returnType}} * @return {{{returnType}}} {{/returnType}} - * @throws Swagger.ApiException if fails to make API call + * @throws OAS.ApiException if fails to make API call */ public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#hasParams}}Map params{{/hasParams}}) { {{#allParams}} @@ -33,7 +33,7 @@ public class {{classname}} { client.assertNotNull(params.get('{{paramName}}'), '{{paramName}}'); {{/required}} {{/allParams}} - List query = new List(); + List query = new List(); {{#hasQueryParams}} // cast query params to verify their expected type @@ -54,7 +54,7 @@ public class {{classname}} { {{/hasMore}} {{/queryParams}} - List form = new List(); + List form = new List(); {{#hasFormParams}} // cast form params to verify their expected type diff --git a/modules/openapi-generator/src/main/resources/apex/api_doc.mustache b/modules/openapi-generator/src/main/resources/apex/api_doc.mustache index 5a639d29506..947c5607021 100644 --- a/modules/openapi-generator/src/main/resources/apex/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/apex/api_doc.mustache @@ -35,7 +35,7 @@ HttpBasicAuth {{{name}}} = (HttpBasicAuth) client.getAuthentication('{{{name}}}' ApiKeyAuth {{{name}}} = (ApiKeyAuth) client.getAuthentication('{{{name}}}'); {{{name}}}.setApiKey('YOUR API KEY');{{/isApiKey}}{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} -Swagger.OAuth {{{name}}} = (Swagger.OAuth) client.getAuthentication('{{{name}}}'); +OAS.OAuth {{{name}}} = (OAS.OAuth) client.getAuthentication('{{{name}}}'); {{{name}}}.setAccessToken('YOUR ACCESS TOKEN');{{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} @@ -54,7 +54,7 @@ try { {{#returnType}} System.debug(result); {{/returnType}} -} catch (Swagger.ApiException e) { +} catch (OAS.ApiException e) { // ...handle your exceptions } ``` diff --git a/modules/openapi-generator/src/main/resources/apex/api_test.mustache b/modules/openapi-generator/src/main/resources/apex/api_test.mustache index c5db4898998..440abb9d70b 100644 --- a/modules/openapi-generator/src/main/resources/apex/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/apex/api_test.mustache @@ -18,7 +18,7 @@ private class {{classname}}Test { res.setStatusCode(200); res.setStatus('OK'); {{/restfulCreate}} - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); {{#hasParams}} Map params = new Map{ @@ -39,7 +39,7 @@ private class {{classname}}Test { {{#authMethods}} client = new {{classPrefix}}Client(); api = new {{classname}}(client);{{#isApiKey}} - ((Swagger.ApiKeyAuth)client.getAuthentication('{{name}}')).setApiKey('foo-bar-api-key'); + ((OAS.ApiKeyAuth)client.getAuthentication('{{name}}')).setApiKey('foo-bar-api-key'); {{/isApiKey}} {{#examples}} diff --git a/modules/openapi-generator/src/main/resources/apex/build.mustache b/modules/openapi-generator/src/main/resources/apex/build.mustache index beb0fd0b326..31496fae358 100644 --- a/modules/openapi-generator/src/main/resources/apex/build.mustache +++ b/modules/openapi-generator/src/main/resources/apex/build.mustache @@ -62,7 +62,7 @@ {{classname}}Test {{/model}} {{/models}} - SwaggerTest + OASTest @@ -92,7 +92,7 @@ {{classname}}Test {{/model}} {{/models}} - SwaggerTest + OASTest diff --git a/modules/openapi-generator/src/main/resources/apex/client.mustache b/modules/openapi-generator/src/main/resources/apex/client.mustache index fe5ba4f77bb..d2daf5f44f8 100644 --- a/modules/openapi-generator/src/main/resources/apex/client.mustache +++ b/modules/openapi-generator/src/main/resources/apex/client.mustache @@ -1,4 +1,4 @@ -public class {{classPrefix}}Client extends Swagger.ApiClient { +public class {{classPrefix}}Client extends OAS.ApiClient { {{#hasAuthMethods}} public {{classPrefix}}Client() { basePath = '{{basePath}}'; @@ -6,10 +6,10 @@ public class {{classPrefix}}Client extends Swagger.ApiClient { {{#authMethods}} {{#isApiKey}} {{#isKeyInQuery}} - authentications.put('{{name}}', new Swagger.ApiKeyQueryAuth('{{keyParamName}}')); + authentications.put('{{name}}', new OAS.ApiKeyQueryAuth('{{keyParamName}}')); {{/isKeyInQuery}} {{^isKeyInQuery}} - authentications.put('{{name}}', new Swagger.ApiKeyHeaderAuth('{{keyParamName}}')); + authentications.put('{{name}}', new OAS.ApiKeyHeaderAuth('{{keyParamName}}')); {{/isKeyInQuery}} {{/isApiKey}} {{/authMethods}} diff --git a/modules/openapi-generator/src/main/resources/apex/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/apex/git_push.sh.mustache index e153ce23ecf..1de48af66eb 100644 --- a/modules/openapi-generator/src/main/resources/apex/git_push.sh.mustache +++ b/modules/openapi-generator/src/main/resources/apex/git_push.sh.mustache @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 OAS-petstore-perl "minor update" git_user_id=$1 git_repo_id=$2 diff --git a/modules/openapi-generator/src/main/resources/apex/licenseInfo.mustache b/modules/openapi-generator/src/main/resources/apex/licenseInfo.mustache index 94c36dda3af..dbb69eb6426 100644 --- a/modules/openapi-generator/src/main/resources/apex/licenseInfo.mustache +++ b/modules/openapi-generator/src/main/resources/apex/licenseInfo.mustache @@ -5,7 +5,7 @@ * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ diff --git a/modules/openapi-generator/src/main/resources/apex/package.mustache b/modules/openapi-generator/src/main/resources/apex/package.mustache index e13680359ba..cee19208383 100644 --- a/modules/openapi-generator/src/main/resources/apex/package.mustache +++ b/modules/openapi-generator/src/main/resources/apex/package.mustache @@ -3,7 +3,7 @@ {{appName}} API Client Client library for calling the {{appName}} API.{{#appDescription}} {{{appDescription}}}{{/appDescription}} -Generated with Swagger Codegen (github.com/swagger-api/swagger-codegen) +Generated with OAS Codegen (github.com/OAS-api/OAS-codegen) {{#apiInfo}} {{#apis}} @@ -18,9 +18,9 @@ Generated with Swagger Codegen (github.com/swagger-api/swagger-codegen){{classPrefix}}Client - Swagger - SwaggerTest - SwaggerResponseMock + OAS + OASTest + OASResponseMock ApexClass diff --git a/samples/client/petstore/apex/.gitignore b/samples/client/petstore/apex/.gitignore deleted file mode 100644 index c206f2e86e8..00000000000 --- a/samples/client/petstore/apex/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -*DS_Store* - -/Referenced Packages -/salesforce.schema - -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath -.recommenders - -# Eclipse -.project -.externalToolBuilders/ -*.launch - -*.iml -.idea - -*.sublime* -config diff --git a/samples/client/petstore/apex/.openapi-generator-ignore b/samples/client/petstore/apex/.openapi-generator-ignore index c5fa491b4c5..7484ee590a3 100644 --- a/samples/client/petstore/apex/.openapi-generator-ignore +++ b/samples/client/petstore/apex/.openapi-generator-ignore @@ -1,11 +1,11 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator # Use this file to prevent files from being overwritten by the generator. # The patterns follow closely to .gitignore or .dockerignore. # As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: #ApiClient.cs # You can match any string of characters against a directory, file or extension with a single asterisk (*): diff --git a/samples/client/petstore/apex/.swagger-codegen/VERSION b/samples/client/petstore/apex/.swagger-codegen/VERSION deleted file mode 100644 index 855ff9501eb..00000000000 --- a/samples/client/petstore/apex/.swagger-codegen/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/apex/README.md b/samples/client/petstore/apex/README.md index f0f31cf6692..a1481aea075 100644 --- a/samples/client/petstore/apex/README.md +++ b/samples/client/petstore/apex/README.md @@ -1,119 +1,59 @@ -# Swagger Petstore API Client +# OpenAPI Petstore API Client -This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. ## Requirements -- [Java 8 JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html) -- [Apache Ant](http://ant.apache.org/) version 1.6 or later -- [Force.com Migration Tool](https://developer.salesforce.com/docs/atlas.en-us.daas.meta/daas/forcemigrationtool_install.htm) - - The `ant-salesforce.jar` file included with the Force.com Migration Tool must be placed in the root directory of this project (in the same directory as this README and `build.xml`) -- `ANT_HOME` and `JAVA_HOME` environment variables must be set accordingly - - On Windows, `JAVA_HOME` will probably look something like this: +- [Salesforce DX](https://www.salesforce.com/products/platform/products/salesforce-dx/) - ``` - JAVA_HOME = C:\Program Files\Java\jdk1.8.0_121 - ``` - -- The `bin` directory from Ant must be on your `PATH` If everything is set correctly: -- Running `java -version` in a command prompt should output something like: +- Running `sfdx version` in a command prompt should output something like: ```bash - java version "1.8.0_121" - Java(TM) SE Runtime Environment (build 1.8.0_121-b13) - Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode) + sfdx-cli/5.7.5-05549de (darwin-amd64) go1.7.5 sfdxstable ``` -- Running `ant -version` should output something like: - - ```bash - Apache Ant(TM) version 1.10.1 compiled on February 2 2017 - ``` - -For more information, see ## Installation +1. Copy the output into your Salesforce DX folder - or alternatively deploy the output directly into the workspace. +2. Deploy the code via Salesforce DX to your Scratch Org -1. Clone the repo from GitHub + ```bash + $ sfdx force:source:push + ``` +3. If the API needs authentication update the Named Credential in Setup. +4. Run your Apex tests using ```bash - $ git clone git@github.com:GIT_USER_ID/GIT_REPO_ID.git + $ sfdx sfdx force:apex:test:run ``` +5. Retrieve the job id from the console and check the test results. - Or, [download](https://github.com/GIT_USER_ID/GIT_REPO_ID/archive/master.zip) the repo as a ZIP and extract it to `GIT_REPO_ID` + ```bash + $ sfdx force:apex:test:report -i theJobId + ``` -1. Set the `SF_USERNAME` and `SF_PASSWORD` environment variables to your Salesforce username and password. Alternatively, they may be set in `build.properties`. Environment variables will override the values in `build.properties` if set. - - `SF_SESSIONID` may also be set instead of `SF_USERNAME` and `SF_PASSWORD` (more info in `build.properties`) - -2. Open up a command prompt in the root project directory `GIT_REPO_ID` (the same directory as this README and `build.xml`) -3. Deploy to your Salesforce org - - ```bash - $ ant deploy - ``` - - This command will: - - - deploy all classes in the `deploy/classes` directory to your Salesforce org - - create a new [unmanaged package](https://help.salesforce.com/articleView?id=sharing_apps.htm) called **Swagger Petstore API Client** - - execute all of the unit tests included in this package (at least 75% code coverage required) - - create a new [remote site](https://help.salesforce.com/articleView?id=configuring_remoteproxy.htm) called **Swagger_Petstore** configured for the endpoint: - - rolls back any changes upon any error - - A successful deployment will look like this: - - ```bash - [sf:deploy] Request Status: Succeeded - [sf:deploy] *********** DEPLOYMENT SUCCEEDED *********** - [sf:deploy] Finished request 0Af7A00000Ebd5oSAB successfully. - - BUILD SUCCESSFUL - Total time: 34 seconds - ``` - -### Test deployment only - -To perform a test deployment without committing changes: - -```bash -$ ant deployCheckOnly -``` - -All of the included tests will run as if it were a real deployment. Tests and other validations will report back while leaving your org untouched, allowing you to verify that a deployment will succeed without affecting anything in the org. - -### Uninstallation - -```bash -$ ant undeploy -``` - -Removes all classes and the Remote Site created by this package. ## Getting Started Please follow the [installation](#installation) instruction and execute the following Apex code: ```java -SwagPetApi api = new SwagPetApi(); -SwagClient client = api.getClient(); +OASPetApi api = new OASPetApi(); +OASClient client = api.getClient(); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger.OAuth petstore_auth = (Swagger.OAuth) client.getAuthentication('petstore_auth'); -petstore_auth.setAccessToken('YOUR ACCESS TOKEN'); Map params = new Map{ - 'body' => SwagPet.getExample() + 'oaSPet' => OASPet.getExample() }; try { // cross your fingers api.addPet(params); -} catch (Swagger.ApiException e) { +} catch (OAS.ApiException e) { // ...handle your exceptions } ``` @@ -124,36 +64,36 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*SwagPetApi* | [**addPet**](docs/SwagPetApi.md#addPet) | **POST** /pet | Add a new pet to the store -*SwagPetApi* | [**deletePet**](docs/SwagPetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -*SwagPetApi* | [**findPetsByStatus**](docs/SwagPetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -*SwagPetApi* | [**findPetsByTags**](docs/SwagPetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -*SwagPetApi* | [**getPetById**](docs/SwagPetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -*SwagPetApi* | [**updatePet**](docs/SwagPetApi.md#updatePet) | **PUT** /pet | Update an existing pet -*SwagPetApi* | [**updatePetWithForm**](docs/SwagPetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -*SwagPetApi* | [**uploadFile**](docs/SwagPetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image -*SwagStoreApi* | [**deleteOrder**](docs/SwagStoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*SwagStoreApi* | [**getInventory**](docs/SwagStoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -*SwagStoreApi* | [**getOrderById**](docs/SwagStoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -*SwagStoreApi* | [**placeOrder**](docs/SwagStoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet -*SwagUserApi* | [**createUser**](docs/SwagUserApi.md#createUser) | **POST** /user | Create user -*SwagUserApi* | [**createUsersWithArrayInput**](docs/SwagUserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -*SwagUserApi* | [**createUsersWithListInput**](docs/SwagUserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -*SwagUserApi* | [**deleteUser**](docs/SwagUserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -*SwagUserApi* | [**getUserByName**](docs/SwagUserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -*SwagUserApi* | [**loginUser**](docs/SwagUserApi.md#loginUser) | **GET** /user/login | Logs user into the system -*SwagUserApi* | [**logoutUser**](docs/SwagUserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -*SwagUserApi* | [**updateUser**](docs/SwagUserApi.md#updateUser) | **PUT** /user/{username} | Updated user +*OASPetApi* | [**addPet**](OASPetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*OASPetApi* | [**deletePet**](OASPetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*OASPetApi* | [**findPetsByStatus**](OASPetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*OASPetApi* | [**findPetsByTags**](OASPetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*OASPetApi* | [**getPetById**](OASPetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*OASPetApi* | [**updatePet**](OASPetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*OASPetApi* | [**updatePetWithForm**](OASPetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +*OASPetApi* | [**uploadFile**](OASPetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +*OASStoreApi* | [**deleteOrder**](OASStoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*OASStoreApi* | [**getInventory**](OASStoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*OASStoreApi* | [**getOrderById**](OASStoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*OASStoreApi* | [**placeOrder**](OASStoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*OASUserApi* | [**createUser**](OASUserApi.md#createUser) | **POST** /user | Create user +*OASUserApi* | [**createUsersWithArrayInput**](OASUserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*OASUserApi* | [**createUsersWithListInput**](OASUserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*OASUserApi* | [**deleteUser**](OASUserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*OASUserApi* | [**getUserByName**](OASUserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*OASUserApi* | [**loginUser**](OASUserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*OASUserApi* | [**logoutUser**](OASUserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*OASUserApi* | [**updateUser**](OASUserApi.md#updateUser) | **PUT** /user/{username} | Updated user ## Documentation for Models - - [SwagApiResponse](docs/SwagApiResponse.md) - - [SwagCategory](docs/SwagCategory.md) - - [SwagOrder](docs/SwagOrder.md) - - [SwagPet](docs/SwagPet.md) - - [SwagTag](docs/SwagTag.md) - - [SwagUser](docs/SwagUser.md) + - [OASApiResponse](OASApiResponse.md) + - [OASCategory](OASCategory.md) + - [OASOrder](OASOrder.md) + - [OASPet](OASPet.md) + - [OASTag](OASTag.md) + - [OASUser](OASUser.md) ## Documentation for Authorization @@ -169,7 +109,7 @@ Authentication schemes defined for the API: - **Type**: OAuth - **Flow**: implicit -- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog - **Scopes**: - write:pets: modify pets in your account - read:pets: read your pets @@ -177,5 +117,5 @@ Authentication schemes defined for the API: ## Author -apiteam@swagger.io + diff --git a/samples/client/petstore/apex/build.properties b/samples/client/petstore/apex/build.properties deleted file mode 100644 index 93b38a78f55..00000000000 --- a/samples/client/petstore/apex/build.properties +++ /dev/null @@ -1,37 +0,0 @@ -# build.properties -# - -# The first three properties (SF_USERNAME, SF_PASSWORD, SF_SESSIONID) may either be specified below -# or set from environment variables of the same names. The remaining non-uppercase properties, which -# have the "sf." prefix (e.g.: sf.serverurl) may only be specified in this file and not from -# environment variables. - -# Required if sessionId isn’t specified. The Salesforce username for login. The username associated -# with this connection must have the “Modify All Data” permission. Typically, this is only enabled -# for System Administrator users. -# -# SF_USERNAME = username@example.com - -# Required if sessionId isn’t specified. The password you use to log in to the org associated with -# this project. If you are using a security token, paste the 25-digit token value to the end of your -# password. -# -# SF_PASSWORD = password123 - -# Required if username and password aren’t specified. The ID of an active Salesforce session or the -# OAuth access token. A session is created after a user logs in to Salesforce successfully with a -# username and password. Use a session ID for logging in to an existing session instead of creating -# a new session. Alternatively, use an access token for OAuth authentication. For more information, -# see Authenticating Apps with OAuth in the Salesforce Help. -# -# SF_SESSIONID = 0000... - -# Optional. The Salesforce server URL (if blank, defaults to login.salesforce.com). To connect to a -# sandbox instance, change this to test.salesforce.com. -# -sf.serverurl = test.salesforce.com - -# Optional. Defaults to 200. The number of times to poll the server for the results of the deploy -# request. Note that deployment can succeed even if you stop waiting. -# -sf.maxPoll = 200 diff --git a/samples/client/petstore/apex/build.xml b/samples/client/petstore/apex/build.xml deleted file mode 100644 index b6c2b201750..00000000000 --- a/samples/client/petstore/apex/build.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SwagPetApiTest - SwagStoreApiTest - SwagUserApiTest - SwagApiResponseTest - SwagCategoryTest - SwagOrderTest - SwagPetTest - SwagTagTest - SwagUserTest - SwaggerTest - - - - - - - - - - - - - SwagPetApiTest - SwagStoreApiTest - SwagUserApiTest - SwagApiResponseTest - SwagCategoryTest - SwagOrderTest - SwagPetTest - SwagTagTest - SwagUserTest - SwaggerTest - - - diff --git a/samples/client/petstore/apex/config/project-scratch-def.json b/samples/client/petstore/apex/config/project-scratch-def.json new file mode 100644 index 00000000000..36aace55266 --- /dev/null +++ b/samples/client/petstore/apex/config/project-scratch-def.json @@ -0,0 +1,8 @@ +{ + "orgName": "muenzpraeger - René Winkelmeyer", + "edition": "Developer", + "orgPreferences": { + "enabled": ["S1DesktopEnabled"], + "disabled": ["S1EncryptedStoragePref2"] + } +} diff --git a/samples/client/petstore/apex/deploy/classes/SwagApiResponse.cls b/samples/client/petstore/apex/deploy/classes/SwagApiResponse.cls deleted file mode 100644 index 8f87c98fd11..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagApiResponse.cls +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * 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. - */ - -/** - * Describes the result of uploading an image resource - */ -public class SwagApiResponse implements Swagger.MappedProperties { - /** - * Get code - * @return code - */ - public Integer code { get; set; } - - /** - * Get r_type - * @return r_type - */ - public String r_type { get; set; } - - /** - * Get message - * @return message - */ - public String message { get; set; } - - private static final Map propertyMappings = new Map{ - 'type' => 'r_type' - }; - - public Map getPropertyMappings() { - return propertyMappings; - } - - public static SwagApiResponse getExample() { - SwagApiResponse apiResponse = new SwagApiResponse(); - apiResponse.code = 123; - apiResponse.r_type = 'aeiou'; - apiResponse.message = 'aeiou'; - return apiResponse; - } - - public Boolean equals(Object obj) { - if (obj instanceof SwagApiResponse) { - SwagApiResponse apiResponse = (SwagApiResponse) obj; - return this.code == apiResponse.code - && this.r_type == apiResponse.r_type - && this.message == apiResponse.message; - } - return false; - } - - public Integer hashCode() { - Integer hashCode = 43; - hashCode = (17 * hashCode) + (code == null ? 0 : System.hashCode(code)); - hashCode = (17 * hashCode) + (r_type == null ? 0 : System.hashCode(r_type)); - hashCode = (17 * hashCode) + (message == null ? 0 : System.hashCode(message)); - return hashCode; - } -} - diff --git a/samples/client/petstore/apex/deploy/classes/SwagApiResponseTest.cls b/samples/client/petstore/apex/deploy/classes/SwagApiResponseTest.cls deleted file mode 100644 index a7095a4f1c2..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagApiResponseTest.cls +++ /dev/null @@ -1,87 +0,0 @@ -@isTest -private class SwagApiResponseTest { - @isTest - private static void equalsSameInstance() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = apiResponse1; - SwagApiResponse apiResponse3 = new SwagApiResponse(); - SwagApiResponse apiResponse4 = apiResponse3; - - System.assert(apiResponse1.equals(apiResponse2)); - System.assert(apiResponse2.equals(apiResponse1)); - System.assert(apiResponse1.equals(apiResponse1)); - System.assert(apiResponse3.equals(apiResponse4)); - System.assert(apiResponse4.equals(apiResponse3)); - System.assert(apiResponse3.equals(apiResponse3)); - } - - @isTest - private static void equalsIdenticalInstance() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse3 = new SwagApiResponse(); - SwagApiResponse apiResponse4 = new SwagApiResponse(); - - System.assert(apiResponse1.equals(apiResponse2)); - System.assert(apiResponse2.equals(apiResponse1)); - System.assert(apiResponse3.equals(apiResponse4)); - System.assert(apiResponse4.equals(apiResponse3)); - } - - @isTest - private static void notEqualsUnlikeInstance() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = new SwagApiResponse(); - - System.assertEquals(false, apiResponse1.equals(apiResponse2)); - System.assertEquals(false, apiResponse2.equals(apiResponse1)); - } - - @isTest - private static void notEqualsDifferentType() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = new SwagApiResponse(); - - System.assertEquals(false, apiResponse1.equals('foo')); - System.assertEquals(false, apiResponse2.equals('foo')); - } - - @isTest - private static void notEqualsNull() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = new SwagApiResponse(); - SwagApiResponse apiResponse3; - - System.assertEquals(false, apiResponse1.equals(apiResponse3)); - System.assertEquals(false, apiResponse2.equals(apiResponse3)); - } - - @isTest - private static void consistentHashCodeValue() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = new SwagApiResponse(); - - System.assertEquals(apiResponse1.hashCode(), apiResponse1.hashCode()); - System.assertEquals(apiResponse2.hashCode(), apiResponse2.hashCode()); - } - - @isTest - private static void equalInstancesHaveSameHashCode() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse3 = new SwagApiResponse(); - SwagApiResponse apiResponse4 = new SwagApiResponse(); - - System.assert(apiResponse1.equals(apiResponse2)); - System.assert(apiResponse3.equals(apiResponse4)); - System.assertEquals(apiResponse1.hashCode(), apiResponse2.hashCode()); - System.assertEquals(apiResponse3.hashCode(), apiResponse4.hashCode()); - } - - @isTest - private static void maintainRenamedProperties() { - SwagApiResponse apiResponse = new SwagApiResponse(); - Map propertyMappings = apiResponse.getPropertyMappings(); - System.assertEquals('r_type', propertyMappings.get('type')); - } -} diff --git a/samples/client/petstore/apex/deploy/classes/SwagCategory.cls b/samples/client/petstore/apex/deploy/classes/SwagCategory.cls deleted file mode 100644 index b9e0e81b137..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagCategory.cls +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * 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. - */ - -/** - * A category for a pet - */ -public class SwagCategory { - /** - * Get id - * @return id - */ - public Long id { get; set; } - - /** - * Get name - * @return name - */ - public String name { get; set; } - - public static SwagCategory getExample() { - SwagCategory category = new SwagCategory(); - category.id = 123456789L; - category.name = 'aeiou'; - return category; - } - - public Boolean equals(Object obj) { - if (obj instanceof SwagCategory) { - SwagCategory category = (SwagCategory) obj; - return this.id == category.id - && this.name == category.name; - } - return false; - } - - public Integer hashCode() { - Integer hashCode = 43; - hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); - hashCode = (17 * hashCode) + (name == null ? 0 : System.hashCode(name)); - return hashCode; - } -} - diff --git a/samples/client/petstore/apex/deploy/classes/SwagCategoryTest.cls b/samples/client/petstore/apex/deploy/classes/SwagCategoryTest.cls deleted file mode 100644 index 8689ece6dc5..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagCategoryTest.cls +++ /dev/null @@ -1,80 +0,0 @@ -@isTest -private class SwagCategoryTest { - @isTest - private static void equalsSameInstance() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = category1; - SwagCategory category3 = new SwagCategory(); - SwagCategory category4 = category3; - - System.assert(category1.equals(category2)); - System.assert(category2.equals(category1)); - System.assert(category1.equals(category1)); - System.assert(category3.equals(category4)); - System.assert(category4.equals(category3)); - System.assert(category3.equals(category3)); - } - - @isTest - private static void equalsIdenticalInstance() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = SwagCategory.getExample(); - SwagCategory category3 = new SwagCategory(); - SwagCategory category4 = new SwagCategory(); - - System.assert(category1.equals(category2)); - System.assert(category2.equals(category1)); - System.assert(category3.equals(category4)); - System.assert(category4.equals(category3)); - } - - @isTest - private static void notEqualsUnlikeInstance() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = new SwagCategory(); - - System.assertEquals(false, category1.equals(category2)); - System.assertEquals(false, category2.equals(category1)); - } - - @isTest - private static void notEqualsDifferentType() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = new SwagCategory(); - - System.assertEquals(false, category1.equals('foo')); - System.assertEquals(false, category2.equals('foo')); - } - - @isTest - private static void notEqualsNull() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = new SwagCategory(); - SwagCategory category3; - - System.assertEquals(false, category1.equals(category3)); - System.assertEquals(false, category2.equals(category3)); - } - - @isTest - private static void consistentHashCodeValue() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = new SwagCategory(); - - System.assertEquals(category1.hashCode(), category1.hashCode()); - System.assertEquals(category2.hashCode(), category2.hashCode()); - } - - @isTest - private static void equalInstancesHaveSameHashCode() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = SwagCategory.getExample(); - SwagCategory category3 = new SwagCategory(); - SwagCategory category4 = new SwagCategory(); - - System.assert(category1.equals(category2)); - System.assert(category3.equals(category4)); - System.assertEquals(category1.hashCode(), category2.hashCode()); - System.assertEquals(category3.hashCode(), category4.hashCode()); - } -} diff --git a/samples/client/petstore/apex/deploy/classes/SwagClient.cls b/samples/client/petstore/apex/deploy/classes/SwagClient.cls deleted file mode 100644 index 97804910eda..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagClient.cls +++ /dev/null @@ -1,7 +0,0 @@ -public class SwagClient extends Swagger.ApiClient { - public SwagClient() { - basePath = 'http://petstore.swagger.io/v2'; - authentications.put('api_key', new Swagger.ApiKeyHeaderAuth('api_key')); - authentications.put('petstore_auth', new Swagger.OAuth2()); - } -} diff --git a/samples/client/petstore/apex/deploy/classes/SwagClient.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagClient.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagClient.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagOrder.cls b/samples/client/petstore/apex/deploy/classes/SwagOrder.cls deleted file mode 100644 index 775081a55c8..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagOrder.cls +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * 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. - */ - -/** - * An order for a pets from the pet store - */ -public class SwagOrder { - /** - * Get id - * @return id - */ - public Long id { get; set; } - - /** - * Get petId - * @return petId - */ - public Long petId { get; set; } - - /** - * Get quantity - * @return quantity - */ - public Integer quantity { get; set; } - - /** - * Get shipDate - * @return shipDate - */ - public Datetime shipDate { get; set; } - - /** - * Order Status - */ - public enum StatusEnum { - PLACED, - APPROVED, - DELIVERED - } - - /** - * Order Status - * @return status - */ - public StatusEnum status { get; set; } - - /** - * Get complete - * @return complete - */ - public Boolean complete { get; set; } - - public SwagOrder() { - complete = false; - } - - public static SwagOrder getExample() { - SwagOrder order = new SwagOrder(); - order.id = 123456789L; - order.petId = 123456789L; - order.quantity = 123; - order.shipDate = Datetime.newInstanceGmt(2000, 1, 23, 4, 56, 7); - order.status = StatusEnum.PLACED; - order.complete = true; - return order; - } - - public Boolean equals(Object obj) { - if (obj instanceof SwagOrder) { - SwagOrder order = (SwagOrder) obj; - return this.id == order.id - && this.petId == order.petId - && this.quantity == order.quantity - && this.shipDate == order.shipDate - && this.status == order.status - && this.complete == order.complete; - } - return false; - } - - public Integer hashCode() { - Integer hashCode = 43; - hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); - hashCode = (17 * hashCode) + (petId == null ? 0 : System.hashCode(petId)); - hashCode = (17 * hashCode) + (quantity == null ? 0 : System.hashCode(quantity)); - hashCode = (17 * hashCode) + (shipDate == null ? 0 : System.hashCode(shipDate)); - hashCode = (17 * hashCode) + (status == null ? 0 : System.hashCode(status)); - hashCode = (17 * hashCode) + (complete == null ? 0 : System.hashCode(complete)); - return hashCode; - } -} - diff --git a/samples/client/petstore/apex/deploy/classes/SwagOrder.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagOrder.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagOrder.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagOrderTest.cls b/samples/client/petstore/apex/deploy/classes/SwagOrderTest.cls deleted file mode 100644 index 090eea45e5e..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagOrderTest.cls +++ /dev/null @@ -1,91 +0,0 @@ -@isTest -private class SwagOrderTest { - @isTest - private static void equalsSameInstance() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = order1; - SwagOrder order3 = new SwagOrder(); - SwagOrder order4 = order3; - - System.assert(order1.equals(order2)); - System.assert(order2.equals(order1)); - System.assert(order1.equals(order1)); - System.assert(order3.equals(order4)); - System.assert(order4.equals(order3)); - System.assert(order3.equals(order3)); - } - - @isTest - private static void equalsIdenticalInstance() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = SwagOrder.getExample(); - SwagOrder order3 = new SwagOrder(); - SwagOrder order4 = new SwagOrder(); - - System.assert(order1.equals(order2)); - System.assert(order2.equals(order1)); - System.assert(order3.equals(order4)); - System.assert(order4.equals(order3)); - } - - @isTest - private static void notEqualsUnlikeInstance() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = new SwagOrder(); - - System.assertEquals(false, order1.equals(order2)); - System.assertEquals(false, order2.equals(order1)); - } - - @isTest - private static void notEqualsDifferentType() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = new SwagOrder(); - - System.assertEquals(false, order1.equals('foo')); - System.assertEquals(false, order2.equals('foo')); - } - - @isTest - private static void notEqualsNull() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = new SwagOrder(); - SwagOrder order3; - - System.assertEquals(false, order1.equals(order3)); - System.assertEquals(false, order2.equals(order3)); - } - - @isTest - private static void consistentHashCodeValue() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = new SwagOrder(); - - System.assertEquals(order1.hashCode(), order1.hashCode()); - System.assertEquals(order2.hashCode(), order2.hashCode()); - } - - @isTest - private static void equalInstancesHaveSameHashCode() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = SwagOrder.getExample(); - SwagOrder order3 = new SwagOrder(); - SwagOrder order4 = new SwagOrder(); - - System.assert(order1.equals(order2)); - System.assert(order3.equals(order4)); - System.assertEquals(order1.hashCode(), order2.hashCode()); - System.assertEquals(order3.hashCode(), order4.hashCode()); - } - - @isTest - private static void defaultValuesPopulated() { - SwagOrder order = new SwagOrder(); - System.assertEquals(false, order.complete); - System.assertEquals(null, order.id); - System.assertEquals(null, order.petId); - System.assertEquals(null, order.quantity); - System.assertEquals(null, order.shipDate); - System.assertEquals(null, order.status); - } -} diff --git a/samples/client/petstore/apex/deploy/classes/SwagOrderTest.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagOrderTest.cls-meta.xml deleted file mode 100644 index 38aa015d1fc..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagOrderTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 36.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagPet.cls b/samples/client/petstore/apex/deploy/classes/SwagPet.cls deleted file mode 100644 index 4c0b2346a8c..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagPet.cls +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * 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. - */ - -/** - * A pet for sale in the pet store - */ -public class SwagPet { - /** - * Get id - * @return id - */ - public Long id { get; set; } - - /** - * Get category - * @return category - */ - public SwagCategory category { get; set; } - - /** - * Get name - * @return name - */ - public String name { get; set; } - - /** - * Get photoUrls - * @return photoUrls - */ - public List photoUrls { get; set; } - - /** - * Get tags - * @return tags - */ - public List tags { get; set; } - - /** - * pet status in the store - */ - public enum StatusEnum { - AVAILABLE, - PENDING, - SOLD - } - - /** - * pet status in the store - * @return status - */ - public StatusEnum status { get; set; } - - public SwagPet() { - photoUrls = new List(); - tags = new List(); - } - - public static SwagPet getExample() { - SwagPet pet = new SwagPet(); - pet.id = 123456789L; - pet.category = SwagCategory.getExample(); - pet.name = 'doggie'; - pet.photoUrls = new List{'aeiou'}; - pet.tags = new List{SwagTag.getExample()}; - pet.status = StatusEnum.AVAILABLE; - return pet; - } - - public Boolean equals(Object obj) { - if (obj instanceof SwagPet) { - SwagPet pet = (SwagPet) obj; - return this.id == pet.id - && this.category == pet.category - && this.name == pet.name - && this.photoUrls == pet.photoUrls - && this.tags == pet.tags - && this.status == pet.status; - } - return false; - } - - public Integer hashCode() { - Integer hashCode = 43; - hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); - hashCode = (17 * hashCode) + (category == null ? 0 : System.hashCode(category)); - hashCode = (17 * hashCode) + (name == null ? 0 : System.hashCode(name)); - hashCode = (17 * hashCode) + (photoUrls == null ? 0 : System.hashCode(photoUrls)); - hashCode = (17 * hashCode) + (tags == null ? 0 : System.hashCode(tags)); - hashCode = (17 * hashCode) + (status == null ? 0 : System.hashCode(status)); - return hashCode; - } -} - diff --git a/samples/client/petstore/apex/deploy/classes/SwagPet.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagPet.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagPet.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagPetApi.cls b/samples/client/petstore/apex/deploy/classes/SwagPetApi.cls deleted file mode 100644 index 059b7bdcd78..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagPetApi.cls +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * 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. - */ - -public class SwagPetApi { - SwagClient client; - - public SwagPetApi(SwagClient client) { - this.client = client; - } - - public SwagPetApi() { - this.client = new SwagClient(); - } - - public SwagClient getClient() { - return this.client; - } - - /** - * Add a new pet to the store - * - * @param body Pet object that needs to be added to the store (required) - * @throws Swagger.ApiException if fails to make API call - */ - public void addPet(Map params) { - client.assertNotNull(params.get('body'), 'body'); - List query = new List(); - List form = new List(); - - client.invoke( - 'POST', '/pet', - (SwagPet) params.get('body'), - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List { 'petstore_auth' }, - null - ); - } - /** - * Deletes a pet - * - * @param petId Pet id to delete (required) - * @param apiKey (optional) - * @throws Swagger.ApiException if fails to make API call - */ - public void deletePet(Map params) { - client.assertNotNull(params.get('petId'), 'petId'); - List query = new List(); - List form = new List(); - - client.invoke( - 'DELETE', '/pet/{petId}', '', - query, form, - new Map{ - 'petId' => (Long) params.get('petId') - }, - new Map{ - 'api_key' => (String) params.get('apiKey') - }, - new List{ 'application/json' }, - new List{ 'application/json' }, - new List { 'petstore_auth' }, - null - ); - } - /** - * Finds Pets by status - * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) - * @return List - * @throws Swagger.ApiException if fails to make API call - */ - public List findPetsByStatus(Map params) { - client.assertNotNull(params.get('status'), 'status'); - List query = new List(); - - // cast query params to verify their expected type - query.addAll(client.makeParam('status', (List) params.get('status'), 'csv')); - - List form = new List(); - - return (List) client.invoke( - 'GET', '/pet/findByStatus', '', - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List { 'petstore_auth' }, - List.class - ); - } - /** - * Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) - * @return List - * @throws Swagger.ApiException if fails to make API call - */ - public List findPetsByTags(Map params) { - client.assertNotNull(params.get('tags'), 'tags'); - List query = new List(); - - // cast query params to verify their expected type - query.addAll(client.makeParam('tags', (List) params.get('tags'), 'csv')); - - List form = new List(); - - return (List) client.invoke( - 'GET', '/pet/findByTags', '', - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List { 'petstore_auth' }, - List.class - ); - } - /** - * Find pet by ID - * Returns a single pet - * @param petId ID of pet to return (required) - * @return SwagPet - * @throws Swagger.ApiException if fails to make API call - */ - public SwagPet getPetById(Map params) { - client.assertNotNull(params.get('petId'), 'petId'); - List query = new List(); - List form = new List(); - - return (SwagPet) client.invoke( - 'GET', '/pet/{petId}', '', - query, form, - new Map{ - 'petId' => (Long) params.get('petId') - }, - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List { 'api_key' }, - SwagPet.class - ); - } - /** - * Update an existing pet - * - * @param body Pet object that needs to be added to the store (required) - * @throws Swagger.ApiException if fails to make API call - */ - public void updatePet(Map params) { - client.assertNotNull(params.get('body'), 'body'); - List query = new List(); - List form = new List(); - - client.invoke( - 'PUT', '/pet', - (SwagPet) params.get('body'), - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List { 'petstore_auth' }, - null - ); - } - /** - * Updates a pet in the store with form data - * - * @param petId ID of pet that needs to be updated (required) - * @param name Updated name of the pet (optional) - * @param status Updated status of the pet (optional) - * @throws Swagger.ApiException if fails to make API call - */ - public void updatePetWithForm(Map params) { - client.assertNotNull(params.get('petId'), 'petId'); - List query = new List(); - List form = new List(); - - // cast form params to verify their expected type - form.addAll(client.makeParam('name', (String) params.get('name'))); - form.addAll(client.makeParam('status', (String) params.get('status'))); - - client.invoke( - 'POST', '/pet/{petId}', '', - query, form, - new Map{ - 'petId' => (Long) params.get('petId') - }, - new Map(), - new List{ 'application/json' }, - new List{ 'application/x-www-form-urlencoded' }, - new List { 'petstore_auth' }, - null - ); - } - /** - * uploads an image - * - * @param petId ID of pet to update (required) - * @param additionalMetadata Additional data to pass to server (optional) - * @param file file to upload (optional) - * @return SwagApiResponse - * @throws Swagger.ApiException if fails to make API call - */ - public SwagApiResponse uploadFile(Map params) { - client.assertNotNull(params.get('petId'), 'petId'); - List query = new List(); - List form = new List(); - - // cast form params to verify their expected type - form.addAll(client.makeParam('additionalMetadata', (String) params.get('additionalMetadata'))); - form.addAll(client.makeParam('file', (Blob) params.get('file'))); - - return (SwagApiResponse) client.invoke( - 'POST', '/pet/{petId}/uploadImage', '', - query, form, - new Map{ - 'petId' => (Long) params.get('petId') - }, - new Map(), - new List{ 'application/json' }, - new List{ 'application/x-www-form-urlencoded' }, - new List { 'petstore_auth' }, - SwagApiResponse.class - ); - } -} diff --git a/samples/client/petstore/apex/deploy/classes/SwagPetApi.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagPetApi.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagPetApi.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagPetApiTest.cls b/samples/client/petstore/apex/deploy/classes/SwagPetApiTest.cls deleted file mode 100644 index e0f872e71b1..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagPetApiTest.cls +++ /dev/null @@ -1,247 +0,0 @@ -@isTest -private class SwagPetApiTest { - /** - * Add a new pet to the store - * - * - */ - @isTest - private static void addPetTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(201); - res.setStatus('Created'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'body' => SwagPet.getExample() - }; - - SwagClient client; - SwagPetApi api; - - client = new SwagClient(); - api = new SwagPetApi(client); - ((Swagger.OAuth2) client.getAuthentication('petstore_auth')) - .setAccessToken('foo-bar-access-token'); - - api.addPet(params); - } - - /** - * Deletes a pet - * - * - */ - @isTest - private static void deletePetTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'petId' => 2147483648L, - 'apiKey' => 'apiKey_example' - }; - - SwagClient client; - SwagPetApi api; - - client = new SwagClient(); - api = new SwagPetApi(client); - ((Swagger.OAuth2) client.getAuthentication('petstore_auth')) - .setAccessToken('foo-bar-access-token'); - - api.deletePet(params); - } - - /** - * Finds Pets by status - * - * Multiple status values can be provided with comma separated strings - */ - @isTest - private static void findPetsByStatusTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'status' => new List{'available'} - }; - - SwagClient client; - SwagPetApi api; - List response; - List expectedResponse; - - client = new SwagClient(); - api = new SwagPetApi(client); - ((Swagger.OAuth2) client.getAuthentication('petstore_auth')) - .setAccessToken('foo-bar-access-token'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('[ {\n "photoUrls" : [ "aeiou" ],\n "name" : "doggie",\n "id" : 0,\n "category" : {\n "name" : "aeiou",\n "id" : 6\n },\n "tags" : [ {\n "name" : "aeiou",\n "id" : 1\n } ],\n "status" : "available"\n} ]'); - expectedResponse = new List{SwagPet.getExample()}; - response = (List) api.findPetsByStatus(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Finds Pets by tags - * - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - */ - @isTest - private static void findPetsByTagsTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'tags' => new List{'aeiou'} - }; - - SwagClient client; - SwagPetApi api; - List response; - List expectedResponse; - - client = new SwagClient(); - api = new SwagPetApi(client); - ((Swagger.OAuth2) client.getAuthentication('petstore_auth')) - .setAccessToken('foo-bar-access-token'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('[ {\n "photoUrls" : [ "aeiou" ],\n "name" : "doggie",\n "id" : 0,\n "category" : {\n "name" : "aeiou",\n "id" : 6\n },\n "tags" : [ {\n "name" : "aeiou",\n "id" : 1\n } ],\n "status" : "available"\n} ]'); - expectedResponse = new List{SwagPet.getExample()}; - response = (List) api.findPetsByTags(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Find pet by ID - * - * Returns a single pet - */ - @isTest - private static void getPetByIdTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'petId' => 2147483648L - }; - - SwagClient client; - SwagPetApi api; - SwagPet response; - SwagPet expectedResponse; - - client = new SwagClient(); - api = new SwagPetApi(client); - ((Swagger.ApiKeyAuth) client.getAuthentication('api_key')) - .setApiKey('foo-bar-api-key'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "photoUrls" : [ "aeiou" ],\n "name" : "doggie",\n "id" : 0,\n "category" : {\n "name" : "aeiou",\n "id" : 6\n },\n "tags" : [ {\n "name" : "aeiou",\n "id" : 1\n } ],\n "status" : "available"\n}'); - expectedResponse = SwagPet.getExample(); - response = (SwagPet) api.getPetById(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Update an existing pet - * - * - */ - @isTest - private static void updatePetTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'body' => SwagPet.getExample() - }; - - SwagClient client; - SwagPetApi api; - - client = new SwagClient(); - api = new SwagPetApi(client); - ((Swagger.OAuth2) client.getAuthentication('petstore_auth')) - .setAccessToken('foo-bar-access-token'); - - api.updatePet(params); - } - - /** - * Updates a pet in the store with form data - * - * - */ - @isTest - private static void updatePetWithFormTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'petId' => 2147483648L, - 'name' => 'name_example', - 'status' => 'status_example' - }; - - SwagClient client; - SwagPetApi api; - - client = new SwagClient(); - api = new SwagPetApi(client); - ((Swagger.OAuth2) client.getAuthentication('petstore_auth')) - .setAccessToken('foo-bar-access-token'); - - api.updatePetWithForm(params); - } - - /** - * uploads an image - * - * - */ - @isTest - private static void uploadFileTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'petId' => 2147483648L, - 'additionalMetadata' => 'additionalMetadata_example', - 'file' => Blob.valueOf('Sample text file\nContents') - }; - - SwagClient client; - SwagPetApi api; - SwagApiResponse response; - SwagApiResponse expectedResponse; - - client = new SwagClient(); - api = new SwagPetApi(client); - ((Swagger.OAuth2) client.getAuthentication('petstore_auth')) - .setAccessToken('foo-bar-access-token'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "code" : 0,\n "type" : "aeiou",\n "message" : "aeiou"\n}'); - expectedResponse = SwagApiResponse.getExample(); - response = (SwagApiResponse) api.uploadFile(params); - System.assertEquals(expectedResponse, response); - } -} \ No newline at end of file diff --git a/samples/client/petstore/apex/deploy/classes/SwagPetApiTest.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagPetApiTest.cls-meta.xml deleted file mode 100644 index 38aa015d1fc..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagPetApiTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 36.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagPetTest.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagPetTest.cls-meta.xml deleted file mode 100644 index 38aa015d1fc..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagPetTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 36.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagStoreApi.cls b/samples/client/petstore/apex/deploy/classes/SwagStoreApi.cls deleted file mode 100644 index feb55354464..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagStoreApi.cls +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * 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. - */ - -public class SwagStoreApi { - SwagClient client; - - public SwagStoreApi(SwagClient client) { - this.client = client; - } - - public SwagStoreApi() { - this.client = new SwagClient(); - } - - public SwagClient getClient() { - return this.client; - } - - /** - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @param orderId ID of the order that needs to be deleted (required) - * @throws Swagger.ApiException if fails to make API call - */ - public void deleteOrder(Map params) { - client.assertNotNull(params.get('orderId'), 'orderId'); - List query = new List(); - List form = new List(); - - client.invoke( - 'DELETE', '/store/order/{orderId}', '', - query, form, - new Map{ - 'orderId' => (String) params.get('orderId') - }, - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - null - ); - } - /** - * Returns pet inventories by status - * Returns a map of status codes to quantities - * @return Map - * @throws Swagger.ApiException if fails to make API call - */ - public Map getInventory() { - List query = new List(); - List form = new List(); - - return (Map) client.invoke( - 'GET', '/store/inventory', '', - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List { 'api_key' }, - Map.class - ); - } - /** - * Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @param orderId ID of pet that needs to be fetched (required) - * @return SwagOrder - * @throws Swagger.ApiException if fails to make API call - */ - public SwagOrder getOrderById(Map params) { - client.assertNotNull(params.get('orderId'), 'orderId'); - List query = new List(); - List form = new List(); - - return (SwagOrder) client.invoke( - 'GET', '/store/order/{orderId}', '', - query, form, - new Map{ - 'orderId' => (Long) params.get('orderId') - }, - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - SwagOrder.class - ); - } - /** - * Place an order for a pet - * - * @param body order placed for purchasing the pet (required) - * @return SwagOrder - * @throws Swagger.ApiException if fails to make API call - */ - public SwagOrder placeOrder(Map params) { - client.assertNotNull(params.get('body'), 'body'); - List query = new List(); - List form = new List(); - - return (SwagOrder) client.invoke( - 'POST', '/store/order', - (SwagOrder) params.get('body'), - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - SwagOrder.class - ); - } -} diff --git a/samples/client/petstore/apex/deploy/classes/SwagStoreApi.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagStoreApi.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagStoreApi.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagStoreApiTest.cls b/samples/client/petstore/apex/deploy/classes/SwagStoreApiTest.cls deleted file mode 100644 index 7efe273bba9..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagStoreApiTest.cls +++ /dev/null @@ -1,115 +0,0 @@ -@isTest -private class SwagStoreApiTest { - /** - * Delete purchase order by ID - * - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - */ - @isTest - private static void deleteOrderTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'orderId' => 'orderId_example' - }; - - SwagClient client; - SwagStoreApi api; - - api = new SwagStoreApi(new SwagClient()); - - api.deleteOrder(params); - } - - /** - * Returns pet inventories by status - * - * Returns a map of status codes to quantities - */ - @isTest - private static void getInventoryTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - SwagClient client; - SwagStoreApi api; - Map response; - Map expectedResponse; - - client = new SwagClient(); - api = new SwagStoreApi(client); - ((Swagger.ApiKeyAuth) client.getAuthentication('api_key')) - .setApiKey('foo-bar-api-key'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "key" : 0\n}'); - expectedResponse = new Map{'key'=>123}; - response = (Map) api.getInventory(); - System.assertEquals(expectedResponse, response); - } - - /** - * Find purchase order by ID - * - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - */ - @isTest - private static void getOrderByIdTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'orderId' => 2147483648L - }; - - SwagClient client; - SwagStoreApi api; - SwagOrder response; - SwagOrder expectedResponse; - - api = new SwagStoreApi(new SwagClient()); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "petId" : 6,\n "quantity" : 1,\n "id" : 0,\n "shipDate" : "2000-01-23T04:56:07.000+00:00",\n "complete" : false,\n "status" : "placed"\n}'); - expectedResponse = SwagOrder.getExample(); - response = (SwagOrder) api.getOrderById(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Place an order for a pet - * - * - */ - @isTest - private static void placeOrderTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'body' => SwagOrder.getExample() - }; - - SwagClient client; - SwagStoreApi api; - SwagOrder response; - SwagOrder expectedResponse; - - api = new SwagStoreApi(new SwagClient()); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "petId" : 6,\n "quantity" : 1,\n "id" : 0,\n "shipDate" : "2000-01-23T04:56:07.000+00:00",\n "complete" : false,\n "status" : "placed"\n}'); - expectedResponse = SwagOrder.getExample(); - response = (SwagOrder) api.placeOrder(params); - System.assertEquals(expectedResponse, response); - } -} \ No newline at end of file diff --git a/samples/client/petstore/apex/deploy/classes/SwagStoreApiTest.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagStoreApiTest.cls-meta.xml deleted file mode 100644 index 38aa015d1fc..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagStoreApiTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 36.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagTag.cls b/samples/client/petstore/apex/deploy/classes/SwagTag.cls deleted file mode 100644 index d1348d58db8..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagTag.cls +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * 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. - */ - -/** - * A tag for a pet - */ -public class SwagTag { - /** - * Get id - * @return id - */ - public Long id { get; set; } - - /** - * Get name - * @return name - */ - public String name { get; set; } - - public static SwagTag getExample() { - SwagTag tag = new SwagTag(); - tag.id = 123456789L; - tag.name = 'aeiou'; - return tag; - } - - public Boolean equals(Object obj) { - if (obj instanceof SwagTag) { - SwagTag tag = (SwagTag) obj; - return this.id == tag.id - && this.name == tag.name; - } - return false; - } - - public Integer hashCode() { - Integer hashCode = 43; - hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); - hashCode = (17 * hashCode) + (name == null ? 0 : System.hashCode(name)); - return hashCode; - } -} - diff --git a/samples/client/petstore/apex/deploy/classes/SwagTag.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagTag.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagTag.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagTagTest.cls b/samples/client/petstore/apex/deploy/classes/SwagTagTest.cls deleted file mode 100644 index beee6690404..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagTagTest.cls +++ /dev/null @@ -1,80 +0,0 @@ -@isTest -private class SwagTagTest { - @isTest - private static void equalsSameInstance() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = tag1; - SwagTag tag3 = new SwagTag(); - SwagTag tag4 = tag3; - - System.assert(tag1.equals(tag2)); - System.assert(tag2.equals(tag1)); - System.assert(tag1.equals(tag1)); - System.assert(tag3.equals(tag4)); - System.assert(tag4.equals(tag3)); - System.assert(tag3.equals(tag3)); - } - - @isTest - private static void equalsIdenticalInstance() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = SwagTag.getExample(); - SwagTag tag3 = new SwagTag(); - SwagTag tag4 = new SwagTag(); - - System.assert(tag1.equals(tag2)); - System.assert(tag2.equals(tag1)); - System.assert(tag3.equals(tag4)); - System.assert(tag4.equals(tag3)); - } - - @isTest - private static void notEqualsUnlikeInstance() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = new SwagTag(); - - System.assertEquals(false, tag1.equals(tag2)); - System.assertEquals(false, tag2.equals(tag1)); - } - - @isTest - private static void notEqualsDifferentType() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = new SwagTag(); - - System.assertEquals(false, tag1.equals('foo')); - System.assertEquals(false, tag2.equals('foo')); - } - - @isTest - private static void notEqualsNull() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = new SwagTag(); - SwagTag tag3; - - System.assertEquals(false, tag1.equals(tag3)); - System.assertEquals(false, tag2.equals(tag3)); - } - - @isTest - private static void consistentHashCodeValue() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = new SwagTag(); - - System.assertEquals(tag1.hashCode(), tag1.hashCode()); - System.assertEquals(tag2.hashCode(), tag2.hashCode()); - } - - @isTest - private static void equalInstancesHaveSameHashCode() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = SwagTag.getExample(); - SwagTag tag3 = new SwagTag(); - SwagTag tag4 = new SwagTag(); - - System.assert(tag1.equals(tag2)); - System.assert(tag3.equals(tag4)); - System.assertEquals(tag1.hashCode(), tag2.hashCode()); - System.assertEquals(tag3.hashCode(), tag4.hashCode()); - } -} diff --git a/samples/client/petstore/apex/deploy/classes/SwagTagTest.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagTagTest.cls-meta.xml deleted file mode 100644 index 38aa015d1fc..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagTagTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 36.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagUser.cls b/samples/client/petstore/apex/deploy/classes/SwagUser.cls deleted file mode 100644 index d8ec7643bb2..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagUser.cls +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * 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. - */ - -/** - * A User who is purchasing from the pet store - */ -public class SwagUser { - /** - * Get id - * @return id - */ - public Long id { get; set; } - - /** - * Get username - * @return username - */ - public String username { get; set; } - - /** - * Get firstName - * @return firstName - */ - public String firstName { get; set; } - - /** - * Get lastName - * @return lastName - */ - public String lastName { get; set; } - - /** - * Get email - * @return email - */ - public String email { get; set; } - - /** - * Get password - * @return password - */ - public String password { get; set; } - - /** - * Get phone - * @return phone - */ - public String phone { get; set; } - - /** - * User Status - * @return userStatus - */ - public Integer userStatus { get; set; } - - public static SwagUser getExample() { - SwagUser user = new SwagUser(); - user.id = 123456789L; - user.username = 'aeiou'; - user.firstName = 'aeiou'; - user.lastName = 'aeiou'; - user.email = 'aeiou'; - user.password = 'aeiou'; - user.phone = 'aeiou'; - user.userStatus = 123; - return user; - } - - public Boolean equals(Object obj) { - if (obj instanceof SwagUser) { - SwagUser user = (SwagUser) obj; - return this.id == user.id - && this.username == user.username - && this.firstName == user.firstName - && this.lastName == user.lastName - && this.email == user.email - && this.password == user.password - && this.phone == user.phone - && this.userStatus == user.userStatus; - } - return false; - } - - public Integer hashCode() { - Integer hashCode = 43; - hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); - hashCode = (17 * hashCode) + (username == null ? 0 : System.hashCode(username)); - hashCode = (17 * hashCode) + (firstName == null ? 0 : System.hashCode(firstName)); - hashCode = (17 * hashCode) + (lastName == null ? 0 : System.hashCode(lastName)); - hashCode = (17 * hashCode) + (email == null ? 0 : System.hashCode(email)); - hashCode = (17 * hashCode) + (password == null ? 0 : System.hashCode(password)); - hashCode = (17 * hashCode) + (phone == null ? 0 : System.hashCode(phone)); - hashCode = (17 * hashCode) + (userStatus == null ? 0 : System.hashCode(userStatus)); - return hashCode; - } -} - diff --git a/samples/client/petstore/apex/deploy/classes/SwagUser.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagUser.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagUser.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagUserApi.cls b/samples/client/petstore/apex/deploy/classes/SwagUserApi.cls deleted file mode 100644 index 01d9ebe4013..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagUserApi.cls +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. - * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io - * - * 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. - */ - -public class SwagUserApi { - SwagClient client; - - public SwagUserApi(SwagClient client) { - this.client = client; - } - - public SwagUserApi() { - this.client = new SwagClient(); - } - - public SwagClient getClient() { - return this.client; - } - - /** - * Create user - * This can only be done by the logged in user. - * @param body Created user object (required) - * @throws Swagger.ApiException if fails to make API call - */ - public void createUser(Map params) { - client.assertNotNull(params.get('body'), 'body'); - List query = new List(); - List form = new List(); - - client.invoke( - 'POST', '/user', - (SwagUser) params.get('body'), - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - null - ); - } - /** - * Creates list of users with given input array - * - * @param body List of user object (required) - * @throws Swagger.ApiException if fails to make API call - */ - public void createUsersWithArrayInput(Map params) { - client.assertNotNull(params.get('body'), 'body'); - List query = new List(); - List form = new List(); - - client.invoke( - 'POST', '/user/createWithArray', - (List) params.get('body'), - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - null - ); - } - /** - * Creates list of users with given input array - * - * @param body List of user object (required) - * @throws Swagger.ApiException if fails to make API call - */ - public void createUsersWithListInput(Map params) { - client.assertNotNull(params.get('body'), 'body'); - List query = new List(); - List form = new List(); - - client.invoke( - 'POST', '/user/createWithList', - (List) params.get('body'), - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - null - ); - } - /** - * Delete user - * This can only be done by the logged in user. - * @param username The name that needs to be deleted (required) - * @throws Swagger.ApiException if fails to make API call - */ - public void deleteUser(Map params) { - client.assertNotNull(params.get('username'), 'username'); - List query = new List(); - List form = new List(); - - client.invoke( - 'DELETE', '/user/{username}', '', - query, form, - new Map{ - 'username' => (String) params.get('username') - }, - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - null - ); - } - /** - * Get user by user name - * - * @param username The name that needs to be fetched. Use user1 for testing. (required) - * @return SwagUser - * @throws Swagger.ApiException if fails to make API call - */ - public SwagUser getUserByName(Map params) { - client.assertNotNull(params.get('username'), 'username'); - List query = new List(); - List form = new List(); - - return (SwagUser) client.invoke( - 'GET', '/user/{username}', '', - query, form, - new Map{ - 'username' => (String) params.get('username') - }, - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - SwagUser.class - ); - } - /** - * Logs user into the system - * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) - * @return String - * @throws Swagger.ApiException if fails to make API call - */ - public String loginUser(Map params) { - client.assertNotNull(params.get('username'), 'username'); - client.assertNotNull(params.get('password'), 'password'); - List query = new List(); - - // cast query params to verify their expected type - query.addAll(client.makeParam('username', (String) params.get('username'))); - query.addAll(client.makeParam('password', (String) params.get('password'))); - - List form = new List(); - - return (String) client.invoke( - 'GET', '/user/login', '', - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - String.class - ); - } - /** - * Logs out current logged in user session - * - * @throws Swagger.ApiException if fails to make API call - */ - public void logoutUser() { - List query = new List(); - List form = new List(); - - client.invoke( - 'GET', '/user/logout', '', - query, form, - new Map(), - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - null - ); - } - /** - * Updated user - * This can only be done by the logged in user. - * @param username name that need to be deleted (required) - * @param body Updated user object (required) - * @throws Swagger.ApiException if fails to make API call - */ - public void updateUser(Map params) { - client.assertNotNull(params.get('username'), 'username'); - client.assertNotNull(params.get('body'), 'body'); - List query = new List(); - List form = new List(); - - client.invoke( - 'PUT', '/user/{username}', - (SwagUser) params.get('body'), - query, form, - new Map{ - 'username' => (String) params.get('username') - }, - new Map(), - new List{ 'application/json' }, - new List{ 'application/json' }, - new List(), - null - ); - } -} diff --git a/samples/client/petstore/apex/deploy/classes/SwagUserApi.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagUserApi.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagUserApi.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagUserApiTest.cls b/samples/client/petstore/apex/deploy/classes/SwagUserApiTest.cls deleted file mode 100644 index 637f55bd5a5..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagUserApiTest.cls +++ /dev/null @@ -1,204 +0,0 @@ -@isTest -private class SwagUserApiTest { - /** - * Create user - * - * This can only be done by the logged in user. - */ - @isTest - private static void createUserTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(201); - res.setStatus('Created'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'body' => SwagUser.getExample() - }; - - SwagClient client; - SwagUserApi api; - - api = new SwagUserApi(new SwagClient()); - - api.createUser(params); - } - - /** - * Creates list of users with given input array - * - * - */ - @isTest - private static void createUsersWithArrayInputTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'body' => new List{SwagUser.getExample()} - }; - - SwagClient client; - SwagUserApi api; - - api = new SwagUserApi(new SwagClient()); - - api.createUsersWithArrayInput(params); - } - - /** - * Creates list of users with given input array - * - * - */ - @isTest - private static void createUsersWithListInputTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'body' => new List{SwagUser.getExample()} - }; - - SwagClient client; - SwagUserApi api; - - api = new SwagUserApi(new SwagClient()); - - api.createUsersWithListInput(params); - } - - /** - * Delete user - * - * This can only be done by the logged in user. - */ - @isTest - private static void deleteUserTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'username' => 'username_example' - }; - - SwagClient client; - SwagUserApi api; - - api = new SwagUserApi(new SwagClient()); - - api.deleteUser(params); - } - - /** - * Get user by user name - * - * - */ - @isTest - private static void getUserByNameTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'username' => 'username_example' - }; - - SwagClient client; - SwagUserApi api; - SwagUser response; - SwagUser expectedResponse; - - api = new SwagUserApi(new SwagClient()); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "firstName" : "aeiou",\n "lastName" : "aeiou",\n "password" : "aeiou",\n "userStatus" : 6,\n "phone" : "aeiou",\n "id" : 0,\n "email" : "aeiou",\n "username" : "aeiou"\n}'); - expectedResponse = SwagUser.getExample(); - response = (SwagUser) api.getUserByName(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Logs user into the system - * - * - */ - @isTest - private static void loginUserTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'username' => 'username_example', - 'password' => 'password_example' - }; - - SwagClient client; - SwagUserApi api; - String response; - String expectedResponse; - - api = new SwagUserApi(new SwagClient()); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('"aeiou"'); - expectedResponse = 'aeiou'; - response = (String) api.loginUser(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Logs out current logged in user session - * - * - */ - @isTest - private static void logoutUserTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - SwagClient client; - SwagUserApi api; - - api = new SwagUserApi(new SwagClient()); - - api.logoutUser(); - } - - /** - * Updated user - * - * This can only be done by the logged in user. - */ - @isTest - private static void updateUserTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'username' => 'username_example', - 'body' => SwagUser.getExample() - }; - - SwagClient client; - SwagUserApi api; - - api = new SwagUserApi(new SwagClient()); - - api.updateUser(params); - } -} \ No newline at end of file diff --git a/samples/client/petstore/apex/deploy/classes/SwagUserApiTest.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagUserApiTest.cls-meta.xml deleted file mode 100644 index 38aa015d1fc..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagUserApiTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 36.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwagUserTest.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwagUserTest.cls-meta.xml deleted file mode 100644 index 38aa015d1fc..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwagUserTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 36.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/Swagger.cls b/samples/client/petstore/apex/deploy/classes/Swagger.cls deleted file mode 100644 index 0a7a1b106a7..00000000000 --- a/samples/client/petstore/apex/deploy/classes/Swagger.cls +++ /dev/null @@ -1,395 +0,0 @@ -public class Swagger { - private static final String HEADER_CONTENT_TYPE = 'Content-Type'; - private static final String HEADER_ACCEPT = 'Accept'; - private static final String HEADER_ACCEPT_DELIMITER = ','; - private static final Map DELIMITERS = new Map { - 'csv' => ',', - 'ssv' => ' ', - 'tsv' => '\t', - 'pipes' => '|' - }; - - public class Param { - private String name, value; - - public Param(String name, String value) { - this.name = name; - this.value = value; - } - - public override String toString() { - return EncodingUtil.urlEncode(name, 'UTF-8') + '=' - + EncodingUtil.urlEncode(value, 'UTF-8'); - } - } - - public interface Authentication { - void apply(Map headers, List query); - } - - public interface MappedProperties { - Map getPropertyMappings(); - } - - public abstract class ApiKeyAuth implements Authentication { - protected final String paramName; - protected String key = ''; - - public void setApiKey(String key) { - this.key = key; - } - - @TestVisible - private String getApiKey() { - return key; - } - } - - public class ApiKeyQueryAuth extends ApiKeyAuth { - public ApiKeyQueryAuth(String paramName) { - this.paramName = paramName; - } - - public void apply(Map headers, List query) { - query.add(new Param(paramName, key)); - } - } - - public class ApiKeyHeaderAuth extends ApiKeyAuth { - public ApiKeyHeaderAuth(String paramName) { - this.paramName = paramName; - } - - public void apply(Map headers, List query) { - headers.put(paramName, key); - } - } - - public class HttpBasicAuth implements Authentication { - private String username = ''; - private String password = ''; - - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setCredentials(String username, String password) { - setUsername(username); - setPassword(password); - } - - @TestVisible - private String getHeaderValue() { - return 'Basic ' + EncodingUtil.base64Encode(Blob.valueOf(username + ':' + password)); - } - - public void apply(Map headers, List query) { - headers.put('Authorization', getHeaderValue()); - } - } - - public class OAuth2 implements Authentication { - private String accessToken = ''; - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - @TestVisible - private String getHeaderValue() { - return 'Bearer ' + accessToken; - } - - public void apply(Map headers, List query) { - headers.put('Authorization', getHeaderValue()); - } - } - - public class ApiException extends Exception { - private final Integer code; - private final String status; - private final Map headers; - private final String body; - - public ApiException(Integer code, String status, Map headers, String body) { - this('API returned HTTP ' + code + ': ' + status); - this.code = code; - this.status = status; - this.headers = headers; - this.body = body; - } - - public Integer getStatusCode() { - return code; - } - - public String getStatus() { - return status; - } - - public Map getHeaders() { - return headers; - } - - public String getBody() { - return body; - } - } - - public virtual class ApiClient { - protected String preferredContentType = 'application/json'; - protected String preferredAccept = 'application/json'; - protected final String basePath; - - @TestVisible - protected final Map authentications = new Map(); - - public virtual Authentication getAuthentication(String authName) { - return authentications.get(authName); - } - - public virtual void setUsername(String username) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setUsername(username); - return; - } - } - throw new NoSuchElementException('No HTTP basic authentication configured!'); - } - - public virtual void setPassword(String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setPassword(password); - return; - } - } - throw new NoSuchElementException('No HTTP basic authentication configured!'); - } - - public virtual void setCredentials(String username, String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setCredentials(username, password); - return; - } - } - throw new NoSuchElementException('No HTTP basic authentication configured!'); - } - - public virtual void setApiKey(String apiKey) { - for (Authentication auth : authentications.values()) { - if (auth instanceof ApiKeyAuth) { - ((ApiKeyAuth) auth).setApiKey(apiKey); - return; - } - } - throw new NoSuchElementException('No API key authentication configured!'); - } - - public virtual void setAccessToken(String accessToken) { - for (Authentication auth : authentications.values()) { - if (auth instanceof OAuth2) { - ((OAuth2) auth).setAccessToken(accessToken); - return; - } - } - throw new NoSuchElementException('No OAuth2 authentication configured!'); - } - - public List makeParams(String name, List values) { - List pairs = new List(); - for (Object value : new List(values)) { - pairs.add(new Param(name, String.valueOf(value))); - } - return pairs; - } - - public List makeParam(String name, List values, String format) { - List pairs = new List(); - if (values != null) { - String delimiter = DELIMITERS.get(format); - pairs.add(new Param(name, String.join(values, delimiter))); - } - return pairs; - } - - public List makeParam(String name, Object value) { - List pairs = new List(); - if (value != null) { - pairs.add(new Param(name, String.valueOf(value))); - } - return pairs; - } - - public virtual void assertNotNull(Object required, String parameterName) { - if (required == null) { - Exception e = new NullPointerException(); - e.setMessage('Argument cannot be null: ' + parameterName); - throw e; - } - } - - public virtual Object invoke( - String method, String path, Object body, List query, List form, - Map pathParams, Map headers, List accepts, - List contentTypes, List authMethods, Type returnType) { - - HttpResponse res = getResponse(method, path, body, query, form, pathParams, headers, - accepts, contentTypes, authMethods); - - Integer code = res.getStatusCode(); - Boolean isFailure = code / 100 != 2; - if (isFailure) { - throw new ApiException(code, res.getStatus(), getHeaders(res), res.getBody()); - } else if (returnType != null) { - return toReturnValue(res.getBody(), returnType, res.getHeader('Content-Type')); - } - return null; - } - - @TestVisible - protected virtual Map getHeaders(HttpResponse res) { - Map headers = new Map(); - List headerKeys = res.getHeaderKeys(); - for (String headerKey : headerKeys) { - headers.put(headerKey, res.getHeader(headerKey)); - } - return headers; - } - - @TestVisible - protected virtual Object toReturnValue(String body, Type returnType, String contentType) { - if (contentType == 'application/json') { - Object o = returnType.newInstance(); - if (o instanceof MappedProperties) { - Map propertyMappings = ((MappedProperties) o).getPropertyMappings(); - for (String baseName : propertyMappings.keySet()) { - body = body.replaceAll('"' + baseName + '"\\s*:', - '"' + propertyMappings.get(baseName) + '":'); - } - } - JsonParser parser = Json.createParser(body); - parser.nextToken(); - return parser.readValueAs(returnType); - } - return body; - } - - @TestVisible - protected virtual HttpResponse getResponse( - String method, String path, Object body, List query, List form, - Map pathParams, Map headers, List accepts, - List contentTypes, List authMethods) { - - HttpRequest req = new HttpRequest(); - applyAuthentication(authMethods, headers, query); - req.setMethod(method); - req.setEndpoint(toEndpoint(path, pathParams, query)); - String contentType = setContentTypeHeader(contentTypes, headers); - setAcceptHeader(accepts, headers); - setHeaders(req, headers); - - if (method != 'GET') { - req.setBody(toBody(contentType, body, form)); - } - - return new Http().send(req); - } - - @TestVisible - protected virtual void setHeaders(HttpRequest req, Map headers) { - for (String headerName : headers.keySet()) { - req.setHeader(headerName, String.valueOf(headers.get(headerName))); - } - } - - @TestVisible - protected virtual String toBody(String contentType, Object body, List form) { - if (contentType.contains('application/x-www-form-urlencoded')) { - return paramsToString(form); - } else if (contentType.contains('application/json')) { - return Json.serialize(body); - } - return String.valueOf(body); - } - - @TestVisible - protected virtual String setContentTypeHeader(List contentTypes, - Map headers) { - if (contentTypes.isEmpty()) { - headers.put(HEADER_CONTENT_TYPE, preferredContentType); - return preferredContentType; - } - for (String contentType : contentTypes) { - if (preferredContentType == contentType) { - headers.put(HEADER_CONTENT_TYPE, contentType); - return contentType; - } - } - String contentType = contentTypes.get(0); - headers.put(HEADER_CONTENT_TYPE, contentType); - return contentType; - } - - @TestVisible - protected virtual void setAcceptHeader(List accepts, Map headers) { - for (String accept : accepts) { - if (preferredAccept == accept) { - headers.put(HEADER_ACCEPT, accept); - return; - } - } - if (!accepts.isEmpty()) { - headers.put(HEADER_ACCEPT, String.join(accepts, HEADER_ACCEPT_DELIMITER)); - } - } - - @TestVisible - protected virtual void applyAuthentication(List names, Map headers, - List query) { - for (Authentication auth : getAuthMethods(names)) { - auth.apply(headers, query); - } - } - - @TestVisible - protected virtual List getAuthMethods(List names) { - List authMethods = new List(); - for (String name : names) { - authMethods.add(authentications.get(name)); - } - return authMethods; - } - - @TestVisible - protected virtual String toPath(String path, Map params) { - String formatted = path; - for (String key : params.keySet()) { - formatted = formatted.replace('{' + key + '}', String.valueOf(params.get(key))); - } - return formatted; - } - - @TestVisible - protected virtual String toEndpoint(String path, Map params, - List queryParams) { - String query = '?' + paramsToString(queryParams); - return basePath + toPath(path, params) + query.removeEnd('?'); - } - - @TestVisible - protected virtual String paramsToString(List params) { - String s = ''; - for (Param p : params) { - s += '&' + p; - } - return s.removeStart('&'); - } - } -} \ No newline at end of file diff --git a/samples/client/petstore/apex/deploy/classes/Swagger.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/Swagger.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/Swagger.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwaggerResponseMock.cls b/samples/client/petstore/apex/deploy/classes/SwaggerResponseMock.cls deleted file mode 100644 index 7d3acb1a91f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwaggerResponseMock.cls +++ /dev/null @@ -1,18 +0,0 @@ -@isTest -public class SwaggerResponseMock implements HttpCalloutMock { - private final HttpResponse response; - private HttpRequest request; - - public SwaggerResponseMock(HttpResponse response) { - this.response = response; - } - - public HttpResponse respond(HttpRequest request) { - this.request = request; - return response; - } - - public HttpRequest getRequest() { - return request; - } -} \ No newline at end of file diff --git a/samples/client/petstore/apex/deploy/classes/SwaggerResponseMock.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwaggerResponseMock.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwaggerResponseMock.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/classes/SwaggerTest.cls b/samples/client/petstore/apex/deploy/classes/SwaggerTest.cls deleted file mode 100644 index dcbca6cdd94..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwaggerTest.cls +++ /dev/null @@ -1,782 +0,0 @@ -@isTest -private class SwaggerTest { - @isTest - private static void Param_urlEncodeKeyValuePairUtf8() { - String toEncodeLeft = 'Hello +%-_.!~*\'()@'; - String toEncodeRight = 'World +%-_.!~*\'()@'; - String expected = 'Hello+%2B%25-_.%21%7E*%27%28%29%40=World+%2B%25-_.%21%7E*%27%28%29%40'; - String result = new Swagger.Param(toEncodeLeft, toEncodeRight).toString(); - System.assertEquals(expected, result); - } - - @isTest - private static void ApiKeyHeaderAuth_keyInHeaderWithGivenName() { - Map headers = new Map(); - List query = new List(); - Swagger.ApiKeyHeaderAuth auth = new Swagger.ApiKeyHeaderAuth('X-Authenticate'); - auth.setApiKey('foo-bar-api-key'); - auth.apply(headers, query); - - System.assert(query.isEmpty()); - System.assertEquals(1, headers.size()); - System.assertEquals('foo-bar-api-key', headers.get('X-Authenticate')); - } - - @isTest - private static void ApiKeyQueryAuth_keyInQueryParamWithGivenName() { - Map headers = new Map(); - List query = new List(); - Swagger.ApiKeyQueryAuth auth = new Swagger.ApiKeyQueryAuth('auth_token'); - auth.setApiKey('foo-bar-api-key'); - auth.apply(headers, query); - - System.assert(headers.isEmpty()); - System.assertEquals(1, query.size()); - System.assertEquals('auth_token=foo-bar-api-key', query.get(0).toString()); - } - - @isTest - private static void HttpBasicAuth_base64EncodeCredentials() { - Map headers = new Map(); - List query = new List(); - Swagger.HttpBasicAuth auth = new Swagger.HttpBasicAuth(); - auth.setCredentials('username', 'password'); - auth.apply(headers, query); - - System.assert(query.isEmpty()); - System.assertEquals(1, headers.size()); - System.assertEquals('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', headers.get('Authorization')); - } - - @isTest - private static void HttpBasicAuth_base64EncodeUsernamePassword() { - Map headers = new Map(); - List query = new List(); - Swagger.HttpBasicAuth auth = new Swagger.HttpBasicAuth(); - auth.setUsername('username'); - auth.setPassword('password'); - auth.apply(headers, query); - - System.assert(query.isEmpty()); - System.assertEquals(1, headers.size()); - System.assertEquals('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', headers.get('Authorization')); - } - - @isTest - private static void OAuth2_tokenInAuthorizationHeaderWithBearerPrefix() { - Map headers = new Map(); - List query = new List(); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-api-key'); - auth.apply(headers, query); - - System.assert(query.isEmpty()); - System.assertEquals(1, headers.size()); - System.assertEquals('Bearer foo-bar-api-key', headers.get('Authorization')); - } - - @isTest - private static void ApiClient_returnAuthenticationMatchingInput() { - MockApiClient client = new MockApiClient(); - Swagger.ApiKeyHeaderAuth auth1 = new Swagger.ApiKeyHeaderAuth('foo'); - Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('foo'); - Swagger.HttpBasicAuth auth3 = new Swagger.HttpBasicAuth(); - Swagger.OAuth2 auth4 = new Swagger.OAuth2(); - - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); - - System.assertEquals(auth1, client.getAuthentication('auth1')); - System.assertEquals(auth2, client.getAuthentication('auth2')); - System.assertEquals(auth3, client.getAuthentication('auth3')); - System.assertEquals(auth4, client.getAuthentication('auth4')); - } - - @isTest - private static void ApiClient_noAuthenticationsMatchInputReturnNull() { - MockApiClient client = new MockApiClient(); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - client.authentications.put('auth', auth); - - System.assertEquals(auth, client.getAuthentication('auth')); - System.assertEquals(null, client.getAuthentication('no-auth')); - } - - @isTest - private static void ApiClient_setUsernamePasswordFirstBasicAuthOnly() { - MockApiClient client = new MockApiClient(); - Swagger.OAuth2 auth1 = new Swagger.OAuth2(); - Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('auth2'); - Swagger.ApiKeyHeaderAuth auth3 = new Swagger.ApiKeyHeaderAuth('auth3'); - Swagger.HttpBasicAuth auth4 = new Swagger.HttpBasicAuth(); - Swagger.HttpBasicAuth auth5 = new Swagger.HttpBasicAuth(); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); - client.authentications.put('auth5', auth5); - client.setUsername('username'); - client.setPassword('password'); - - System.assertEquals('Bearer ', auth1.getHeaderValue()); - System.assertEquals('', auth2.getApiKey()); - System.assertEquals('', auth3.getApiKey()); - System.assertEquals('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', auth4.getHeaderValue()); - System.assertEquals('Basic Og==', auth5.getHeaderValue()); - } - - @isTest - private static void ApiClient_setUsernameExceptionNoBasicAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setUsername('username'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_setPasswordExceptionNoBasicAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setPassword('password'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_setCredentialsFirstBasicAuthOnly() { - MockApiClient client = new MockApiClient(); - Swagger.OAuth2 auth1 = new Swagger.OAuth2(); - Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('auth2'); - Swagger.ApiKeyHeaderAuth auth3 = new Swagger.ApiKeyHeaderAuth('auth3'); - Swagger.HttpBasicAuth auth4 = new Swagger.HttpBasicAuth(); - Swagger.HttpBasicAuth auth5 = new Swagger.HttpBasicAuth(); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); - client.authentications.put('auth5', auth5); - client.setCredentials('username', 'password'); - - System.assertEquals('Bearer ', auth1.getHeaderValue()); - System.assertEquals('', auth2.getApiKey()); - System.assertEquals('', auth3.getApiKey()); - System.assertEquals('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', auth4.getHeaderValue()); - System.assertEquals('Basic Og==', auth5.getHeaderValue()); - } - - @isTest - private static void ApiClient_setCredentialsExceptionNoBasicAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setCredentials('username', 'password'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_setApiKeyFirstKeyAuthOnly() { - MockApiClient client = new MockApiClient(); - Swagger.OAuth2 auth1 = new Swagger.OAuth2(); - Swagger.HttpBasicAuth auth2 = new Swagger.HttpBasicAuth(); - Swagger.HttpBasicAuth auth3 = new Swagger.HttpBasicAuth(); - Swagger.ApiKeyQueryAuth auth4 = new Swagger.ApiKeyQueryAuth('auth4'); - Swagger.ApiKeyHeaderAuth auth5 = new Swagger.ApiKeyHeaderAuth('auth5'); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); - client.authentications.put('auth5', auth5); - client.setApiKey('foo-bar-api-key'); - - System.assertEquals('Bearer ', auth1.getHeaderValue()); - System.assertEquals('Basic Og==', auth2.getHeaderValue()); - System.assertEquals('Basic Og==', auth3.getHeaderValue()); - System.assertEquals('foo-bar-api-key', auth4.getApiKey()); - System.assertEquals('', auth5.getApiKey()); - } - - @isTest - private static void ApiClient_setApiKeyExceptionNoKeyAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setApiKey('foo-bar-api-key'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_setAccessTokenFirstOauthOnly() { - MockApiClient client = new MockApiClient(); - Swagger.HttpBasicAuth auth1 = new Swagger.HttpBasicAuth(); - Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('auth2'); - Swagger.ApiKeyHeaderAuth auth3 = new Swagger.ApiKeyHeaderAuth('auth3'); - Swagger.OAuth2 auth4 = new Swagger.OAuth2(); - Swagger.OAuth2 auth5 = new Swagger.OAuth2(); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); - client.authentications.put('auth5', auth5); - client.setAccessToken('foo-bar-api-key'); - - System.assertEquals('Basic Og==', auth1.getHeaderValue()); - System.assertEquals('', auth2.getApiKey()); - System.assertEquals('', auth3.getApiKey()); - System.assertEquals('Bearer foo-bar-api-key', auth4.getHeaderValue()); - System.assertEquals('Bearer ', auth5.getHeaderValue()); - } - - @isTest - private static void ApiClient_setAccessTokenExceptionNoOAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setAccessToken('foo-bar-api-key'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_oneKeyValuePairForEachValueInList() { - List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParams('foo', values); - - System.assertEquals(5, params.size()); - System.assertEquals('foo=bar', params.get(0).toString()); - System.assertEquals('foo=4', params.get(1).toString()); - System.assertEquals('foo=false', params.get(2).toString()); - System.assertEquals('foo=12.4', params.get(3).toString()); - System.assertEquals('foo=', params.get(4).toString()); - } - - @isTest - private static void ApiClient_nullMultiValuesListToEmptyParamsList() { - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParams('foo', null); - - System.assert(params.isEmpty()); - } - - @isTest - private static void ApiClient_valuesListToSingleCsvKeyValuePair() { - List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'csv'); - - System.assertEquals(1, params.size()); - System.assertEquals('foo=bar%2C4%2Cfalse%2C12.4%2C', params.get(0).toString()); - } - - @isTest - private static void ApiClient_valuesListToSingleSsvKeyValuePair() { - List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'ssv'); - - System.assertEquals(1, params.size()); - System.assertEquals('foo=bar+4+false+12.4+', params.get(0).toString()); - } - - @isTest - private static void ApiClient_valuesListToSingleTsvKeyValuePair() { - List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'tsv'); - - System.assertEquals(1, params.size()); - System.assertEquals('foo=bar%094%09false%0912.4%09', params.get(0).toString()); - } - - @isTest - private static void ApiClient_valuesListToSinglePipeSeparatedKeyValuePair() { - List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'pipes'); - - System.assertEquals(1, params.size()); - System.assertEquals('foo=bar%7C4%7Cfalse%7C12.4%7C', params.get(0).toString()); - } - - @isTest - private static void ApiClient_nullValuesListToEmptyParamsList() { - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', null, 'csv'); - - System.assert(params.isEmpty()); - } - - @isTest - private static void ApiClient_paramsFromAnyPrimitiveTypeDiscardNull() { - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = new List(); - params.addAll(client.makeParam('foo', 'bar')); - params.addAll(client.makeParam('foo', 10)); - params.addAll(client.makeParam('foo', 12.6)); - params.addAll(client.makeParam('foo', true)); - params.addAll(client.makeParam('foo', '')); - params.addAll(client.makeParam('foo', Datetime.newInstanceGmt(2017, 1, 1, 15, 0, 0))); - params.addAll(client.makeParam('foo', null)); - - System.assertEquals(6, params.size()); - System.assertEquals('foo=bar', params.get(0).toString()); - System.assertEquals('foo=10', params.get(1).toString()); - System.assertEquals('foo=12.6', params.get(2).toString()); - System.assertEquals('foo=true', params.get(3).toString()); - System.assertEquals('foo=', params.get(4).toString()); - System.assertEquals('foo=2017-01-01+15%3A00%3A00', params.get(5).toString()); - } - - @isTest - private static void ApiClient_requiredParameterPasses() { - Swagger.ApiClient client = new Swagger.ApiClient(); - client.assertNotNull('foo', 'bar'); - } - - @isTest - private static void ApiClient_requiredParameterFails() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.assertNotNull(null, 'bar'); - } catch (NullPointerException e) { - System.assertEquals('Argument cannot be null: bar', e.getMessage()); - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_extractHeadersFromResponse() { - HttpResponse res = new HttpResponse(); - res.setHeader('Content-Type', 'application/json'); - res.setHeader('Cache-Control', 'private, max-age=0'); - Map headers = new MockApiClient().getHeaders(res); - - System.assertEquals(2, headers.size()); - System.assertEquals('application/json', headers.get('Content-Type')); - System.assertEquals('private, max-age=0', headers.get('Cache-Control')); - } - - @isTest - private static void ApiClient_deserializeResponseBodyByContentType() { - MockApiClient client = new MockApiClient(); - String jsonBody = '{"red":"apple","yellow":"banana","orange":"orange"}'; - Map result1 = (Map) client - .toReturnValue(jsonBody, Map.class, 'application/json'); - - System.assertEquals(3, result1.size()); - System.assertEquals('apple', result1.get('red')); - System.assertEquals('banana', result1.get('yellow')); - System.assertEquals('orange', result1.get('orange')); - - String result2 = (String) client - .toReturnValue('Hello, World!', String.class, 'text/plain'); - - System.assertEquals('Hello, World!', result2); - } - - @isTest - private static void ApiClient_addStringifiedHeadersToRequest() { - MockApiClient client = new MockApiClient(); - Map headers = new Map{ - 'Content-Type' => 'application/json', - 'Max-Forwards' => 10 - }; - HttpRequest req = new HttpRequest(); - client.setHeaders(req, headers); - - System.assertEquals('application/json', req.getHeader('Content-Type')); - System.assertEquals('10', req.getHeader('Max-Forwards')); - } - - @isTest - private static void ApiClient_serializeRequestBodyOrFormByContentType() { - MockApiClient client = new MockApiClient(); - Map body1 = new Map{ - 'hello' => 'world', - 'foo' => 15, - 'bar' => Datetime.newInstanceGmt(2017, 1, 1, 15, 0, 0), - 'bat' => false - }; - Set expected1 = new Set{ - '"hello":"world"', - '"foo":15', - '"bar":"2017-01-01T15:00:00.000Z"', - '"bat":false' - }; - Set actual1 = new Set(client - .toBody('application/json', body1, new List()) - .removeStart('{') - .removeEnd('}') - .split(',') - ); - System.assertEquals(expected1, actual1); - - String body2 = 'Hello, World!'; - String actual2 = client.toBody('text/plain', body2, new List()); - System.assertEquals(body2, actual2); - - List form = new List{ - new Swagger.Param('hello', 'world'), - new Swagger.Param('date', '2017-01-01 15:00:00') - }; - String expected3 = 'hello=world&date=2017-01-01+15%3A00%3A00'; - String actual3 = client.toBody('application/x-www-form-urlencoded', '', form); - System.assertEquals(expected3, actual3); - } - - @isTest - private static void ApiClient_usePreferredContentTypeOrFirstInList() { - MockApiClient client = new MockApiClient(); - - Map headers1 = new Map(); - List types1 = new List{'application/xml', 'application/json', 'text/plain'}; - String result1 = client.setContentTypeHeader(types1, headers1); - System.assertEquals(1, headers1.size()); - System.assertEquals('application/json', headers1.get('Content-Type')); - System.assertEquals('application/json', result1); - - Map headers2 = new Map(); - List types2 = new List{'application/xml', 'text/plain'}; - String result2 = client.setContentTypeHeader(types2, headers2); - System.assertEquals(1, headers2.size()); - System.assertEquals('application/xml', headers2.get('Content-Type')); - System.assertEquals('application/xml', result2); - - Map headers3 = new Map(); - String result3 = client.setContentTypeHeader(new List(), headers3); - System.assertEquals(1, headers3.size()); - System.assertEquals('application/json', headers3.get('Content-Type')); - System.assertEquals('application/json', result3); - } - - @isTest - private static void ApiClient_usePreferredAcceptOrAllInListNoDefault() { - MockApiClient client = new MockApiClient(); - - Map headers1 = new Map(); - List types1 = new List{'application/xml', 'application/json', 'text/plain'}; - client.setAcceptHeader(types1, headers1); - System.assertEquals(1, headers1.size()); - System.assertEquals('application/json', headers1.get('Accept')); - - Map headers2 = new Map(); - List types2 = new List{'application/xml', 'text/plain'}; - client.setAcceptHeader(types2, headers2); - System.assertEquals(1, headers2.size()); - System.assertEquals('application/xml,text/plain', headers2.get('Accept')); - - Map headers3 = new Map(); - client.setAcceptHeader(new List(), headers3); - System.assert(headers3.isEmpty()); - } - - @isTest - private static void ApiClient_applyOnlyGivenAuthMethodsToParams() { - MockApiClient client = new MockApiClient(); - Map headers = new Map(); - Swagger.OAuth2 auth1 = new Swagger.OAuth2(); - Swagger.ApiKeyHeaderAuth auth2 = new Swagger.ApiKeyHeaderAuth('X-Authentication-Token'); - auth1.setAccessToken('boo-bat-api-key'); - auth2.setApiKey('foo-bar-api-key'); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.applyAuthentication(new List{'auth2'}, headers, new List()); - - System.assertEquals(1, headers.size()); - System.assertEquals('foo-bar-api-key', headers.get('X-Authentication-Token')); - } - - @isTest - private static void ApiClient_formUrlWithQueryParamsPathParams() { - MockApiClient client = new MockApiClient(); - String path = '/departments/{department}'; - Map params = new Map{'department' => 'finance'}; - List queryParams = new List{ - new Swagger.Param('foo', 'bar'), - new Swagger.Param('bat', '123') - }; - String expected = 'https://www.mccombs.utexas.edu/departments/finance?foo=bar&bat=123'; - String actual = client.toEndpoint(path, params, queryParams); - System.assertEquals(expected, actual); - } - - @isTest - private static void ApiClient_setupRequestWithBody() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-access-token'); - client.authentications.put('oauth_method', auth); - Test.setMock(HttpCalloutMock.class, mock); - - HttpResponse returned = client.getResponse( - 'PUT', '/courses/{course}/assignments/{assignmentId}', - new Map { - 'title' => 'Chapter 4 quiz', - 'timed' => true, - 'time' => 60, - 'points' => 20.5, - 'due' => Datetime.newInstanceGmt(2016, 5, 10, 23, 59, 59), - 'description' => '' - }, - new List(), - new List(), - new Map{ - 'course' => 'acc321', - 'assignmentId' => 5 - }, - new Map{ - 'X-Session' => 'foo-bar-444' - }, - new List{'application/json', 'application/xml'}, - new List{'application/json', 'application/xml'}, - new List{'oauth_method'} - ); - - HttpRequest req = mock.getRequest(); - String expectedUrl = 'https://www.mccombs.utexas.edu/courses/acc321/assignments/5'; - Set body = new Set(req - .getBody() - .removeStart('{') - .removeEnd('}') - .split(',') - ); - - System.assertEquals(res, returned); - System.assertEquals(expectedUrl, req.getEndpoint()); - System.assertEquals(6, body.size()); - System.assert(body.contains('"title":"Chapter 4 quiz"')); - System.assert(body.contains('"timed":true')); - System.assert(body.contains('"time":60')); - System.assert(body.contains('"points":20.5')); - System.assert(body.contains('"due":"2016-05-10T23:59:59.000Z"')); - System.assert(body.contains('"description":""')); - System.assertEquals('PUT', req.getMethod()); - System.assertEquals('Bearer foo-bar-access-token', req.getHeader('Authorization')); - System.assertEquals('foo-bar-444', req.getHeader('X-Session')); - System.assertEquals('application/json', req.getHeader('Accept')); - System.assertEquals('application/json', req.getHeader('Content-Type')); - } - - @isTest - private static void ApiClient_setupRequestWithForm() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-access-token'); - client.authentications.put('oauth_method', auth); - Test.setMock(HttpCalloutMock.class, mock); - - HttpResponse returned = client.getResponse( - 'PUT', '/courses/{course}/assignments/{assignmentId}', '', - new List(), - new List{ - new Swagger.Param('title', 'Chapter 4 quiz'), - new Swagger.Param('timed', 'true'), - new Swagger.Param('time', '60'), - new Swagger.Param('points', '20.5'), - new Swagger.Param('due', '2016-05-10 18:59:59'), - new Swagger.Param('description', 'complete & upload \'section1: advanced\'') - }, - new Map{ - 'course' => 'acc321', - 'assignmentId' => 5 - }, - new Map{ - 'X-Session' => 'foo-bar-444' - }, - new List{'text/html', 'application/xml'}, - new List{'application/x-www-form-urlencoded'}, - new List{'oauth_method'} - ); - - HttpRequest req = mock.getRequest(); - String expectedUrl = 'https://www.mccombs.utexas.edu/courses/acc321/assignments/5'; - Set body = new Set(req.getBody().split('&')); - - System.assertEquals(res, returned); - System.assertEquals(expectedUrl, req.getEndpoint()); - System.assertEquals(6, body.size()); - System.assert(body.contains('title=Chapter+4+quiz')); - System.assert(body.contains('timed=true')); - System.assert(body.contains('time=60')); - System.assert(body.contains('points=20.5')); - System.assert(body.contains('due=2016-05-10+18%3A59%3A59')); - System.assert(body.contains('description=complete+%26+upload+%27section1%3A+advanced%27')); - System.assertEquals('PUT', req.getMethod()); - System.assertEquals('Bearer foo-bar-access-token', req.getHeader('Authorization')); - System.assertEquals('foo-bar-444', req.getHeader('X-Session')); - System.assertEquals('text/html,application/xml', req.getHeader('Accept')); - System.assertEquals('application/x-www-form-urlencoded', req.getHeader('Content-Type')); - } - - @isTest - private static void ApiClient_setupRequestWithQuery() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-access-token'); - client.authentications.put('oauth_method', auth); - Test.setMock(HttpCalloutMock.class, mock); - - HttpResponse returned = client.getResponse( - 'GET', '/courses/{course}/assignments', '', - new List{ - new Swagger.Param('title', '#chapter1:section2'), - new Swagger.Param('due', '2016-05-10 18:59:59') - }, - new List(), - new Map{ - 'course' => 'acc321' - }, - new Map(), - new List{'application/xml'}, - new List{'text/plain'}, - new List{'oauth_method'} - ); - - HttpRequest req = mock.getRequest(); - List splitUrl = req.getEndpoint().split('\\?'); - String expectedUrl = 'https://www.mccombs.utexas.edu/courses/acc321/assignments'; - Set query = new Set(splitUrl.get(1).split('&')); - - System.assertEquals(res, returned); - System.assertEquals(expectedUrl, splitUrl.get(0)); - System.assertEquals(2, query.size()); - System.assert(query.contains('title=%23chapter1%3Asection2')); - System.assert(query.contains('due=2016-05-10+18%3A59%3A59')); - System.assertEquals('GET', req.getMethod()); - System.assertEquals('Bearer foo-bar-access-token', req.getHeader('Authorization')); - System.assertEquals('application/xml', req.getHeader('Accept')); - System.assertEquals('text/plain', req.getHeader('Content-Type')); - } - - @isTest - private static void ApiClient_nonSuccessfulStatusCodeException() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-access-token'); - client.authentications.put('oauth_method', auth); - Test.setMock(HttpCalloutMock.class, mock); - - res.setStatus('Not Found'); - res.setStatusCode(404); - res.setHeader('X-Request-ID', '1234567890'); - res.setHeader('Content-Type', 'application/json'); - res.setBody('{"error":"the specified course does not exist"}'); - - try { - client.invoke( - 'GET', '/courses/{course}', '', - new List(), - new List(), - new Map{ - 'course' => 'acc321' - }, - new Map(), - new List{'application/json'}, - new List{'text/plain'}, - new List{'oauth_method'}, - null - ); - } catch (Swagger.ApiException e) { - Map headers = e.getHeaders(); - - System.assertEquals('API returned HTTP 404: Not Found', e.getMessage()); - System.assertEquals(404, e.getStatusCode()); - System.assertEquals('Not Found', e.getStatus()); - System.assertEquals('{"error":"the specified course does not exist"}', e.getBody()); - System.assertEquals(2, headers.size()); - System.assertEquals('1234567890', headers.get('X-Request-ID')); - System.assertEquals('application/json', headers.get('Content-Type')); - return; - } - - System.assert(false); - } - - @isTest - private static void ApiClient_returnParsedBody() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Test.setMock(HttpCalloutMock.class, mock); - - res.setStatus('OK'); - res.setStatusCode(200); - res.setHeader('Content-Type', 'application/json'); - res.setBody('{' - + '"city":"Austin","country":"United States","latitude":30.28403639999999,' - + '"longitude":-97.73789449999998,"postalCode":"78705","state":"Texas",' - + '"street":"2110 Speedway"}'); - - Address a = (Address) client.invoke( - 'GET', '/address', '', - new List(), - new List(), - new Map(), - new Map(), - new List{'application/json'}, - new List{'text/plain'}, - new List(), - Address.class - ); - - System.assertEquals('Austin', a.getCity()); - System.assertEquals('United States', a.getCountry()); - System.assertEquals(30.28403639999999, a.getLatitude()); - System.assertEquals(-97.73789449999998, a.getLongitude()); - System.assertEquals('78705', a.getPostalCode()); - System.assertEquals('Texas', a.getState()); - System.assertEquals('2110 Speedway', a.getStreet()); - } - - @isTest - private static void ApiClient_noReturnTypeReturnsNull() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Test.setMock(HttpCalloutMock.class, mock); - - res.setStatus('OK'); - res.setStatusCode(200); - - Object o = client.invoke( - 'POST', '/address', '', - new List(), - new List(), - new Map(), - new Map(), - new List{'application/json'}, - new List{'text/plain'}, - new List(), - null - ); - - System.assertEquals(null, o); - } - - private class MockApiClient extends Swagger.ApiClient { - public MockApiClient() { - basePath = 'https://www.mccombs.utexas.edu'; - } - } -} \ No newline at end of file diff --git a/samples/client/petstore/apex/deploy/classes/SwaggerTest.cls-meta.xml b/samples/client/petstore/apex/deploy/classes/SwaggerTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/deploy/classes/SwaggerTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/deploy/package.xml b/samples/client/petstore/apex/deploy/package.xml deleted file mode 100644 index 9f535579566..00000000000 --- a/samples/client/petstore/apex/deploy/package.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - Swagger Petstore API Client - Client library for calling the Swagger Petstore API. -This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. -Generated with Swagger Codegen (github.com/swagger-api/swagger-codegen) - - SwagPetApi - SwagPetApiTest - SwagStoreApi - SwagStoreApiTest - SwagUserApi - SwagUserApiTest - SwagApiResponse - SwagApiResponseTest - SwagCategory - SwagCategoryTest - SwagOrder - SwagOrderTest - SwagPet - SwagPetTest - SwagTag - SwagTagTest - SwagUser - SwagUserTest - SwagClient - Swagger - SwaggerTest - SwaggerResponseMock - ApexClass - - - Swagger_Petstore - RemoteSiteSetting - - 39.0 - diff --git a/samples/client/petstore/apex/deploy/remoteSiteSettings/Swagger_Petstore.remoteSite b/samples/client/petstore/apex/deploy/remoteSiteSettings/Swagger_Petstore.remoteSite deleted file mode 100644 index a797eaedbe5..00000000000 --- a/samples/client/petstore/apex/deploy/remoteSiteSettings/Swagger_Petstore.remoteSite +++ /dev/null @@ -1,7 +0,0 @@ - - - This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authori - false - true - http://petstore.swagger.io/v2 - \ No newline at end of file diff --git a/samples/client/petstore/apex/docs/SwagApiResponse.md b/samples/client/petstore/apex/docs/SwagApiResponse.md deleted file mode 100644 index a1e635ca251..00000000000 --- a/samples/client/petstore/apex/docs/SwagApiResponse.md +++ /dev/null @@ -1,12 +0,0 @@ - -# SwagApiResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **Integer** | | [optional] -**r_type** | **String** | | [optional] -**message** | **String** | | [optional] - - - diff --git a/samples/client/petstore/apex/docs/SwagCategory.md b/samples/client/petstore/apex/docs/SwagCategory.md deleted file mode 100644 index 9fb37feef87..00000000000 --- a/samples/client/petstore/apex/docs/SwagCategory.md +++ /dev/null @@ -1,11 +0,0 @@ - -# SwagCategory - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**name** | **String** | | [optional] - - - diff --git a/samples/client/petstore/apex/docs/SwagOrder.md b/samples/client/petstore/apex/docs/SwagOrder.md deleted file mode 100644 index 95e4b48f219..00000000000 --- a/samples/client/petstore/apex/docs/SwagOrder.md +++ /dev/null @@ -1,24 +0,0 @@ - -# SwagOrder - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**petId** | **Long** | | [optional] -**quantity** | **Integer** | | [optional] -**shipDate** | **Datetime** | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] -**complete** | **Boolean** | | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -PLACED | "placed" -APPROVED | "approved" -DELIVERED | "delivered" - - - diff --git a/samples/client/petstore/apex/docs/SwagPet.md b/samples/client/petstore/apex/docs/SwagPet.md deleted file mode 100644 index 6f73d7f9775..00000000000 --- a/samples/client/petstore/apex/docs/SwagPet.md +++ /dev/null @@ -1,24 +0,0 @@ - -# SwagPet - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**category** | [**SwagCategory**](SwagCategory.md) | | [optional] -**name** | **String** | | -**photoUrls** | **List<String>** | | -**tags** | [**List<SwagTag>**](SwagTag.md) | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -AVAILABLE | "available" -PENDING | "pending" -SOLD | "sold" - - - diff --git a/samples/client/petstore/apex/docs/SwagPetApi.md b/samples/client/petstore/apex/docs/SwagPetApi.md deleted file mode 100644 index 0911fbd0fa8..00000000000 --- a/samples/client/petstore/apex/docs/SwagPetApi.md +++ /dev/null @@ -1,414 +0,0 @@ -# SwagPetApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**addPet**](SwagPetApi.md#addPet) | **POST** /pet | Add a new pet to the store -[**deletePet**](SwagPetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -[**findPetsByStatus**](SwagPetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -[**findPetsByTags**](SwagPetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -[**getPetById**](SwagPetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -[**updatePet**](SwagPetApi.md#updatePet) | **PUT** /pet | Update an existing pet -[**updatePetWithForm**](SwagPetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -[**uploadFile**](SwagPetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image - - - -# **addPet** -> addPet(body) - -Add a new pet to the store - - - -### Example -```java -SwagPetApi api = new SwagPetApi(); -SwagClient client = api.getClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -Swagger.OAuth petstore_auth = (Swagger.OAuth) client.getAuthentication('petstore_auth'); -petstore_auth.setAccessToken('YOUR ACCESS TOKEN'); - -Map params = new Map{ - 'body' => SwagPet.getExample() -}; - -try { - // cross your fingers - api.addPet(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**SwagPet**](Pet.md)| Pet object that needs to be added to the store | - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **deletePet** -> deletePet(petId, apiKey) - -Deletes a pet - - - -### Example -```java -SwagPetApi api = new SwagPetApi(); -SwagClient client = api.getClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -Swagger.OAuth petstore_auth = (Swagger.OAuth) client.getAuthentication('petstore_auth'); -petstore_auth.setAccessToken('YOUR ACCESS TOKEN'); - -Map params = new Map{ - 'petId' => 2147483648L, - 'apiKey' => 'apiKey_example' -}; - -try { - // cross your fingers - api.deletePet(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| Pet id to delete | - **apiKey** | **String**| | [optional] - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **findPetsByStatus** -> List<SwagPet> findPetsByStatus(status) - -Finds Pets by status - -Multiple status values can be provided with comma separated strings - -### Example -```java -SwagPetApi api = new SwagPetApi(); -SwagClient client = api.getClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -Swagger.OAuth petstore_auth = (Swagger.OAuth) client.getAuthentication('petstore_auth'); -petstore_auth.setAccessToken('YOUR ACCESS TOKEN'); - -Map params = new Map{ - 'status' => new List{'available'} -}; - -try { - // cross your fingers - List result = api.findPetsByStatus(params); - System.debug(result); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] - -### Return type - -[**List<SwagPet>**](SwagPet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **findPetsByTags** -> List<SwagPet> findPetsByTags(tags) - -Finds Pets by tags - -Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - -### Example -```java -SwagPetApi api = new SwagPetApi(); -SwagClient client = api.getClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -Swagger.OAuth petstore_auth = (Swagger.OAuth) client.getAuthentication('petstore_auth'); -petstore_auth.setAccessToken('YOUR ACCESS TOKEN'); - -Map params = new Map{ - 'tags' => new List{'aeiou'} -}; - -try { - // cross your fingers - List result = api.findPetsByTags(params); - System.debug(result); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **tags** | [**List<String>**](String.md)| Tags to filter by | - -### Return type - -[**List<SwagPet>**](SwagPet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **getPetById** -> SwagPet getPetById(petId) - -Find pet by ID - -Returns a single pet - -### Example -```java -SwagPetApi api = new SwagPetApi(); -SwagClient client = api.getClient(); - -// Configure API key authorization: api_key -ApiKeyAuth api_key = (ApiKeyAuth) client.getAuthentication('api_key'); -api_key.setApiKey('YOUR API KEY'); - -Map params = new Map{ - 'petId' => 2147483648L -}; - -try { - // cross your fingers - SwagPet result = api.getPetById(params); - System.debug(result); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet to return | - -### Return type - -[**SwagPet**](SwagPet.md) - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **updatePet** -> updatePet(body) - -Update an existing pet - - - -### Example -```java -SwagPetApi api = new SwagPetApi(); -SwagClient client = api.getClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -Swagger.OAuth petstore_auth = (Swagger.OAuth) client.getAuthentication('petstore_auth'); -petstore_auth.setAccessToken('YOUR ACCESS TOKEN'); - -Map params = new Map{ - 'body' => SwagPet.getExample() -}; - -try { - // cross your fingers - api.updatePet(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**SwagPet**](Pet.md)| Pet object that needs to be added to the store | - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **updatePetWithForm** -> updatePetWithForm(petId, name, status) - -Updates a pet in the store with form data - - - -### Example -```java -SwagPetApi api = new SwagPetApi(); -SwagClient client = api.getClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -Swagger.OAuth petstore_auth = (Swagger.OAuth) client.getAuthentication('petstore_auth'); -petstore_auth.setAccessToken('YOUR ACCESS TOKEN'); - -Map params = new Map{ - 'petId' => 2147483648L, - 'name' => 'name_example', - 'status' => 'status_example' -}; - -try { - // cross your fingers - api.updatePetWithForm(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet that needs to be updated | - **name** | **String**| Updated name of the pet | [optional] - **status** | **String**| Updated status of the pet | [optional] - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/json - - -# **uploadFile** -> SwagApiResponse uploadFile(petId, additionalMetadata, file) - -uploads an image - - - -### Example -```java -SwagPetApi api = new SwagPetApi(); -SwagClient client = api.getClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -Swagger.OAuth petstore_auth = (Swagger.OAuth) client.getAuthentication('petstore_auth'); -petstore_auth.setAccessToken('YOUR ACCESS TOKEN'); - -Map params = new Map{ - 'petId' => 2147483648L, - 'additionalMetadata' => 'additionalMetadata_example', - 'file' => Blob.valueOf('Sample text file\nContents') -}; - -try { - // cross your fingers - SwagApiResponse result = api.uploadFile(params); - System.debug(result); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet to update | - **additionalMetadata** | **String**| Additional data to pass to server | [optional] - **file** | **Blob**| file to upload | [optional] - -### Return type - -[**SwagApiResponse**](SwagApiResponse.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/json - diff --git a/samples/client/petstore/apex/docs/SwagStoreApi.md b/samples/client/petstore/apex/docs/SwagStoreApi.md deleted file mode 100644 index c0212e0300f..00000000000 --- a/samples/client/petstore/apex/docs/SwagStoreApi.md +++ /dev/null @@ -1,185 +0,0 @@ -# SwagStoreApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**deleteOrder**](SwagStoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -[**getInventory**](SwagStoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -[**getOrderById**](SwagStoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -[**placeOrder**](SwagStoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet - - - -# **deleteOrder** -> deleteOrder(orderId) - -Delete purchase order by ID - -For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - -### Example -```java -SwagStoreApi api = new SwagStoreApi(); - -Map params = new Map{ - 'orderId' => 'orderId_example' -}; - -try { - // cross your fingers - api.deleteOrder(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **orderId** | **String**| ID of the order that needs to be deleted | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **getInventory** -> Map<String, Integer> getInventory() - -Returns pet inventories by status - -Returns a map of status codes to quantities - -### Example -```java -SwagStoreApi api = new SwagStoreApi(); -SwagClient client = api.getClient(); - -// Configure API key authorization: api_key -ApiKeyAuth api_key = (ApiKeyAuth) client.getAuthentication('api_key'); -api_key.setApiKey('YOUR API KEY'); - -try { - // cross your fingers - Map result = api.getInventory(); - System.debug(result); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -[**Map<String, Integer>**](Map.md) - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **getOrderById** -> SwagOrder getOrderById(orderId) - -Find purchase order by ID - -For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - -### Example -```java -SwagStoreApi api = new SwagStoreApi(); - -Map params = new Map{ - 'orderId' => 2147483648L -}; - -try { - // cross your fingers - SwagOrder result = api.getOrderById(params); - System.debug(result); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **orderId** | **Long**| ID of pet that needs to be fetched | - -### Return type - -[**SwagOrder**](SwagOrder.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **placeOrder** -> SwagOrder placeOrder(body) - -Place an order for a pet - - - -### Example -```java -SwagStoreApi api = new SwagStoreApi(); - -Map params = new Map{ - 'body' => SwagOrder.getExample() -}; - -try { - // cross your fingers - SwagOrder result = api.placeOrder(params); - System.debug(result); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**SwagOrder**](Order.md)| order placed for purchasing the pet | - -### Return type - -[**SwagOrder**](SwagOrder.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - diff --git a/samples/client/petstore/apex/docs/SwagTag.md b/samples/client/petstore/apex/docs/SwagTag.md deleted file mode 100644 index 50060654b68..00000000000 --- a/samples/client/petstore/apex/docs/SwagTag.md +++ /dev/null @@ -1,11 +0,0 @@ - -# SwagTag - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**name** | **String** | | [optional] - - - diff --git a/samples/client/petstore/apex/docs/SwagUser.md b/samples/client/petstore/apex/docs/SwagUser.md deleted file mode 100644 index a3e487966f5..00000000000 --- a/samples/client/petstore/apex/docs/SwagUser.md +++ /dev/null @@ -1,17 +0,0 @@ - -# SwagUser - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**username** | **String** | | [optional] -**firstName** | **String** | | [optional] -**lastName** | **String** | | [optional] -**email** | **String** | | [optional] -**password** | **String** | | [optional] -**phone** | **String** | | [optional] -**userStatus** | **Integer** | User Status | [optional] - - - diff --git a/samples/client/petstore/apex/docs/SwagUserApi.md b/samples/client/petstore/apex/docs/SwagUserApi.md deleted file mode 100644 index aa559ddeac2..00000000000 --- a/samples/client/petstore/apex/docs/SwagUserApi.md +++ /dev/null @@ -1,359 +0,0 @@ -# SwagUserApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**createUser**](SwagUserApi.md#createUser) | **POST** /user | Create user -[**createUsersWithArrayInput**](SwagUserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -[**createUsersWithListInput**](SwagUserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -[**deleteUser**](SwagUserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -[**getUserByName**](SwagUserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -[**loginUser**](SwagUserApi.md#loginUser) | **GET** /user/login | Logs user into the system -[**logoutUser**](SwagUserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -[**updateUser**](SwagUserApi.md#updateUser) | **PUT** /user/{username} | Updated user - - - -# **createUser** -> createUser(body) - -Create user - -This can only be done by the logged in user. - -### Example -```java -SwagUserApi api = new SwagUserApi(); - -Map params = new Map{ - 'body' => SwagUser.getExample() -}; - -try { - // cross your fingers - api.createUser(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**SwagUser**](User.md)| Created user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **createUsersWithArrayInput** -> createUsersWithArrayInput(body) - -Creates list of users with given input array - - - -### Example -```java -SwagUserApi api = new SwagUserApi(); - -Map params = new Map{ - 'body' => new List{SwagUser.getExample()} -}; - -try { - // cross your fingers - api.createUsersWithArrayInput(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**List<SwagUser>**](SwagUser.md)| List of user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **createUsersWithListInput** -> createUsersWithListInput(body) - -Creates list of users with given input array - - - -### Example -```java -SwagUserApi api = new SwagUserApi(); - -Map params = new Map{ - 'body' => new List{SwagUser.getExample()} -}; - -try { - // cross your fingers - api.createUsersWithListInput(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**List<SwagUser>**](SwagUser.md)| List of user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **deleteUser** -> deleteUser(username) - -Delete user - -This can only be done by the logged in user. - -### Example -```java -SwagUserApi api = new SwagUserApi(); - -Map params = new Map{ - 'username' => 'username_example' -}; - -try { - // cross your fingers - api.deleteUser(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be deleted | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **getUserByName** -> SwagUser getUserByName(username) - -Get user by user name - - - -### Example -```java -SwagUserApi api = new SwagUserApi(); - -Map params = new Map{ - 'username' => 'username_example' -}; - -try { - // cross your fingers - SwagUser result = api.getUserByName(params); - System.debug(result); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be fetched. Use user1 for testing. | - -### Return type - -[**SwagUser**](SwagUser.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **loginUser** -> String loginUser(username, password) - -Logs user into the system - - - -### Example -```java -SwagUserApi api = new SwagUserApi(); - -Map params = new Map{ - 'username' => 'username_example', - 'password' => 'password_example' -}; - -try { - // cross your fingers - String result = api.loginUser(params); - System.debug(result); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The user name for login | - **password** | **String**| The password for login in clear text | - -### Return type - -**String** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **logoutUser** -> logoutUser() - -Logs out current logged in user session - - - -### Example -```java -SwagUserApi api = new SwagUserApi(); - -try { - // cross your fingers - api.logoutUser(); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - - -# **updateUser** -> updateUser(username, body) - -Updated user - -This can only be done by the logged in user. - -### Example -```java -SwagUserApi api = new SwagUserApi(); - -Map params = new Map{ - 'username' => 'username_example', - 'body' => SwagUser.getExample() -}; - -try { - // cross your fingers - api.updateUser(params); -} catch (Swagger.ApiException e) { - // ...handle your exceptions -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| name that need to be deleted | - **body** | [**SwagUser**](User.md)| Updated user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - diff --git a/samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls b/samples/client/petstore/apex/force-app/main/default/classes/OAS.cls similarity index 99% rename from samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OAS.cls index bb4e44f7971..d7f4c6053ce 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OAS.cls @@ -1,4 +1,4 @@ -public class Swagger { +public class OAS { private static final String HEADER_CONTENT_TYPE = 'Content-Type'; private static final String HEADER_ACCEPT = 'Accept'; private static final String HEADER_ACCEPT_DELIMITER = ','; diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OAS.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OAS.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASApiResponse.cls similarity index 78% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASApiResponse.cls index d7d088cfcef..2cae18bc3c4 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASApiResponse.cls @@ -5,15 +5,15 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ /** * Describes the result of uploading an image resource */ -public class SwagApiResponse implements Swagger.MappedProperties { +public class OASApiResponse implements OAS.MappedProperties { /** * Get code * @return code @@ -40,8 +40,8 @@ public class SwagApiResponse implements Swagger.MappedProperties { return propertyMappings; } - public static SwagApiResponse getExample() { - SwagApiResponse apiResponse = new SwagApiResponse(); + public static OASApiResponse getExample() { + OASApiResponse apiResponse = new OASApiResponse(); apiResponse.code = 0; apiResponse.r_type = ''; apiResponse.message = ''; @@ -49,8 +49,8 @@ public class SwagApiResponse implements Swagger.MappedProperties { } public Boolean equals(Object obj) { - if (obj instanceof SwagApiResponse) { - SwagApiResponse apiResponse = (SwagApiResponse) obj; + if (obj instanceof OASApiResponse) { + OASApiResponse apiResponse = (OASApiResponse) obj; return this.code == apiResponse.code && this.r_type == apiResponse.r_type && this.message == apiResponse.message; diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASApiResponse.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASApiResponse.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASApiResponseTest.cls similarity index 54% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASApiResponseTest.cls index a7095a4f1c2..4245ce16642 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASApiResponseTest.cls @@ -1,11 +1,11 @@ @isTest -private class SwagApiResponseTest { +private class OASApiResponseTest { @isTest private static void equalsSameInstance() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = apiResponse1; - SwagApiResponse apiResponse3 = new SwagApiResponse(); - SwagApiResponse apiResponse4 = apiResponse3; + OASApiResponse apiResponse1 = OASApiResponse.getExample(); + OASApiResponse apiResponse2 = apiResponse1; + OASApiResponse apiResponse3 = new OASApiResponse(); + OASApiResponse apiResponse4 = apiResponse3; System.assert(apiResponse1.equals(apiResponse2)); System.assert(apiResponse2.equals(apiResponse1)); @@ -17,10 +17,10 @@ private class SwagApiResponseTest { @isTest private static void equalsIdenticalInstance() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse3 = new SwagApiResponse(); - SwagApiResponse apiResponse4 = new SwagApiResponse(); + OASApiResponse apiResponse1 = OASApiResponse.getExample(); + OASApiResponse apiResponse2 = OASApiResponse.getExample(); + OASApiResponse apiResponse3 = new OASApiResponse(); + OASApiResponse apiResponse4 = new OASApiResponse(); System.assert(apiResponse1.equals(apiResponse2)); System.assert(apiResponse2.equals(apiResponse1)); @@ -28,19 +28,10 @@ private class SwagApiResponseTest { System.assert(apiResponse4.equals(apiResponse3)); } - @isTest - private static void notEqualsUnlikeInstance() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = new SwagApiResponse(); - - System.assertEquals(false, apiResponse1.equals(apiResponse2)); - System.assertEquals(false, apiResponse2.equals(apiResponse1)); - } - @isTest private static void notEqualsDifferentType() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = new SwagApiResponse(); + OASApiResponse apiResponse1 = OASApiResponse.getExample(); + OASApiResponse apiResponse2 = new OASApiResponse(); System.assertEquals(false, apiResponse1.equals('foo')); System.assertEquals(false, apiResponse2.equals('foo')); @@ -48,9 +39,9 @@ private class SwagApiResponseTest { @isTest private static void notEqualsNull() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = new SwagApiResponse(); - SwagApiResponse apiResponse3; + OASApiResponse apiResponse1 = OASApiResponse.getExample(); + OASApiResponse apiResponse2 = new OASApiResponse(); + OASApiResponse apiResponse3; System.assertEquals(false, apiResponse1.equals(apiResponse3)); System.assertEquals(false, apiResponse2.equals(apiResponse3)); @@ -58,8 +49,8 @@ private class SwagApiResponseTest { @isTest private static void consistentHashCodeValue() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = new SwagApiResponse(); + OASApiResponse apiResponse1 = OASApiResponse.getExample(); + OASApiResponse apiResponse2 = new OASApiResponse(); System.assertEquals(apiResponse1.hashCode(), apiResponse1.hashCode()); System.assertEquals(apiResponse2.hashCode(), apiResponse2.hashCode()); @@ -67,10 +58,10 @@ private class SwagApiResponseTest { @isTest private static void equalInstancesHaveSameHashCode() { - SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse2 = SwagApiResponse.getExample(); - SwagApiResponse apiResponse3 = new SwagApiResponse(); - SwagApiResponse apiResponse4 = new SwagApiResponse(); + OASApiResponse apiResponse1 = OASApiResponse.getExample(); + OASApiResponse apiResponse2 = OASApiResponse.getExample(); + OASApiResponse apiResponse3 = new OASApiResponse(); + OASApiResponse apiResponse4 = new OASApiResponse(); System.assert(apiResponse1.equals(apiResponse2)); System.assert(apiResponse3.equals(apiResponse4)); @@ -80,7 +71,7 @@ private class SwagApiResponseTest { @isTest private static void maintainRenamedProperties() { - SwagApiResponse apiResponse = new SwagApiResponse(); + OASApiResponse apiResponse = new OASApiResponse(); Map propertyMappings = apiResponse.getPropertyMappings(); System.assertEquals('r_type', propertyMappings.get('type')); } diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASApiResponseTest.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASApiResponseTest.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASCategory.cls similarity index 72% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASCategory.cls index 018d73ec7d4..69f1a5c677f 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASCategory.cls @@ -5,15 +5,15 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ /** * A category for a pet */ -public class SwagCategory { +public class OASCategory { /** * Get id * @return id @@ -26,16 +26,16 @@ public class SwagCategory { */ public String name { get; set; } - public static SwagCategory getExample() { - SwagCategory category = new SwagCategory(); + public static OASCategory getExample() { + OASCategory category = new OASCategory(); category.id = 123456789L; category.name = ''; return category; } public Boolean equals(Object obj) { - if (obj instanceof SwagCategory) { - SwagCategory category = (SwagCategory) obj; + if (obj instanceof OASCategory) { + OASCategory category = (OASCategory) obj; return this.id == category.id && this.name == category.name; } diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASCategory.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASCategory.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASCategoryTest.cls similarity index 53% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASCategoryTest.cls index 8689ece6dc5..534bc3ccfb1 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASCategoryTest.cls @@ -1,11 +1,11 @@ @isTest -private class SwagCategoryTest { +private class OASCategoryTest { @isTest private static void equalsSameInstance() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = category1; - SwagCategory category3 = new SwagCategory(); - SwagCategory category4 = category3; + OASCategory category1 = OASCategory.getExample(); + OASCategory category2 = category1; + OASCategory category3 = new OASCategory(); + OASCategory category4 = category3; System.assert(category1.equals(category2)); System.assert(category2.equals(category1)); @@ -17,10 +17,10 @@ private class SwagCategoryTest { @isTest private static void equalsIdenticalInstance() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = SwagCategory.getExample(); - SwagCategory category3 = new SwagCategory(); - SwagCategory category4 = new SwagCategory(); + OASCategory category1 = OASCategory.getExample(); + OASCategory category2 = OASCategory.getExample(); + OASCategory category3 = new OASCategory(); + OASCategory category4 = new OASCategory(); System.assert(category1.equals(category2)); System.assert(category2.equals(category1)); @@ -28,19 +28,10 @@ private class SwagCategoryTest { System.assert(category4.equals(category3)); } - @isTest - private static void notEqualsUnlikeInstance() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = new SwagCategory(); - - System.assertEquals(false, category1.equals(category2)); - System.assertEquals(false, category2.equals(category1)); - } - @isTest private static void notEqualsDifferentType() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = new SwagCategory(); + OASCategory category1 = OASCategory.getExample(); + OASCategory category2 = new OASCategory(); System.assertEquals(false, category1.equals('foo')); System.assertEquals(false, category2.equals('foo')); @@ -48,9 +39,9 @@ private class SwagCategoryTest { @isTest private static void notEqualsNull() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = new SwagCategory(); - SwagCategory category3; + OASCategory category1 = OASCategory.getExample(); + OASCategory category2 = new OASCategory(); + OASCategory category3; System.assertEquals(false, category1.equals(category3)); System.assertEquals(false, category2.equals(category3)); @@ -58,8 +49,8 @@ private class SwagCategoryTest { @isTest private static void consistentHashCodeValue() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = new SwagCategory(); + OASCategory category1 = OASCategory.getExample(); + OASCategory category2 = new OASCategory(); System.assertEquals(category1.hashCode(), category1.hashCode()); System.assertEquals(category2.hashCode(), category2.hashCode()); @@ -67,10 +58,10 @@ private class SwagCategoryTest { @isTest private static void equalInstancesHaveSameHashCode() { - SwagCategory category1 = SwagCategory.getExample(); - SwagCategory category2 = SwagCategory.getExample(); - SwagCategory category3 = new SwagCategory(); - SwagCategory category4 = new SwagCategory(); + OASCategory category1 = OASCategory.getExample(); + OASCategory category2 = OASCategory.getExample(); + OASCategory category3 = new OASCategory(); + OASCategory category4 = new OASCategory(); System.assert(category1.equals(category2)); System.assert(category3.equals(category4)); diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASCategoryTest.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASCategoryTest.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/OASClient.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASClient.cls new file mode 100644 index 00000000000..a808ff44b35 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASClient.cls @@ -0,0 +1,7 @@ +public class OASClient extends OAS.ApiClient { + public OASClient() { + basePath = 'http://petstore.swagger.io/v2'; + calloutName = 'OpenAPI_Petstore'; + authentications.put('api_key', new OAS.ApiKeyHeaderAuth('api_key')); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASClient.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASClient.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASOrder.cls similarity index 86% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASOrder.cls index 47bd1aa549b..cd9e98a3e81 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASOrder.cls @@ -5,15 +5,15 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ /** * An order for a pets from the pet store */ -public class SwagOrder { +public class OASOrder { /** * Get id * @return id @@ -59,12 +59,12 @@ public class SwagOrder { */ public Boolean complete { get; set; } - public SwagOrder() { + public OASOrder() { complete = false; } - public static SwagOrder getExample() { - SwagOrder order = new SwagOrder(); + public static OASOrder getExample() { + OASOrder order = new OASOrder(); order.id = 123456789L; order.petId = 123456789L; order.quantity = 0; @@ -75,8 +75,8 @@ public class SwagOrder { } public Boolean equals(Object obj) { - if (obj instanceof SwagOrder) { - SwagOrder order = (SwagOrder) obj; + if (obj instanceof OASOrder) { + OASOrder order = (OASOrder) obj; return this.id == order.id && this.petId == order.petId && this.quantity == order.quantity diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASOrder.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASOrder.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASOrderTest.cls similarity index 60% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASOrderTest.cls index 090eea45e5e..100f10c1394 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASOrderTest.cls @@ -1,11 +1,11 @@ @isTest -private class SwagOrderTest { +private class OASOrderTest { @isTest private static void equalsSameInstance() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = order1; - SwagOrder order3 = new SwagOrder(); - SwagOrder order4 = order3; + OASOrder order1 = OASOrder.getExample(); + OASOrder order2 = order1; + OASOrder order3 = new OASOrder(); + OASOrder order4 = order3; System.assert(order1.equals(order2)); System.assert(order2.equals(order1)); @@ -17,10 +17,10 @@ private class SwagOrderTest { @isTest private static void equalsIdenticalInstance() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = SwagOrder.getExample(); - SwagOrder order3 = new SwagOrder(); - SwagOrder order4 = new SwagOrder(); + OASOrder order1 = OASOrder.getExample(); + OASOrder order2 = OASOrder.getExample(); + OASOrder order3 = new OASOrder(); + OASOrder order4 = new OASOrder(); System.assert(order1.equals(order2)); System.assert(order2.equals(order1)); @@ -28,19 +28,10 @@ private class SwagOrderTest { System.assert(order4.equals(order3)); } - @isTest - private static void notEqualsUnlikeInstance() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = new SwagOrder(); - - System.assertEquals(false, order1.equals(order2)); - System.assertEquals(false, order2.equals(order1)); - } - @isTest private static void notEqualsDifferentType() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = new SwagOrder(); + OASOrder order1 = OASOrder.getExample(); + OASOrder order2 = new OASOrder(); System.assertEquals(false, order1.equals('foo')); System.assertEquals(false, order2.equals('foo')); @@ -48,9 +39,9 @@ private class SwagOrderTest { @isTest private static void notEqualsNull() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = new SwagOrder(); - SwagOrder order3; + OASOrder order1 = OASOrder.getExample(); + OASOrder order2 = new OASOrder(); + OASOrder order3; System.assertEquals(false, order1.equals(order3)); System.assertEquals(false, order2.equals(order3)); @@ -58,8 +49,8 @@ private class SwagOrderTest { @isTest private static void consistentHashCodeValue() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = new SwagOrder(); + OASOrder order1 = OASOrder.getExample(); + OASOrder order2 = new OASOrder(); System.assertEquals(order1.hashCode(), order1.hashCode()); System.assertEquals(order2.hashCode(), order2.hashCode()); @@ -67,10 +58,10 @@ private class SwagOrderTest { @isTest private static void equalInstancesHaveSameHashCode() { - SwagOrder order1 = SwagOrder.getExample(); - SwagOrder order2 = SwagOrder.getExample(); - SwagOrder order3 = new SwagOrder(); - SwagOrder order4 = new SwagOrder(); + OASOrder order1 = OASOrder.getExample(); + OASOrder order2 = OASOrder.getExample(); + OASOrder order3 = new OASOrder(); + OASOrder order4 = new OASOrder(); System.assert(order1.equals(order2)); System.assert(order3.equals(order4)); @@ -80,7 +71,7 @@ private class SwagOrderTest { @isTest private static void defaultValuesPopulated() { - SwagOrder order = new SwagOrder(); + OASOrder order = new OASOrder(); System.assertEquals(false, order.complete); System.assertEquals(null, order.id); System.assertEquals(null, order.petId); diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASOrderTest.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASOrderTest.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASPet.cls similarity index 78% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASPet.cls index 7cd6f3a85fd..2a521f464e5 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASPet.cls @@ -5,15 +5,15 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ /** * A pet for sale in the pet store */ -public class SwagPet { +public class OASPet { /** * Get id * @return id @@ -24,7 +24,7 @@ public class SwagPet { * Get category * @return category */ - public SwagCategory category { get; set; } + public OASCategory category { get; set; } /** * Get name @@ -42,7 +42,7 @@ public class SwagPet { * Get tags * @return tags */ - public List tags { get; set; } + public List tags { get; set; } /** * pet status in the store @@ -59,25 +59,25 @@ public class SwagPet { */ public StatusEnum status { get; set; } - public SwagPet() { + public OASPet() { photoUrls = new List(); - tags = new List(); + tags = new List(); } - public static SwagPet getExample() { - SwagPet pet = new SwagPet(); + public static OASPet getExample() { + OASPet pet = new OASPet(); pet.id = 123456789L; - + pet.category = OASCategory.getExample(); pet.name = 'doggie'; pet.photoUrls = new List{''}; - pet.tags = new List{null}; + pet.tags = new List{OASTag.getExample()}; pet.status = StatusEnum.AVAILABLE; return pet; } public Boolean equals(Object obj) { - if (obj instanceof SwagPet) { - SwagPet pet = (SwagPet) obj; + if (obj instanceof OASPet) { + OASPet pet = (OASPet) obj; return this.id == pet.id && this.category == pet.category && this.name == pet.name diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASPet.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASPet.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASPetApi.cls similarity index 66% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASPetApi.cls index 8c680e2b193..331cb6d2ef1 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASPetApi.cls @@ -5,40 +5,40 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ -public class SwagPetApi { - SwagClient client; +public class OASPetApi { + OASClient client; - public SwagPetApi(SwagClient client) { + public OASPetApi(OASClient client) { this.client = client; } - public SwagPetApi() { - this.client = new SwagClient(); + public OASPetApi() { + this.client = new OASClient(); } - public SwagClient getClient() { + public OASClient getClient() { return this.client; } /** * Add a new pet to the store * - * @param swagPet Pet object that needs to be added to the store (required) - * @throws Swagger.ApiException if fails to make API call + * @param oaSPet Pet object that needs to be added to the store (required) + * @throws OAS.ApiException if fails to make API call */ public void addPet(Map params) { - client.assertNotNull(params.get('swagPet'), 'swagPet'); - List query = new List(); - List form = new List(); + client.assertNotNull(params.get('oaSPet'), 'oaSPet'); + List query = new List(); + List form = new List(); client.invoke( 'POST', '/pet', - (SwagPet) params.get('swagPet'), + (OASPet) params.get('oaSPet'), query, form, new Map(), new Map(), @@ -53,12 +53,12 @@ public class SwagPetApi { * * @param petId Pet id to delete (required) * @param apiKey (optional) - * @throws Swagger.ApiException if fails to make API call + * @throws OAS.ApiException if fails to make API call */ public void deletePet(Map params) { client.assertNotNull(params.get('petId'), 'petId'); - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); client.invoke( 'DELETE', '/pet/{petId}', '', @@ -79,19 +79,19 @@ public class SwagPetApi { * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter (required) - * @return List - * @throws Swagger.ApiException if fails to make API call + * @return List + * @throws OAS.ApiException if fails to make API call */ - public List findPetsByStatus(Map params) { + public List findPetsByStatus(Map params) { client.assertNotNull(params.get('status'), 'status'); - List query = new List(); + List query = new List(); // cast query params to verify their expected type query.addAll(client.makeParam('status', (List) params.get('status'), 'csv')); - List form = new List(); + List form = new List(); - return (List) client.invoke( + return (List) client.invoke( 'GET', '/pet/findByStatus', '', query, form, new Map(), @@ -99,26 +99,26 @@ public class SwagPetApi { new List{ 'application/xml', 'application/json' }, new List(), new List { 'petstore_auth' }, - List.class + List.class ); } /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by (required) - * @return List - * @throws Swagger.ApiException if fails to make API call + * @return List + * @throws OAS.ApiException if fails to make API call */ - public List findPetsByTags(Map params) { + public List findPetsByTags(Map params) { client.assertNotNull(params.get('tags'), 'tags'); - List query = new List(); + List query = new List(); // cast query params to verify their expected type query.addAll(client.makeParam('tags', (List) params.get('tags'), 'csv')); - List form = new List(); + List form = new List(); - return (List) client.invoke( + return (List) client.invoke( 'GET', '/pet/findByTags', '', query, form, new Map(), @@ -126,22 +126,22 @@ public class SwagPetApi { new List{ 'application/xml', 'application/json' }, new List(), new List { 'petstore_auth' }, - List.class + List.class ); } /** * Find pet by ID * Returns a single pet * @param petId ID of pet to return (required) - * @return SwagPet - * @throws Swagger.ApiException if fails to make API call + * @return OASPet + * @throws OAS.ApiException if fails to make API call */ - public SwagPet getPetById(Map params) { + public OASPet getPetById(Map params) { client.assertNotNull(params.get('petId'), 'petId'); - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); - return (SwagPet) client.invoke( + return (OASPet) client.invoke( 'GET', '/pet/{petId}', '', query, form, new Map{ @@ -151,23 +151,23 @@ public class SwagPetApi { new List{ 'application/xml', 'application/json' }, new List(), new List { 'api_key' }, - SwagPet.class + OASPet.class ); } /** * Update an existing pet * - * @param swagPet Pet object that needs to be added to the store (required) - * @throws Swagger.ApiException if fails to make API call + * @param oaSPet Pet object that needs to be added to the store (required) + * @throws OAS.ApiException if fails to make API call */ public void updatePet(Map params) { - client.assertNotNull(params.get('swagPet'), 'swagPet'); - List query = new List(); - List form = new List(); + client.assertNotNull(params.get('oaSPet'), 'oaSPet'); + List query = new List(); + List form = new List(); client.invoke( 'PUT', '/pet', - (SwagPet) params.get('swagPet'), + (OASPet) params.get('oaSPet'), query, form, new Map(), new Map(), @@ -183,12 +183,12 @@ public class SwagPetApi { * @param petId ID of pet that needs to be updated (required) * @param name Updated name of the pet (optional) * @param status Updated status of the pet (optional) - * @throws Swagger.ApiException if fails to make API call + * @throws OAS.ApiException if fails to make API call */ public void updatePetWithForm(Map params) { client.assertNotNull(params.get('petId'), 'petId'); - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); // cast form params to verify their expected type form.addAll(client.makeParam('name', (String) params.get('name'))); @@ -213,19 +213,19 @@ public class SwagPetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return SwagApiResponse - * @throws Swagger.ApiException if fails to make API call + * @return OASApiResponse + * @throws OAS.ApiException if fails to make API call */ - public SwagApiResponse uploadFile(Map params) { + public OASApiResponse uploadFile(Map params) { client.assertNotNull(params.get('petId'), 'petId'); - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); // cast form params to verify their expected type form.addAll(client.makeParam('additionalMetadata', (String) params.get('additionalMetadata'))); form.addAll(client.makeParam('file', (Blob) params.get('file'))); - return (SwagApiResponse) client.invoke( + return (OASApiResponse) client.invoke( 'POST', '/pet/{petId}/uploadImage', '', query, form, new Map{ @@ -235,7 +235,7 @@ public class SwagPetApi { new List{ 'application/json' }, new List{ 'multipart/form-data' }, new List { 'petstore_auth' }, - SwagApiResponse.class + OASApiResponse.class ); } } diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASPetApi.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASPetApi.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/OASPetApiTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASPetApiTest.cls new file mode 100644 index 00000000000..1eaf5a3ad2b --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASPetApiTest.cls @@ -0,0 +1,265 @@ +@isTest +private class OASPetApiTest { + /** + * Add a new pet to the store + * + * + */ + @isTest + private static void addPetTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(201); + res.setStatus('Created'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'oaSPet' => OASPet.getExample() + }; + + OASClient client; + OASPetApi api; + String js = ''; + + client = new OASClient(); + api = new OASPetApi(client); + api.addPet(params); + } + + /** + * Deletes a pet + * + * + */ + @isTest + private static void deletePetTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'petId' => 2147483648L, + 'apiKey' => 'null' + }; + + OASClient client; + OASPetApi api; + String js = ''; + + client = new OASClient(); + api = new OASPetApi(client); + api.deletePet(params); + } + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + */ + @isTest + private static void findPetsByStatusTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'status' => new List{'available'} + }; + + OASClient client; + OASPetApi api; + List response; + List expectedResponse; + String js = ''; + + client = new OASClient(); + api = new OASPetApi(client); + + js = JSON.serialize(new List{OASPet.getExample()}); + res.setHeader('Content-Type', 'application/json'); + res.setBody(js); + expectedResponse = new List{OASPet.getExample()}; + response = (List) api.findPetsByStatus(params); + System.assertEquals(expectedResponse, response); + + + js = JSON.serialize(new List{OASPet.getExample()}); + res.setHeader('Content-Type', 'application/xml'); + res.setBody(js); + expectedResponse = new List{OASPet.getExample()}; + response = (List) api.findPetsByStatus(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + */ + @isTest + private static void findPetsByTagsTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'tags' => new List{''} + }; + + OASClient client; + OASPetApi api; + List response; + List expectedResponse; + String js = ''; + + client = new OASClient(); + api = new OASPetApi(client); + + js = JSON.serialize(new List{OASPet.getExample()}); + res.setHeader('Content-Type', 'application/json'); + res.setBody(js); + expectedResponse = new List{OASPet.getExample()}; + response = (List) api.findPetsByTags(params); + System.assertEquals(expectedResponse, response); + + + js = JSON.serialize(new List{OASPet.getExample()}); + res.setHeader('Content-Type', 'application/xml'); + res.setBody(js); + expectedResponse = new List{OASPet.getExample()}; + response = (List) api.findPetsByTags(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Find pet by ID + * + * Returns a single pet + */ + @isTest + private static void getPetByIdTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'petId' => 2147483648L + }; + + OASClient client; + OASPetApi api; + OASPet response; + OASPet expectedResponse; + String js = ''; + + client = new OASClient(); + api = new OASPetApi(client); + ((OAS.ApiKeyAuth)client.getAuthentication('api_key')).setApiKey('foo-bar-api-key'); + + + js = JSON.serialize(OASPet.getExample()); + res.setHeader('Content-Type', 'application/json'); + res.setBody(js); + expectedResponse = OASPet.getExample(); + response = (OASPet) api.getPetById(params); + System.assertEquals(expectedResponse, response); + + + js = JSON.serialize(OASPet.getExample()); + res.setHeader('Content-Type', 'application/xml'); + res.setBody(js); + expectedResponse = OASPet.getExample(); + response = (OASPet) api.getPetById(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Update an existing pet + * + * + */ + @isTest + private static void updatePetTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'oaSPet' => OASPet.getExample() + }; + + OASClient client; + OASPetApi api; + String js = ''; + + client = new OASClient(); + api = new OASPetApi(client); + api.updatePet(params); + } + + /** + * Updates a pet in the store with form data + * + * + */ + @isTest + private static void updatePetWithFormTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'petId' => 2147483648L, + 'name' => 'null', + 'status' => 'null' + }; + + OASClient client; + OASPetApi api; + String js = ''; + + client = new OASClient(); + api = new OASPetApi(client); + api.updatePetWithForm(params); + } + + /** + * uploads an image + * + * + */ + @isTest + private static void uploadFileTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'petId' => 2147483648L, + 'additionalMetadata' => 'null', + 'file' => Blob.valueOf('Sample text file\nContents') + }; + + OASClient client; + OASPetApi api; + OASApiResponse response; + OASApiResponse expectedResponse; + String js = ''; + + client = new OASClient(); + api = new OASPetApi(client); + + js = JSON.serialize(OASApiResponse.getExample()); + res.setHeader('Content-Type', 'application/json'); + res.setBody(js); + expectedResponse = OASApiResponse.getExample(); + response = (OASApiResponse) api.uploadFile(params); + System.assertEquals(expectedResponse, response); + } +} \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASPetApiTest.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASPetApiTest.cls-meta.xml diff --git a/samples/client/petstore/apex/deploy/classes/SwagPetTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASPetTest.cls similarity index 60% rename from samples/client/petstore/apex/deploy/classes/SwagPetTest.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASPetTest.cls index 30b6d88b963..b0aa4c692a3 100644 --- a/samples/client/petstore/apex/deploy/classes/SwagPetTest.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASPetTest.cls @@ -1,11 +1,11 @@ @isTest -private class SwagPetTest { +private class OASPetTest { @isTest private static void equalsSameInstance() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = pet1; - SwagPet pet3 = new SwagPet(); - SwagPet pet4 = pet3; + OASPet pet1 = OASPet.getExample(); + OASPet pet2 = pet1; + OASPet pet3 = new OASPet(); + OASPet pet4 = pet3; System.assert(pet1.equals(pet2)); System.assert(pet2.equals(pet1)); @@ -17,10 +17,10 @@ private class SwagPetTest { @isTest private static void equalsIdenticalInstance() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = SwagPet.getExample(); - SwagPet pet3 = new SwagPet(); - SwagPet pet4 = new SwagPet(); + OASPet pet1 = OASPet.getExample(); + OASPet pet2 = OASPet.getExample(); + OASPet pet3 = new OASPet(); + OASPet pet4 = new OASPet(); System.assert(pet1.equals(pet2)); System.assert(pet2.equals(pet1)); @@ -28,19 +28,10 @@ private class SwagPetTest { System.assert(pet4.equals(pet3)); } - @isTest - private static void notEqualsUnlikeInstance() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = new SwagPet(); - - System.assertEquals(false, pet1.equals(pet2)); - System.assertEquals(false, pet2.equals(pet1)); - } - @isTest private static void notEqualsDifferentType() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = new SwagPet(); + OASPet pet1 = OASPet.getExample(); + OASPet pet2 = new OASPet(); System.assertEquals(false, pet1.equals('foo')); System.assertEquals(false, pet2.equals('foo')); @@ -48,9 +39,9 @@ private class SwagPetTest { @isTest private static void notEqualsNull() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = new SwagPet(); - SwagPet pet3; + OASPet pet1 = OASPet.getExample(); + OASPet pet2 = new OASPet(); + OASPet pet3; System.assertEquals(false, pet1.equals(pet3)); System.assertEquals(false, pet2.equals(pet3)); @@ -58,8 +49,8 @@ private class SwagPetTest { @isTest private static void consistentHashCodeValue() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = new SwagPet(); + OASPet pet1 = OASPet.getExample(); + OASPet pet2 = new OASPet(); System.assertEquals(pet1.hashCode(), pet1.hashCode()); System.assertEquals(pet2.hashCode(), pet2.hashCode()); @@ -67,10 +58,10 @@ private class SwagPetTest { @isTest private static void equalInstancesHaveSameHashCode() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = SwagPet.getExample(); - SwagPet pet3 = new SwagPet(); - SwagPet pet4 = new SwagPet(); + OASPet pet1 = OASPet.getExample(); + OASPet pet2 = OASPet.getExample(); + OASPet pet3 = new OASPet(); + OASPet pet4 = new OASPet(); System.assert(pet1.equals(pet2)); System.assert(pet3.equals(pet4)); @@ -80,9 +71,9 @@ private class SwagPetTest { @isTest private static void defaultValuesPopulated() { - SwagPet pet = new SwagPet(); + OASPet pet = new OASPet(); System.assertEquals(new List(), pet.photoUrls); - System.assertEquals(new List(), pet.tags); + System.assertEquals(new List(), pet.tags); System.assertEquals(null, pet.id); System.assertEquals(null, pet.category); System.assertEquals(null, pet.name); diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASPetTest.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASPetTest.cls-meta.xml diff --git a/modules/openapi-generator/src/main/resources/apex/SwaggerResponseMock.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASResponseMock.cls similarity index 72% rename from modules/openapi-generator/src/main/resources/apex/SwaggerResponseMock.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASResponseMock.cls index 7d3acb1a91f..a6931145c52 100644 --- a/modules/openapi-generator/src/main/resources/apex/SwaggerResponseMock.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASResponseMock.cls @@ -1,9 +1,9 @@ @isTest -public class SwaggerResponseMock implements HttpCalloutMock { +public class OASResponseMock implements HttpCalloutMock { private final HttpResponse response; private HttpRequest request; - public SwaggerResponseMock(HttpResponse response) { + public OASResponseMock(HttpResponse response) { this.response = response; } diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASResponseMock.cls-meta.xml similarity index 100% rename from samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASResponseMock.cls-meta.xml diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASStoreApi.cls similarity index 62% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASStoreApi.cls index 36acaad1504..215f61329f0 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASStoreApi.cls @@ -5,23 +5,23 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ -public class SwagStoreApi { - SwagClient client; +public class OASStoreApi { + OASClient client; - public SwagStoreApi(SwagClient client) { + public OASStoreApi(OASClient client) { this.client = client; } - public SwagStoreApi() { - this.client = new SwagClient(); + public OASStoreApi() { + this.client = new OASClient(); } - public SwagClient getClient() { + public OASClient getClient() { return this.client; } @@ -29,12 +29,12 @@ public class SwagStoreApi { * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted (required) - * @throws Swagger.ApiException if fails to make API call + * @throws OAS.ApiException if fails to make API call */ public void deleteOrder(Map params) { client.assertNotNull(params.get('orderId'), 'orderId'); - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); client.invoke( 'DELETE', '/store/order/{orderId}', '', @@ -53,11 +53,11 @@ public class SwagStoreApi { * Returns pet inventories by status * Returns a map of status codes to quantities * @return Map - * @throws Swagger.ApiException if fails to make API call + * @throws OAS.ApiException if fails to make API call */ public Map getInventory() { - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); return (Map) client.invoke( 'GET', '/store/inventory', '', @@ -74,15 +74,15 @@ public class SwagStoreApi { * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched (required) - * @return SwagOrder - * @throws Swagger.ApiException if fails to make API call + * @return OASOrder + * @throws OAS.ApiException if fails to make API call */ - public SwagOrder getOrderById(Map params) { + public OASOrder getOrderById(Map params) { client.assertNotNull(params.get('orderId'), 'orderId'); - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); - return (SwagOrder) client.invoke( + return (OASOrder) client.invoke( 'GET', '/store/order/{orderId}', '', query, form, new Map{ @@ -92,31 +92,31 @@ public class SwagStoreApi { new List{ 'application/xml', 'application/json' }, new List(), new List(), - SwagOrder.class + OASOrder.class ); } /** * Place an order for a pet * - * @param swagOrder order placed for purchasing the pet (required) - * @return SwagOrder - * @throws Swagger.ApiException if fails to make API call + * @param oaSOrder order placed for purchasing the pet (required) + * @return OASOrder + * @throws OAS.ApiException if fails to make API call */ - public SwagOrder placeOrder(Map params) { - client.assertNotNull(params.get('swagOrder'), 'swagOrder'); - List query = new List(); - List form = new List(); + public OASOrder placeOrder(Map params) { + client.assertNotNull(params.get('oaSOrder'), 'oaSOrder'); + List query = new List(); + List form = new List(); - return (SwagOrder) client.invoke( + return (OASOrder) client.invoke( 'POST', '/store/order', - (SwagOrder) params.get('swagOrder'), + (OASOrder) params.get('oaSOrder'), query, form, new Map(), new Map(), new List{ 'application/xml', 'application/json' }, new List(), new List(), - SwagOrder.class + OASOrder.class ); } } diff --git a/samples/client/petstore/apex/deploy/classes/SwagApiResponse.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASStoreApi.cls-meta.xml similarity index 80% rename from samples/client/petstore/apex/deploy/classes/SwagApiResponse.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASStoreApi.cls-meta.xml index 8b061c82b6f..fec71a26693 100644 --- a/samples/client/petstore/apex/deploy/classes/SwagApiResponse.cls-meta.xml +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASStoreApi.cls-meta.xml @@ -1,5 +1,5 @@ - 39.0 + 42.0 Active diff --git a/samples/client/petstore/apex/force-app/main/default/classes/OASStoreApiTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASStoreApiTest.cls new file mode 100644 index 00000000000..548c228a651 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASStoreApiTest.cls @@ -0,0 +1,130 @@ +@isTest +private class OASStoreApiTest { + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + */ + @isTest + private static void deleteOrderTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'orderId' => 'null' + }; + + OASClient client; + OASStoreApi api; + String js = ''; + + api = new OASStoreApi(new OASClient()); + + api.deleteOrder(params); + } + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + */ + @isTest + private static void getInventoryTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + OASClient client; + OASStoreApi api; + Map response; + Map expectedResponse; + String js = ''; + + client = new OASClient(); + api = new OASStoreApi(client); + ((OAS.ApiKeyAuth)client.getAuthentication('api_key')).setApiKey('foo-bar-api-key'); + + api.getInventory(); + } + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + */ + @isTest + private static void getOrderByIdTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'orderId' => 2147483648L + }; + + OASClient client; + OASStoreApi api; + OASOrder response; + OASOrder expectedResponse; + String js = ''; + + api = new OASStoreApi(new OASClient()); + + js = JSON.serialize(OASOrder.getExample()); + res.setHeader('Content-Type', 'application/json'); + res.setBody(js); + expectedResponse = OASOrder.getExample(); + response = (OASOrder) api.getOrderById(params); + System.assertEquals(expectedResponse, response); + + js = JSON.serialize(OASOrder.getExample()); + res.setHeader('Content-Type', 'application/xml'); + res.setBody(js); + expectedResponse = OASOrder.getExample(); + response = (OASOrder) api.getOrderById(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Place an order for a pet + * + * + */ + @isTest + private static void placeOrderTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); + + Map params = new Map{ + 'oaSOrder' => OASOrder.getExample() + }; + + OASClient client; + OASStoreApi api; + OASOrder response; + OASOrder expectedResponse; + String js = ''; + + api = new OASStoreApi(new OASClient()); + + js = JSON.serialize(OASOrder.getExample()); + res.setHeader('Content-Type', 'application/json'); + res.setBody(js); + expectedResponse = OASOrder.getExample(); + response = (OASOrder) api.placeOrder(params); + System.assertEquals(expectedResponse, response); + + js = JSON.serialize(OASOrder.getExample()); + res.setHeader('Content-Type', 'application/xml'); + res.setBody(js); + expectedResponse = OASOrder.getExample(); + response = (OASOrder) api.placeOrder(params); + System.assertEquals(expectedResponse, response); + } +} \ No newline at end of file diff --git a/samples/client/petstore/apex/deploy/classes/SwagApiResponseTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASStoreApiTest.cls-meta.xml similarity index 80% rename from samples/client/petstore/apex/deploy/classes/SwagApiResponseTest.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASStoreApiTest.cls-meta.xml index 38aa015d1fc..fec71a26693 100644 --- a/samples/client/petstore/apex/deploy/classes/SwagApiResponseTest.cls-meta.xml +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASStoreApiTest.cls-meta.xml @@ -1,5 +1,5 @@ - 36.0 + 42.0 Active diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASTag.cls similarity index 74% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASTag.cls index b6414b68597..d3658da066c 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASTag.cls @@ -5,15 +5,15 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ /** * A tag for a pet */ -public class SwagTag { +public class OASTag { /** * Get id * @return id @@ -26,16 +26,16 @@ public class SwagTag { */ public String name { get; set; } - public static SwagTag getExample() { - SwagTag tag = new SwagTag(); + public static OASTag getExample() { + OASTag tag = new OASTag(); tag.id = 123456789L; tag.name = ''; return tag; } public Boolean equals(Object obj) { - if (obj instanceof SwagTag) { - SwagTag tag = (SwagTag) obj; + if (obj instanceof OASTag) { + OASTag tag = (OASTag) obj; return this.id == tag.id && this.name == tag.name; } diff --git a/samples/client/petstore/apex/deploy/classes/SwagCategory.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASTag.cls-meta.xml similarity index 80% rename from samples/client/petstore/apex/deploy/classes/SwagCategory.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASTag.cls-meta.xml index 8b061c82b6f..fec71a26693 100644 --- a/samples/client/petstore/apex/deploy/classes/SwagCategory.cls-meta.xml +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASTag.cls-meta.xml @@ -1,5 +1,5 @@ - 39.0 + 42.0 Active diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASTagTest.cls similarity index 57% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASTagTest.cls index beee6690404..43dd1732a9d 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASTagTest.cls @@ -1,11 +1,11 @@ @isTest -private class SwagTagTest { +private class OASTagTest { @isTest private static void equalsSameInstance() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = tag1; - SwagTag tag3 = new SwagTag(); - SwagTag tag4 = tag3; + OASTag tag1 = OASTag.getExample(); + OASTag tag2 = tag1; + OASTag tag3 = new OASTag(); + OASTag tag4 = tag3; System.assert(tag1.equals(tag2)); System.assert(tag2.equals(tag1)); @@ -17,10 +17,10 @@ private class SwagTagTest { @isTest private static void equalsIdenticalInstance() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = SwagTag.getExample(); - SwagTag tag3 = new SwagTag(); - SwagTag tag4 = new SwagTag(); + OASTag tag1 = OASTag.getExample(); + OASTag tag2 = OASTag.getExample(); + OASTag tag3 = new OASTag(); + OASTag tag4 = new OASTag(); System.assert(tag1.equals(tag2)); System.assert(tag2.equals(tag1)); @@ -28,19 +28,10 @@ private class SwagTagTest { System.assert(tag4.equals(tag3)); } - @isTest - private static void notEqualsUnlikeInstance() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = new SwagTag(); - - System.assertEquals(false, tag1.equals(tag2)); - System.assertEquals(false, tag2.equals(tag1)); - } - @isTest private static void notEqualsDifferentType() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = new SwagTag(); + OASTag tag1 = OASTag.getExample(); + OASTag tag2 = new OASTag(); System.assertEquals(false, tag1.equals('foo')); System.assertEquals(false, tag2.equals('foo')); @@ -48,9 +39,9 @@ private class SwagTagTest { @isTest private static void notEqualsNull() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = new SwagTag(); - SwagTag tag3; + OASTag tag1 = OASTag.getExample(); + OASTag tag2 = new OASTag(); + OASTag tag3; System.assertEquals(false, tag1.equals(tag3)); System.assertEquals(false, tag2.equals(tag3)); @@ -58,8 +49,8 @@ private class SwagTagTest { @isTest private static void consistentHashCodeValue() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = new SwagTag(); + OASTag tag1 = OASTag.getExample(); + OASTag tag2 = new OASTag(); System.assertEquals(tag1.hashCode(), tag1.hashCode()); System.assertEquals(tag2.hashCode(), tag2.hashCode()); @@ -67,10 +58,10 @@ private class SwagTagTest { @isTest private static void equalInstancesHaveSameHashCode() { - SwagTag tag1 = SwagTag.getExample(); - SwagTag tag2 = SwagTag.getExample(); - SwagTag tag3 = new SwagTag(); - SwagTag tag4 = new SwagTag(); + OASTag tag1 = OASTag.getExample(); + OASTag tag2 = OASTag.getExample(); + OASTag tag3 = new OASTag(); + OASTag tag4 = new OASTag(); System.assert(tag1.equals(tag2)); System.assert(tag3.equals(tag4)); diff --git a/samples/client/petstore/apex/deploy/classes/SwagCategoryTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASTagTest.cls-meta.xml similarity index 80% rename from samples/client/petstore/apex/deploy/classes/SwagCategoryTest.cls-meta.xml rename to samples/client/petstore/apex/force-app/main/default/classes/OASTagTest.cls-meta.xml index 38aa015d1fc..fec71a26693 100644 --- a/samples/client/petstore/apex/deploy/classes/SwagCategoryTest.cls-meta.xml +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASTagTest.cls-meta.xml @@ -1,5 +1,5 @@ - 36.0 + 42.0 Active diff --git a/modules/openapi-generator/src/main/resources/apex/SwaggerTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASTest.cls similarity index 83% rename from modules/openapi-generator/src/main/resources/apex/SwaggerTest.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASTest.cls index d95e9b60aa8..e1c73d185e4 100644 --- a/modules/openapi-generator/src/main/resources/apex/SwaggerTest.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASTest.cls @@ -1,19 +1,19 @@ @isTest -private class SwaggerTest { +private class OASTest { @isTest private static void Param_urlEncodeKeyValuePairUtf8() { String toEncodeLeft = 'Hello +%-_.!~*\'()@'; String toEncodeRight = 'World +%-_.!~*\'()@'; String expected = 'Hello+%2B%25-_.%21%7E*%27%28%29%40=World+%2B%25-_.%21%7E*%27%28%29%40'; - String result = new Swagger.Param(toEncodeLeft, toEncodeRight).toString(); + String result = new OAS.Param(toEncodeLeft, toEncodeRight).toString(); System.assertEquals(expected, result); } @isTest private static void ApiKeyHeaderAuth_keyInHeaderWithGivenName() { Map headers = new Map(); - List query = new List(); - Swagger.ApiKeyHeaderAuth auth = new Swagger.ApiKeyHeaderAuth('X-Authenticate'); + List query = new List(); + OAS.ApiKeyHeaderAuth auth = new OAS.ApiKeyHeaderAuth('X-Authenticate'); auth.setApiKey('foo-bar-api-key'); auth.apply(headers, query); @@ -25,8 +25,8 @@ private class SwaggerTest { @isTest private static void ApiKeyQueryAuth_keyInQueryParamWithGivenName() { Map headers = new Map(); - List query = new List(); - Swagger.ApiKeyQueryAuth auth = new Swagger.ApiKeyQueryAuth('auth_token'); + List query = new List(); + OAS.ApiKeyQueryAuth auth = new OAS.ApiKeyQueryAuth('auth_token'); auth.setApiKey('foo-bar-api-key'); auth.apply(headers, query); @@ -38,8 +38,8 @@ private class SwaggerTest { @isTest private static void ApiClient_returnAuthenticationMatchingInput() { MockApiClient client = new MockApiClient(); - Swagger.ApiKeyHeaderAuth auth1 = new Swagger.ApiKeyHeaderAuth('foo'); - Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('foo'); + OAS.ApiKeyHeaderAuth auth1 = new OAS.ApiKeyHeaderAuth('foo'); + OAS.ApiKeyQueryAuth auth2 = new OAS.ApiKeyQueryAuth('foo'); client.authentications.put('auth1', auth1); client.authentications.put('auth2', auth2); @@ -51,8 +51,8 @@ private class SwaggerTest { @isTest private static void ApiClient_oneKeyValuePairForEachValueInList() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParams('foo', values); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParams('foo', values); System.assertEquals(5, params.size()); System.assertEquals('foo=bar', params.get(0).toString()); @@ -64,8 +64,8 @@ private class SwaggerTest { @isTest private static void ApiClient_nullMultiValuesListToEmptyParamsList() { - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParams('foo', null); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParams('foo', null); System.assert(params.isEmpty()); } @@ -73,8 +73,8 @@ private class SwaggerTest { @isTest private static void ApiClient_valuesListToSingleCsvKeyValuePair() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'csv'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', values, 'csv'); System.assertEquals(1, params.size()); System.assertEquals('foo=bar%2C4%2Cfalse%2C12.4%2C', params.get(0).toString()); @@ -83,8 +83,8 @@ private class SwaggerTest { @isTest private static void ApiClient_valuesListToSingleSsvKeyValuePair() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'ssv'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', values, 'ssv'); System.assertEquals(1, params.size()); System.assertEquals('foo=bar+4+false+12.4+', params.get(0).toString()); @@ -93,8 +93,8 @@ private class SwaggerTest { @isTest private static void ApiClient_valuesListToSingleTsvKeyValuePair() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'tsv'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', values, 'tsv'); System.assertEquals(1, params.size()); System.assertEquals('foo=bar%094%09false%0912.4%09', params.get(0).toString()); @@ -103,8 +103,8 @@ private class SwaggerTest { @isTest private static void ApiClient_valuesListToSinglePipeSeparatedKeyValuePair() { List values = new List{'bar', 4, false, 12.4, ''}; - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', values, 'pipes'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', values, 'pipes'); System.assertEquals(1, params.size()); System.assertEquals('foo=bar%7C4%7Cfalse%7C12.4%7C', params.get(0).toString()); @@ -112,16 +112,16 @@ private class SwaggerTest { @isTest private static void ApiClient_nullValuesListToEmptyParamsList() { - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = client.makeParam('foo', null, 'csv'); + OAS.ApiClient client = new OAS.ApiClient(); + List params = client.makeParam('foo', null, 'csv'); System.assert(params.isEmpty()); } @isTest private static void ApiClient_paramsFromAnyPrimitiveTypeDiscardNull() { - Swagger.ApiClient client = new Swagger.ApiClient(); - List params = new List(); + OAS.ApiClient client = new OAS.ApiClient(); + List params = new List(); params.addAll(client.makeParam('foo', 'bar')); params.addAll(client.makeParam('foo', 10)); params.addAll(client.makeParam('foo', 12.6)); @@ -141,13 +141,13 @@ private class SwaggerTest { @isTest private static void ApiClient_requiredParameterPasses() { - Swagger.ApiClient client = new Swagger.ApiClient(); + OAS.ApiClient client = new OAS.ApiClient(); client.assertNotNull('foo', 'bar'); } @isTest private static void ApiClient_requiredParameterFails() { - Swagger.ApiClient client = new Swagger.ApiClient(); + OAS.ApiClient client = new OAS.ApiClient(); try { client.assertNotNull(null, 'bar'); } catch (NullPointerException e) { @@ -217,7 +217,7 @@ private class SwaggerTest { '"bat":false' }; Set actual1 = new Set(client - .toBody('application/json', body1, new List()) + .toBody('application/json', body1, new List()) .removeStart('{') .removeEnd('}') .split(',') @@ -225,12 +225,12 @@ private class SwaggerTest { System.assertEquals(expected1, actual1); String body2 = 'Hello, World!'; - String actual2 = client.toBody('text/plain', body2, new List()); + String actual2 = client.toBody('text/plain', body2, new List()); System.assertEquals(body2, actual2); - List form = new List{ - new Swagger.Param('hello', 'world'), - new Swagger.Param('date', '2017-01-01 15:00:00') + List form = new List{ + new OAS.Param('hello', 'world'), + new OAS.Param('date', '2017-01-01 15:00:00') }; String expected3 = 'hello=world&date=2017-01-01+15%3A00%3A00'; String actual3 = client.toBody('application/x-www-form-urlencoded', '', form); @@ -288,9 +288,9 @@ private class SwaggerTest { MockApiClient client = new MockApiClient(); String path = '/departments/{department}'; Map params = new Map{'department' => 'finance'}; - List queryParams = new List{ - new Swagger.Param('foo', 'bar'), - new Swagger.Param('bat', '123') + List queryParams = new List{ + new OAS.Param('foo', 'bar'), + new OAS.Param('bat', '123') }; String expected = 'callout:Winkelmeyer/departments/finance?foo=bar&bat=123'; String actual = client.toEndpoint(path, params, queryParams); @@ -301,7 +301,7 @@ private class SwaggerTest { private static void ApiClient_returnParsedBody() { MockApiClient client = new MockApiClient(); HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); + OASResponseMock mock = new OASResponseMock(res); Test.setMock(HttpCalloutMock.class, mock); res.setStatus('OK'); @@ -314,8 +314,8 @@ private class SwaggerTest { Address a = (Address) client.invoke( 'GET', '/address', '', - new List(), - new List(), + new List(), + new List(), new Map(), new Map(), new List{'application/json'}, @@ -337,7 +337,7 @@ private class SwaggerTest { private static void ApiClient_noReturnTypeReturnsNull() { MockApiClient client = new MockApiClient(); HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); + OASResponseMock mock = new OASResponseMock(res); Test.setMock(HttpCalloutMock.class, mock); res.setStatus('OK'); @@ -345,8 +345,8 @@ private class SwaggerTest { Object o = client.invoke( 'POST', '/address', '', - new List(), - new List(), + new List(), + new List(), new Map(), new Map(), new List{'application/json'}, @@ -358,7 +358,7 @@ private class SwaggerTest { System.assertEquals(null, o); } - private class MockApiClient extends Swagger.ApiClient { + private class MockApiClient extends OAS.ApiClient { public MockApiClient() { basePath = 'https://blog.winkelmeyer.com'; calloutName = 'Winkelmeyer'; diff --git a/samples/client/petstore/apex/force-app/main/default/classes/OASTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASTest.cls-meta.xml new file mode 100644 index 00000000000..fec71a26693 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 42.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASUser.cls similarity index 88% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASUser.cls index 28ffe86d542..8ce543f9fe2 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASUser.cls @@ -5,15 +5,15 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ /** * A User who is purchasing from the pet store */ -public class SwagUser { +public class OASUser { /** * Get id * @return id @@ -62,8 +62,8 @@ public class SwagUser { */ public Integer userStatus { get; set; } - public static SwagUser getExample() { - SwagUser user = new SwagUser(); + public static OASUser getExample() { + OASUser user = new OASUser(); user.id = 123456789L; user.username = ''; user.firstName = ''; @@ -76,8 +76,8 @@ public class SwagUser { } public Boolean equals(Object obj) { - if (obj instanceof SwagUser) { - SwagUser user = (SwagUser) obj; + if (obj instanceof OASUser) { + OASUser user = (OASUser) obj; return this.id == user.id && this.username == user.username && this.firstName == user.firstName diff --git a/samples/client/petstore/apex/force-app/main/default/classes/OASUser.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASUser.cls-meta.xml new file mode 100644 index 00000000000..fec71a26693 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASUser.cls-meta.xml @@ -0,0 +1,5 @@ + + + 42.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASUserApi.cls similarity index 64% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASUserApi.cls index b37fc799e44..c86416a450e 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASUserApi.cls @@ -5,40 +5,40 @@ * OpenAPI spec version: 1.0.0 * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by the OAS code generator program. + * https://github.com/OAS-api/OAS-codegen.git * Do not edit the class manually. */ -public class SwagUserApi { - SwagClient client; +public class OASUserApi { + OASClient client; - public SwagUserApi(SwagClient client) { + public OASUserApi(OASClient client) { this.client = client; } - public SwagUserApi() { - this.client = new SwagClient(); + public OASUserApi() { + this.client = new OASClient(); } - public SwagClient getClient() { + public OASClient getClient() { return this.client; } /** * Create user * This can only be done by the logged in user. - * @param swagUser Created user object (required) - * @throws Swagger.ApiException if fails to make API call + * @param oaSUser Created user object (required) + * @throws OAS.ApiException if fails to make API call */ public void createUser(Map params) { - client.assertNotNull(params.get('swagUser'), 'swagUser'); - List query = new List(); - List form = new List(); + client.assertNotNull(params.get('oaSUser'), 'oaSUser'); + List query = new List(); + List form = new List(); client.invoke( 'POST', '/user', - (SwagUser) params.get('swagUser'), + (OASUser) params.get('oaSUser'), query, form, new Map(), new Map(), @@ -51,17 +51,17 @@ public class SwagUserApi { /** * Creates list of users with given input array * - * @param swagUser List of user object (required) - * @throws Swagger.ApiException if fails to make API call + * @param oaSUser List of user object (required) + * @throws OAS.ApiException if fails to make API call */ public void createUsersWithArrayInput(Map params) { - client.assertNotNull(params.get('swagUser'), 'swagUser'); - List query = new List(); - List form = new List(); + client.assertNotNull(params.get('oaSUser'), 'oaSUser'); + List query = new List(); + List form = new List(); client.invoke( 'POST', '/user/createWithArray', - (List) params.get('swagUser'), + (List) params.get('oaSUser'), query, form, new Map(), new Map(), @@ -74,17 +74,17 @@ public class SwagUserApi { /** * Creates list of users with given input array * - * @param swagUser List of user object (required) - * @throws Swagger.ApiException if fails to make API call + * @param oaSUser List of user object (required) + * @throws OAS.ApiException if fails to make API call */ public void createUsersWithListInput(Map params) { - client.assertNotNull(params.get('swagUser'), 'swagUser'); - List query = new List(); - List form = new List(); + client.assertNotNull(params.get('oaSUser'), 'oaSUser'); + List query = new List(); + List form = new List(); client.invoke( 'POST', '/user/createWithList', - (List) params.get('swagUser'), + (List) params.get('oaSUser'), query, form, new Map(), new Map(), @@ -98,12 +98,12 @@ public class SwagUserApi { * Delete user * This can only be done by the logged in user. * @param username The name that needs to be deleted (required) - * @throws Swagger.ApiException if fails to make API call + * @throws OAS.ApiException if fails to make API call */ public void deleteUser(Map params) { client.assertNotNull(params.get('username'), 'username'); - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); client.invoke( 'DELETE', '/user/{username}', '', @@ -122,15 +122,15 @@ public class SwagUserApi { * Get user by user name * * @param username The name that needs to be fetched. Use user1 for testing. (required) - * @return SwagUser - * @throws Swagger.ApiException if fails to make API call + * @return OASUser + * @throws OAS.ApiException if fails to make API call */ - public SwagUser getUserByName(Map params) { + public OASUser getUserByName(Map params) { client.assertNotNull(params.get('username'), 'username'); - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); - return (SwagUser) client.invoke( + return (OASUser) client.invoke( 'GET', '/user/{username}', '', query, form, new Map{ @@ -140,7 +140,7 @@ public class SwagUserApi { new List{ 'application/xml', 'application/json' }, new List(), new List(), - SwagUser.class + OASUser.class ); } /** @@ -149,18 +149,18 @@ public class SwagUserApi { * @param username The user name for login (required) * @param password The password for login in clear text (required) * @return String - * @throws Swagger.ApiException if fails to make API call + * @throws OAS.ApiException if fails to make API call */ public String loginUser(Map params) { client.assertNotNull(params.get('username'), 'username'); client.assertNotNull(params.get('password'), 'password'); - List query = new List(); + List query = new List(); // cast query params to verify their expected type query.addAll(client.makeParam('username', (String) params.get('username'))); query.addAll(client.makeParam('password', (String) params.get('password'))); - List form = new List(); + List form = new List(); return (String) client.invoke( 'GET', '/user/login', '', @@ -176,11 +176,11 @@ public class SwagUserApi { /** * Logs out current logged in user session * - * @throws Swagger.ApiException if fails to make API call + * @throws OAS.ApiException if fails to make API call */ public void logoutUser() { - List query = new List(); - List form = new List(); + List query = new List(); + List form = new List(); client.invoke( 'GET', '/user/logout', '', @@ -197,18 +197,18 @@ public class SwagUserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param swagUser Updated user object (required) - * @throws Swagger.ApiException if fails to make API call + * @param oaSUser Updated user object (required) + * @throws OAS.ApiException if fails to make API call */ public void updateUser(Map params) { client.assertNotNull(params.get('username'), 'username'); - client.assertNotNull(params.get('swagUser'), 'swagUser'); - List query = new List(); - List form = new List(); + client.assertNotNull(params.get('oaSUser'), 'oaSUser'); + List query = new List(); + List form = new List(); client.invoke( 'PUT', '/user/{username}', - (SwagUser) params.get('swagUser'), + (OASUser) params.get('oaSUser'), query, form, new Map{ 'username' => (String) params.get('username') diff --git a/samples/client/petstore/apex/force-app/main/default/classes/OASUserApi.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASUserApi.cls-meta.xml new file mode 100644 index 00000000000..fec71a26693 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASUserApi.cls-meta.xml @@ -0,0 +1,5 @@ + + + 42.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASUserApiTest.cls similarity index 55% rename from samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASUserApiTest.cls index 637f55bd5a5..3d797e07982 100644 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASUserApiTest.cls @@ -1,5 +1,5 @@ @isTest -private class SwagUserApiTest { +private class OASUserApiTest { /** * Create user * @@ -10,16 +10,17 @@ private class SwagUserApiTest { HttpResponse res = new HttpResponse(); res.setStatusCode(201); res.setStatus('Created'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); Map params = new Map{ - 'body' => SwagUser.getExample() + 'oaSUser' => OASUser.getExample() }; - SwagClient client; - SwagUserApi api; + OASClient client; + OASUserApi api; + String js = ''; - api = new SwagUserApi(new SwagClient()); + api = new OASUserApi(new OASClient()); api.createUser(params); } @@ -34,16 +35,17 @@ private class SwagUserApiTest { HttpResponse res = new HttpResponse(); res.setStatusCode(200); res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); Map params = new Map{ - 'body' => new List{SwagUser.getExample()} + 'oaSUser' => new List{OASUser.getExample()} }; - SwagClient client; - SwagUserApi api; + OASClient client; + OASUserApi api; + String js = ''; - api = new SwagUserApi(new SwagClient()); + api = new OASUserApi(new OASClient()); api.createUsersWithArrayInput(params); } @@ -58,16 +60,17 @@ private class SwagUserApiTest { HttpResponse res = new HttpResponse(); res.setStatusCode(200); res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); Map params = new Map{ - 'body' => new List{SwagUser.getExample()} + 'oaSUser' => new List{OASUser.getExample()} }; - SwagClient client; - SwagUserApi api; + OASClient client; + OASUserApi api; + String js = ''; - api = new SwagUserApi(new SwagClient()); + api = new OASUserApi(new OASClient()); api.createUsersWithListInput(params); } @@ -82,16 +85,17 @@ private class SwagUserApiTest { HttpResponse res = new HttpResponse(); res.setStatusCode(200); res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); Map params = new Map{ - 'username' => 'username_example' + 'username' => 'null' }; - SwagClient client; - SwagUserApi api; + OASClient client; + OASUserApi api; + String js = ''; - api = new SwagUserApi(new SwagClient()); + api = new OASUserApi(new OASClient()); api.deleteUser(params); } @@ -106,23 +110,32 @@ private class SwagUserApiTest { HttpResponse res = new HttpResponse(); res.setStatusCode(200); res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); Map params = new Map{ - 'username' => 'username_example' + 'username' => 'null' }; - SwagClient client; - SwagUserApi api; - SwagUser response; - SwagUser expectedResponse; + OASClient client; + OASUserApi api; + OASUser response; + OASUser expectedResponse; + String js = ''; - api = new SwagUserApi(new SwagClient()); + api = new OASUserApi(new OASClient()); + js = JSON.serialize(OASUser.getExample()); res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "firstName" : "aeiou",\n "lastName" : "aeiou",\n "password" : "aeiou",\n "userStatus" : 6,\n "phone" : "aeiou",\n "id" : 0,\n "email" : "aeiou",\n "username" : "aeiou"\n}'); - expectedResponse = SwagUser.getExample(); - response = (SwagUser) api.getUserByName(params); + res.setBody(js); + expectedResponse = OASUser.getExample(); + response = (OASUser) api.getUserByName(params); + System.assertEquals(expectedResponse, response); + + js = JSON.serialize(OASUser.getExample()); + res.setHeader('Content-Type', 'application/xml'); + res.setBody(js); + expectedResponse = OASUser.getExample(); + response = (OASUser) api.getUserByName(params); System.assertEquals(expectedResponse, response); } @@ -136,25 +149,22 @@ private class SwagUserApiTest { HttpResponse res = new HttpResponse(); res.setStatusCode(200); res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); Map params = new Map{ - 'username' => 'username_example', - 'password' => 'password_example' + 'username' => 'null', + 'password' => 'null' }; - SwagClient client; - SwagUserApi api; + OASClient client; + OASUserApi api; String response; String expectedResponse; + String js = ''; - api = new SwagUserApi(new SwagClient()); + api = new OASUserApi(new OASClient()); - res.setHeader('Content-Type', 'application/json'); - res.setBody('"aeiou"'); - expectedResponse = 'aeiou'; - response = (String) api.loginUser(params); - System.assertEquals(expectedResponse, response); + api.loginUser(params); } /** @@ -167,12 +177,13 @@ private class SwagUserApiTest { HttpResponse res = new HttpResponse(); res.setStatusCode(200); res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); - SwagClient client; - SwagUserApi api; + OASClient client; + OASUserApi api; + String js = ''; - api = new SwagUserApi(new SwagClient()); + api = new OASUserApi(new OASClient()); api.logoutUser(); } @@ -187,17 +198,18 @@ private class SwagUserApiTest { HttpResponse res = new HttpResponse(); res.setStatusCode(200); res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + Test.setMock(HttpCalloutMock.class, new OASResponseMock(res)); Map params = new Map{ - 'username' => 'username_example', - 'body' => SwagUser.getExample() + 'username' => 'null', + 'oaSUser' => OASUser.getExample() }; - SwagClient client; - SwagUserApi api; + OASClient client; + OASUserApi api; + String js = ''; - api = new SwagUserApi(new SwagClient()); + api = new OASUserApi(new OASClient()); api.updateUser(params); } diff --git a/samples/client/petstore/apex/force-app/main/default/classes/OASUserApiTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASUserApiTest.cls-meta.xml new file mode 100644 index 00000000000..fec71a26693 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASUserApiTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 42.0 + Active + diff --git a/samples/client/petstore/apex/deploy/classes/SwagUserTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/OASUserTest.cls similarity index 56% rename from samples/client/petstore/apex/deploy/classes/SwagUserTest.cls rename to samples/client/petstore/apex/force-app/main/default/classes/OASUserTest.cls index ec89e21ac1f..c8bbc9cfd4d 100644 --- a/samples/client/petstore/apex/deploy/classes/SwagUserTest.cls +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASUserTest.cls @@ -1,11 +1,11 @@ @isTest -private class SwagUserTest { +private class OASUserTest { @isTest private static void equalsSameInstance() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = user1; - SwagUser user3 = new SwagUser(); - SwagUser user4 = user3; + OASUser user1 = OASUser.getExample(); + OASUser user2 = user1; + OASUser user3 = new OASUser(); + OASUser user4 = user3; System.assert(user1.equals(user2)); System.assert(user2.equals(user1)); @@ -17,10 +17,10 @@ private class SwagUserTest { @isTest private static void equalsIdenticalInstance() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = SwagUser.getExample(); - SwagUser user3 = new SwagUser(); - SwagUser user4 = new SwagUser(); + OASUser user1 = OASUser.getExample(); + OASUser user2 = OASUser.getExample(); + OASUser user3 = new OASUser(); + OASUser user4 = new OASUser(); System.assert(user1.equals(user2)); System.assert(user2.equals(user1)); @@ -28,19 +28,10 @@ private class SwagUserTest { System.assert(user4.equals(user3)); } - @isTest - private static void notEqualsUnlikeInstance() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = new SwagUser(); - - System.assertEquals(false, user1.equals(user2)); - System.assertEquals(false, user2.equals(user1)); - } - @isTest private static void notEqualsDifferentType() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = new SwagUser(); + OASUser user1 = OASUser.getExample(); + OASUser user2 = new OASUser(); System.assertEquals(false, user1.equals('foo')); System.assertEquals(false, user2.equals('foo')); @@ -48,9 +39,9 @@ private class SwagUserTest { @isTest private static void notEqualsNull() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = new SwagUser(); - SwagUser user3; + OASUser user1 = OASUser.getExample(); + OASUser user2 = new OASUser(); + OASUser user3; System.assertEquals(false, user1.equals(user3)); System.assertEquals(false, user2.equals(user3)); @@ -58,8 +49,8 @@ private class SwagUserTest { @isTest private static void consistentHashCodeValue() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = new SwagUser(); + OASUser user1 = OASUser.getExample(); + OASUser user2 = new OASUser(); System.assertEquals(user1.hashCode(), user1.hashCode()); System.assertEquals(user2.hashCode(), user2.hashCode()); @@ -67,10 +58,10 @@ private class SwagUserTest { @isTest private static void equalInstancesHaveSameHashCode() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = SwagUser.getExample(); - SwagUser user3 = new SwagUser(); - SwagUser user4 = new SwagUser(); + OASUser user1 = OASUser.getExample(); + OASUser user2 = OASUser.getExample(); + OASUser user3 = new OASUser(); + OASUser user4 = new OASUser(); System.assert(user1.equals(user2)); System.assert(user3.equals(user4)); diff --git a/samples/client/petstore/apex/force-app/main/default/classes/OASUserTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/OASUserTest.cls-meta.xml new file mode 100644 index 00000000000..fec71a26693 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/OASUserTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 42.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls deleted file mode 100644 index ee404c543fe..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls +++ /dev/null @@ -1,7 +0,0 @@ -public class SwagClient extends Swagger.ApiClient { - public SwagClient() { - basePath = 'http://petstore.swagger.io/v2'; - calloutName = 'OpenAPI_Petstore'; - authentications.put('api_key', new Swagger.ApiKeyHeaderAuth('api_key')); - } -} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls deleted file mode 100644 index c1daa5f6264..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls +++ /dev/null @@ -1,233 +0,0 @@ -@isTest -private class SwagPetApiTest { - /** - * Add a new pet to the store - * - * - */ - @isTest - private static void addPetTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(201); - res.setStatus('Created'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'body' => SwagPet.getExample() - }; - - SwagClient client; - SwagPetApi api; - - client = new SwagClient(); - api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); - - api.addPet(params); - } - - /** - * Deletes a pet - * - * - */ - @isTest - private static void deletePetTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'petId' => 2147483648L, - 'apiKey' => 'apiKey_example' - }; - - SwagClient client; - SwagPetApi api; - - client = new SwagClient(); - api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); - - api.deletePet(params); - } - - /** - * Finds Pets by status - * - * Multiple status values can be provided with comma separated strings - */ - @isTest - private static void findPetsByStatusTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'status' => new List{'available'} - }; - - SwagClient client; - SwagPetApi api; - List response; - List expectedResponse; - - client = new SwagClient(); - api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('[ {\n "photoUrls" : [ "aeiou" ],\n "name" : "doggie",\n "id" : 0,\n "category" : {\n "name" : "aeiou",\n "id" : 6\n },\n "tags" : [ {\n "name" : "aeiou",\n "id" : 1\n } ],\n "status" : "available"\n} ]'); - expectedResponse = new List{SwagPet.getExample()}; - response = (List) api.findPetsByStatus(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Finds Pets by tags - * - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - */ - @isTest - private static void findPetsByTagsTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'tags' => new List{'aeiou'} - }; - - SwagClient client; - SwagPetApi api; - List response; - List expectedResponse; - - client = new SwagClient(); - api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('[ {\n "photoUrls" : [ "aeiou" ],\n "name" : "doggie",\n "id" : 0,\n "category" : {\n "name" : "aeiou",\n "id" : 6\n },\n "tags" : [ {\n "name" : "aeiou",\n "id" : 1\n } ],\n "status" : "available"\n} ]'); - expectedResponse = new List{SwagPet.getExample()}; - response = (List) api.findPetsByTags(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Find pet by ID - * - * Returns a single pet - */ - @isTest - private static void getPetByIdTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'petId' => 2147483648L - }; - - SwagClient client; - SwagPetApi api; - SwagPet response; - SwagPet expectedResponse; - - client = new SwagClient(); - api = new SwagPetApi(client); - ((Swagger.ApiKeyAuth) client.getAuthentication('api_key'); - client.setApiKey('foo-bar-api-key'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "photoUrls" : [ "aeiou" ],\n "name" : "doggie",\n "id" : 0,\n "category" : {\n "name" : "aeiou",\n "id" : 6\n },\n "tags" : [ {\n "name" : "aeiou",\n "id" : 1\n } ],\n "status" : "available"\n}'); - expectedResponse = SwagPet.getExample(); - response = (SwagPet) api.getPetById(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Update an existing pet - * - * - */ - @isTest - private static void updatePetTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'body' => SwagPet.getExample() - }; - - SwagClient client; - SwagPetApi api; - - client = new SwagClient(); - api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); - - api.updatePet(params); - } - - /** - * Updates a pet in the store with form data - * - * - */ - @isTest - private static void updatePetWithFormTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'petId' => 2147483648L, - 'name' => 'name_example', - 'status' => 'status_example' - }; - - SwagClient client; - SwagPetApi api; - - client = new SwagClient(); - api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); - - api.updatePetWithForm(params); - } - - /** - * uploads an image - * - * - */ - @isTest - private static void uploadFileTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'petId' => 2147483648L, - 'additionalMetadata' => 'additionalMetadata_example', - 'file' => Blob.valueOf('Sample text file\nContents') - }; - - SwagClient client; - SwagPetApi api; - SwagApiResponse response; - SwagApiResponse expectedResponse; - - client = new SwagClient(); - api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "code" : 0,\n "type" : "aeiou",\n "message" : "aeiou"\n}'); - expectedResponse = SwagApiResponse.getExample(); - response = (SwagApiResponse) api.uploadFile(params); - System.assertEquals(expectedResponse, response); - } -} \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls deleted file mode 100644 index 30b6d88b963..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls +++ /dev/null @@ -1,91 +0,0 @@ -@isTest -private class SwagPetTest { - @isTest - private static void equalsSameInstance() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = pet1; - SwagPet pet3 = new SwagPet(); - SwagPet pet4 = pet3; - - System.assert(pet1.equals(pet2)); - System.assert(pet2.equals(pet1)); - System.assert(pet1.equals(pet1)); - System.assert(pet3.equals(pet4)); - System.assert(pet4.equals(pet3)); - System.assert(pet3.equals(pet3)); - } - - @isTest - private static void equalsIdenticalInstance() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = SwagPet.getExample(); - SwagPet pet3 = new SwagPet(); - SwagPet pet4 = new SwagPet(); - - System.assert(pet1.equals(pet2)); - System.assert(pet2.equals(pet1)); - System.assert(pet3.equals(pet4)); - System.assert(pet4.equals(pet3)); - } - - @isTest - private static void notEqualsUnlikeInstance() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = new SwagPet(); - - System.assertEquals(false, pet1.equals(pet2)); - System.assertEquals(false, pet2.equals(pet1)); - } - - @isTest - private static void notEqualsDifferentType() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = new SwagPet(); - - System.assertEquals(false, pet1.equals('foo')); - System.assertEquals(false, pet2.equals('foo')); - } - - @isTest - private static void notEqualsNull() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = new SwagPet(); - SwagPet pet3; - - System.assertEquals(false, pet1.equals(pet3)); - System.assertEquals(false, pet2.equals(pet3)); - } - - @isTest - private static void consistentHashCodeValue() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = new SwagPet(); - - System.assertEquals(pet1.hashCode(), pet1.hashCode()); - System.assertEquals(pet2.hashCode(), pet2.hashCode()); - } - - @isTest - private static void equalInstancesHaveSameHashCode() { - SwagPet pet1 = SwagPet.getExample(); - SwagPet pet2 = SwagPet.getExample(); - SwagPet pet3 = new SwagPet(); - SwagPet pet4 = new SwagPet(); - - System.assert(pet1.equals(pet2)); - System.assert(pet3.equals(pet4)); - System.assertEquals(pet1.hashCode(), pet2.hashCode()); - System.assertEquals(pet3.hashCode(), pet4.hashCode()); - } - - @isTest - private static void defaultValuesPopulated() { - SwagPet pet = new SwagPet(); - System.assertEquals(new List(), pet.photoUrls); - System.assertEquals(new List(), pet.tags); - System.assertEquals(null, pet.id); - System.assertEquals(null, pet.category); - System.assertEquals(null, pet.name); - System.assertEquals(null, pet.status); - } -} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls deleted file mode 100644 index c79bbd98acc..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls +++ /dev/null @@ -1,115 +0,0 @@ -@isTest -private class SwagStoreApiTest { - /** - * Delete purchase order by ID - * - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - */ - @isTest - private static void deleteOrderTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'orderId' => 'orderId_example' - }; - - SwagClient client; - SwagStoreApi api; - - api = new SwagStoreApi(new SwagClient()); - - api.deleteOrder(params); - } - - /** - * Returns pet inventories by status - * - * Returns a map of status codes to quantities - */ - @isTest - private static void getInventoryTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - SwagClient client; - SwagStoreApi api; - Map response; - Map expectedResponse; - - client = new SwagClient(); - api = new SwagStoreApi(client); - ((Swagger.ApiKeyAuth) client.getAuthentication('api_key'); - client.setApiKey('foo-bar-api-key'); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "key" : 0\n}'); - expectedResponse = new Map{'key'=>123}; - response = (Map) api.getInventory(); - System.assertEquals(expectedResponse, response); - } - - /** - * Find purchase order by ID - * - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - */ - @isTest - private static void getOrderByIdTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'orderId' => 2147483648L - }; - - SwagClient client; - SwagStoreApi api; - SwagOrder response; - SwagOrder expectedResponse; - - api = new SwagStoreApi(new SwagClient()); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "petId" : 6,\n "quantity" : 1,\n "id" : 0,\n "shipDate" : "2000-01-23T04:56:07.000+00:00",\n "complete" : false,\n "status" : "placed"\n}'); - expectedResponse = SwagOrder.getExample(); - response = (SwagOrder) api.getOrderById(params); - System.assertEquals(expectedResponse, response); - } - - /** - * Place an order for a pet - * - * - */ - @isTest - private static void placeOrderTest() { - HttpResponse res = new HttpResponse(); - res.setStatusCode(200); - res.setStatus('OK'); - Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); - - Map params = new Map{ - 'body' => SwagOrder.getExample() - }; - - SwagClient client; - SwagStoreApi api; - SwagOrder response; - SwagOrder expectedResponse; - - api = new SwagStoreApi(new SwagClient()); - - res.setHeader('Content-Type', 'application/json'); - res.setBody('{\n "petId" : 6,\n "quantity" : 1,\n "id" : 0,\n "shipDate" : "2000-01-23T04:56:07.000+00:00",\n "complete" : false,\n "status" : "placed"\n}'); - expectedResponse = SwagOrder.getExample(); - response = (SwagOrder) api.placeOrder(params); - System.assertEquals(expectedResponse, response); - } -} \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls deleted file mode 100644 index ec89e21ac1f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls +++ /dev/null @@ -1,80 +0,0 @@ -@isTest -private class SwagUserTest { - @isTest - private static void equalsSameInstance() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = user1; - SwagUser user3 = new SwagUser(); - SwagUser user4 = user3; - - System.assert(user1.equals(user2)); - System.assert(user2.equals(user1)); - System.assert(user1.equals(user1)); - System.assert(user3.equals(user4)); - System.assert(user4.equals(user3)); - System.assert(user3.equals(user3)); - } - - @isTest - private static void equalsIdenticalInstance() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = SwagUser.getExample(); - SwagUser user3 = new SwagUser(); - SwagUser user4 = new SwagUser(); - - System.assert(user1.equals(user2)); - System.assert(user2.equals(user1)); - System.assert(user3.equals(user4)); - System.assert(user4.equals(user3)); - } - - @isTest - private static void notEqualsUnlikeInstance() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = new SwagUser(); - - System.assertEquals(false, user1.equals(user2)); - System.assertEquals(false, user2.equals(user1)); - } - - @isTest - private static void notEqualsDifferentType() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = new SwagUser(); - - System.assertEquals(false, user1.equals('foo')); - System.assertEquals(false, user2.equals('foo')); - } - - @isTest - private static void notEqualsNull() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = new SwagUser(); - SwagUser user3; - - System.assertEquals(false, user1.equals(user3)); - System.assertEquals(false, user2.equals(user3)); - } - - @isTest - private static void consistentHashCodeValue() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = new SwagUser(); - - System.assertEquals(user1.hashCode(), user1.hashCode()); - System.assertEquals(user2.hashCode(), user2.hashCode()); - } - - @isTest - private static void equalInstancesHaveSameHashCode() { - SwagUser user1 = SwagUser.getExample(); - SwagUser user2 = SwagUser.getExample(); - SwagUser user3 = new SwagUser(); - SwagUser user4 = new SwagUser(); - - System.assert(user1.equals(user2)); - System.assert(user3.equals(user4)); - System.assertEquals(user1.hashCode(), user2.hashCode()); - System.assertEquals(user3.hashCode(), user4.hashCode()); - } -} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls-meta.xml deleted file mode 100644 index 8b061c82b6f..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls-meta.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 39.0 - Active - diff --git a/samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential b/samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential deleted file mode 100644 index e7d8d71ac1c..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential +++ /dev/null @@ -1,7 +0,0 @@ - - - http://petstore.swagger.io/v2 - Anonymous - NoAuthentication - - \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential-meta.xml b/samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential-meta.xml deleted file mode 100644 index e7d8d71ac1c..00000000000 --- a/samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential-meta.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - http://petstore.swagger.io/v2 - Anonymous - NoAuthentication - - \ No newline at end of file diff --git a/samples/client/petstore/apex/git_push.sh b/samples/client/petstore/apex/git_push.sh deleted file mode 100644 index ed374619b13..00000000000 --- a/samples/client/petstore/apex/git_push.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 - -if [ "$git_user_id" = "" ]; then - git_user_id="GIT_USER_ID" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="GIT_REPO_ID" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="Minor update" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=`git remote` -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." - git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git - else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https' - diff --git a/samples/client/petstore/apex/sfdx-oss-manifest.json b/samples/client/petstore/apex/sfdx-oss-manifest.json deleted file mode 100644 index f63e2e36114..00000000000 --- a/samples/client/petstore/apex/sfdx-oss-manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "sfdxSource": true, - "version": "1.0.0", - "sourceFolder": "src/", - "folders": [ - "src/classes" - ], - "files": [ - ] -} \ No newline at end of file diff --git a/samples/client/petstore/apex/undeploy/destructiveChanges.xml b/samples/client/petstore/apex/undeploy/destructiveChanges.xml deleted file mode 100644 index 9f535579566..00000000000 --- a/samples/client/petstore/apex/undeploy/destructiveChanges.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - Swagger Petstore API Client - Client library for calling the Swagger Petstore API. -This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. -Generated with Swagger Codegen (github.com/swagger-api/swagger-codegen) - - SwagPetApi - SwagPetApiTest - SwagStoreApi - SwagStoreApiTest - SwagUserApi - SwagUserApiTest - SwagApiResponse - SwagApiResponseTest - SwagCategory - SwagCategoryTest - SwagOrder - SwagOrderTest - SwagPet - SwagPetTest - SwagTag - SwagTagTest - SwagUser - SwagUserTest - SwagClient - Swagger - SwaggerTest - SwaggerResponseMock - ApexClass - - - Swagger_Petstore - RemoteSiteSetting - - 39.0 - diff --git a/samples/client/petstore/apex/undeploy/package.xml b/samples/client/petstore/apex/undeploy/package.xml deleted file mode 100644 index 1f583b9fcb6..00000000000 --- a/samples/client/petstore/apex/undeploy/package.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Swag API Client - 39.0 -