diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 56d465c2a9b4..25b8c613622c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -73,6 +73,7 @@ Code change should conform to the programming style guide of the respective lang - Scala: http://docs.scala-lang.org/style/ - Swift: [Apple Developer](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html) - TypeScript: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines +- Xojo: https://documentation.xojo.com/topics/code_management/coding_guidelines.html For other languages, feel free to suggest. diff --git a/README.md b/README.md index 198752d81c42..b4a67aac55b8 100644 --- a/README.md +++ b/README.md @@ -76,13 +76,13 @@ If you find OpenAPI Generator useful for work, please consider asking your compa ## Overview OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification) (both 2.0 and 3.0 are supported). Currently, the following languages/frameworks are supported: -| | Languages/Frameworks | -| -------------------------------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 15.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) | +| | Languages/Frameworks | +| -------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 15.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo** | | **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) | -| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** | -| **Configuration files** | [**Apache2**](https://httpd.apache.org/) | -| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Protocol Buffer**, **WSDL** | +| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** | +| **Configuration files** | [**Apache2**](https://httpd.apache.org/) | +| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Protocol Buffer**, **WSDL** | ## Table of contents @@ -1024,6 +1024,7 @@ Here is a list of template creators: * TypeScript (Node): @mhardorf * TypeScript (Rxjs): @denyo * TypeScript (redux-query): @petejohansonxo + * Xojo: @Topheee * Server Stubs * Ada: @stcarrez * C# ASP.NET 5: @jimschubert [:heart:](https://www.patreon.com/jimschubert) @@ -1167,6 +1168,7 @@ If you want to join the committee, please kindly apply by sending an email to te | Scala | @clasnake (2017/07), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04) | | Swift | @jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @4brunu (2019/11) | | TypeScript | @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) | +| Xojo | @Topheee (2023/04) | Past Members of Technical Committee: diff --git a/bin/configs/xojo-client-petstore-synchronous.yaml b/bin/configs/xojo-client-petstore-synchronous.yaml new file mode 100644 index 000000000000..ab761f07d777 --- /dev/null +++ b/bin/configs/xojo-client-petstore-synchronous.yaml @@ -0,0 +1,8 @@ +generatorName: xojo-client +outputDir: samples/client/petstore/xojo/client-synchronous +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/xojo-client +additionalProperties: + hideGenerationTimestamp: "true" + supportsAsync: "false" + projectName: "XojoOpenAPIClientSynchronous" diff --git a/bin/configs/xojo-client-petstore.yaml b/bin/configs/xojo-client-petstore.yaml new file mode 100644 index 000000000000..df26a9c7e302 --- /dev/null +++ b/bin/configs/xojo-client-petstore.yaml @@ -0,0 +1,7 @@ +generatorName: xojo-client +outputDir: samples/client/petstore/xojo/client +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/xojo-client +additionalProperties: + hideGenerationTimestamp: "true" + supportsAsync: "true" diff --git a/docs/contributing.md b/docs/contributing.md index 7075b7792bd2..9502582ac4e2 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -77,6 +77,7 @@ Code change should conform to the programming style guide of the respective lang - Scala: http://docs.scala-lang.org/style/ - Swift: [Apple Developer](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html) - TypeScript: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines +- Xojo: https://documentation.xojo.com/topics/code_management/coding_guidelines.html For other languages, feel free to suggest. diff --git a/docs/generators.md b/docs/generators.md index ad83fbeb0593..c9b2665c4a02 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -75,6 +75,7 @@ The following generators are available: * [typescript-node](generators/typescript-node.md) * [typescript-redux-query](generators/typescript-redux-query.md) * [typescript-rxjs](generators/typescript-rxjs.md) +* [xojo-client](generators/xojo-client.md) ## SERVER generators diff --git a/docs/generators/xojo-client.md b/docs/generators/xojo-client.md new file mode 100644 index 000000000000..8618a613b62b --- /dev/null +++ b/docs/generators/xojo-client.md @@ -0,0 +1,297 @@ +--- +title: Documentation for the xojo-client Generator +--- + +## METADATA + +| Property | Value | Notes | +| -------- | ----- | ----- | +| generator name | xojo-client | pass this to the generate command after -g | +| generator stability | STABLE | | +| generator type | CLIENT | | +| generator language | Xojo | | +| generator default templating engine | mustache | | +| helpTxt | Generates a Xojo client module. | | + +## CONFIG OPTIONS +These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details. + +| Option | Description | Values | Default | +| ------ | ----------- | ------ | ------- | +|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| +|apiNamePrefix|Prefix that will be appended to all API classes. Default: empty string.| |null| +|apiPackage|package for generated api classes| |null| +|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true| +|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| +|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| +|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|library|library template (sub-template)|
**httpsocket**
[DEFAULT] HTTP client: HTTPSocket
|httpsocket| +|modelPackage|package for generated models| |null| +|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |null| +|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| +|projectName|Project name in Xojo| |null| +|serializationLibrary|What serialization library to use: 'xoson' (default).| |xoson| +|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| +|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| +|supportsAsync|Generate code that supports async operations.| |null| + +## IMPORT MAPPING + +| Type/Alias | Imports | +| ---------- | ------- | + + +## INSTANTIATION TYPES + +| Type/Alias | Instantiated By | +| ---------- | --------------- | + + +## LANGUAGE PRIMITIVES + + + +## RESERVED WORDS + + + +## FEATURE SET + + +### Client Modification Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|BasePath|✗|ToolingExtension +|Authorizations|✗|ToolingExtension +|UserAgent|✗|ToolingExtension +|MockServer|✗|ToolingExtension + +### Data Type Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Custom|✗|OAS2,OAS3 +|Int32|✓|OAS2,OAS3 +|Int64|✓|OAS2,OAS3 +|Float|✓|OAS2,OAS3 +|Double|✓|OAS2,OAS3 +|Decimal|✓|ToolingExtension +|String|✓|OAS2,OAS3 +|Byte|✓|OAS2,OAS3 +|Binary|✓|OAS2,OAS3 +|Boolean|✓|OAS2,OAS3 +|Date|✓|OAS2,OAS3 +|DateTime|✓|OAS2,OAS3 +|Password|✓|OAS2,OAS3 +|File|✓|OAS2 +|Uuid|✗| +|Array|✓|OAS2,OAS3 +|Null|✗|OAS3 +|AnyType|✗|OAS2,OAS3 +|Object|✓|OAS2,OAS3 +|Maps|✓|ToolingExtension +|CollectionFormat|✓|OAS2 +|CollectionFormatMulti|✓|OAS2 +|Enum|✓|OAS2,OAS3 +|ArrayOfEnum|✓|ToolingExtension +|ArrayOfModel|✓|ToolingExtension +|ArrayOfCollectionOfPrimitives|✓|ToolingExtension +|ArrayOfCollectionOfModel|✓|ToolingExtension +|ArrayOfCollectionOfEnum|✓|ToolingExtension +|MapOfEnum|✓|ToolingExtension +|MapOfModel|✓|ToolingExtension +|MapOfCollectionOfPrimitives|✓|ToolingExtension +|MapOfCollectionOfModel|✓|ToolingExtension +|MapOfCollectionOfEnum|✓|ToolingExtension + +### Documentation Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Readme|✗|ToolingExtension +|Model|✓|ToolingExtension +|Api|✓|ToolingExtension + +### Global Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Host|✓|OAS2,OAS3 +|BasePath|✓|OAS2,OAS3 +|Info|✓|OAS2,OAS3 +|Schemes|✗|OAS2,OAS3 +|PartialSchemes|✓|OAS2,OAS3 +|Consumes|✓|OAS2 +|Produces|✓|OAS2 +|ExternalDocumentation|✓|OAS2,OAS3 +|Examples|✓|OAS2,OAS3 +|XMLStructureDefinitions|✗|OAS2,OAS3 +|MultiServer|✗|OAS3 +|ParameterizedServer|✗|OAS3 +|ParameterStyling|✗|OAS3 +|Callbacks|✓|OAS3 +|LinkObjects|✗|OAS3 + +### Parameter Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Path|✓|OAS2,OAS3 +|Query|✓|OAS2,OAS3 +|Header|✓|OAS2,OAS3 +|Body|✓|OAS2 +|FormUnencoded|✓|OAS2 +|FormMultipart|✓|OAS2 +|Cookie|✓|OAS3 + +### Schema Support Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Simple|✓|OAS2,OAS3 +|Composite|✓|OAS2,OAS3 +|Polymorphism|✓|OAS2,OAS3 +|Union|✗|OAS3 +|allOf|✗|OAS2,OAS3 +|anyOf|✗|OAS3 +|oneOf|✗|OAS3 +|not|✗|OAS3 + +### Security Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|BasicAuth|✓|OAS2,OAS3 +|ApiKey|✓|OAS2,OAS3 +|OpenIDConnect|✗|OAS3 +|BearerToken|✓|OAS3 +|OAuth2_Implicit|✓|OAS2,OAS3 +|OAuth2_Password|✓|OAS2,OAS3 +|OAuth2_ClientCredentials|✓|OAS2,OAS3 +|OAuth2_AuthorizationCode|✓|OAS2,OAS3 + +### Wire Format Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|JSON|✓|OAS2,OAS3 +|XML|✓|OAS2,OAS3 +|PROTOBUF|✗|ToolingExtension +|Custom|✗|OAS2,OAS3 diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/GeneratorLanguage.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/GeneratorLanguage.java index e6959a4adaf3..a81f745ecab8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/GeneratorLanguage.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/GeneratorLanguage.java @@ -33,7 +33,7 @@ public enum GeneratorLanguage { OBJECTIVE_C("Objective-C"), OCAML("OCaml"), PERL("Perl"), PHP("PHP"), POWERSHELL("PowerShell"), PROTOBUF("Protocol Buffers (Protobuf)"), PYTHON("Python"), R("R"), RUBY("Ruby"), RUST("Rust"), SCALA("Scala"), SWIFT("Swift"), - WSDL("Web Services Description Language (WSDL)"), JULIA("Julia"); + WSDL("Web Services Description Language (WSDL)"), JULIA("Julia"), XOJO("Xojo"); private final String label; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/XojoClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/XojoClientCodegen.java new file mode 100644 index 000000000000..185864ee1b52 --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/XojoClientCodegen.java @@ -0,0 +1,749 @@ +package org.openapitools.codegen.languages; + +import io.swagger.v3.oas.models.media.ArraySchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.openapitools.codegen.*; +import org.openapitools.codegen.meta.GeneratorMetadata; +import org.openapitools.codegen.meta.Stability; +import org.openapitools.codegen.model.ModelMap; +import org.openapitools.codegen.model.ModelsMap; +import org.openapitools.codegen.model.OperationsMap; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.MapProperty; +import io.swagger.models.properties.Property; +import io.swagger.models.parameters.Parameter; +import org.openapitools.codegen.utils.ModelUtils; + +import java.io.File; +import java.util.*; +import java.util.function.Consumer; + +import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER; +import static org.openapitools.codegen.utils.StringUtils.camelize; +import static org.openapitools.codegen.utils.StringUtils.underscore; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.WordUtils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class XojoClientCodegen extends DefaultCodegen implements CodegenConfig { + public static final String CODEGEN_MODULE_NAME = "xojo-client"; + public static final String LIBRARY_HTTPSOCKET = "httpsocket"; + + public static final String SERIALIZATION_LIBRARY_DESC = "What serialization library to use: 'xoson' (default)."; + public static final String PROJECT_NAME_DESC = "Project name in Xojo"; + + public enum SERIALIZATION_LIBRARY_TYPE {xoson} + + protected String projectName = "OpenAPIClient"; + protected boolean nonPublicApi = false; + protected boolean supportsAsync = true; + protected SERIALIZATION_LIBRARY_TYPE serializationLibrary = SERIALIZATION_LIBRARY_TYPE.xoson; + + // Number for each object that appears in the xojo_project file. + // We start with a relatively high value, to have space for other static objects. + protected int projectObjectNumber = 100042; + + private final Logger LOGGER = LoggerFactory.getLogger(XojoClientCodegen.class); + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public void setNonPublicApi(boolean nonPublicApi) { + this.nonPublicApi = nonPublicApi; + } + + public void setSupportsAsync(Boolean supportsAsync) { + this.supportsAsync = supportsAsync; + } + + @Override + public String apiFileFolder() { + return outputFolder + File.separator + projectName + File.separator + apiPackage().replace('.', File.separatorChar); + } + + @Override + public String modelFileFolder() { + return outputFolder + File.separator + projectName + File.separator + modelPackage().replace('.', File.separatorChar); + } + + public XojoClientCodegen() { + super(); + this.useOneOfInterfaces = true; + + generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) + .stability(Stability.STABLE) + .build(); + + outputFolder = "generated-code" + File.separator + CODEGEN_MODULE_NAME; + modelTemplateFiles.put("model.mustache", ".xojo_code"); + modelTemplateFiles.put("modelOptionalEnum.mustache", "Optional.xojo_code"); + apiTemplateFiles.put("api.mustache", ".xojo_code"); + embeddedTemplateDir = templateDir = CODEGEN_MODULE_NAME; + apiPackage = "APIs"; + modelPackage = "Models"; + + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + + supportingFiles.add(new SupportingFile("App.mustache", + "", + "App.xojo_code")); + + supportingFiles.add(new SupportingFile("BuildAutomation.mustache", + "", + "Build Automation.xojo_code")); + + supportingFiles.add(new SupportingFile("api_mock.mustache", + "", + "Mock.xojo_code")); + + languageSpecificPrimitives = new HashSet<>( + Arrays.asList( + "Integer", + "Int8", + "Int16", + "Int32", + "Int64", + "UInteger", + "UInt8", + "UInt16", + "UInt32", + "UInt64", + "Single", + "Double", + "Boolean", + "String", + "Color", + "Currency") + ); + + setReservedWordsLowerCase( + Arrays.asList( + // name used by Xojo client + "Models", "APIs", + + // Xojo keywords. This list is taken from here: + // https://documentation.xojo.com/getting_started/using_the_xojo_language/reserved_words.html + // + "#Bad", "#Else", "#Elseif", "#Endif", "#If", "#Pragma", "#Tag", "AddHandler", "AddressOf", "Aggregates", "And", "Array", "As", "Assigns", "Async", "Attributes", "Await", "Break", "ByRef", "ByVal", "Call", "Case", "Catch", "Class", "Const", "Continue", "CType", "Declare", "Delegate", "Dim", "Do", "DownTo", "Each", "Else", "ElseIf", "End", "Enum", "Event", "Exception", "Exit", "Extends", "False", "Finally", "For", "Function", "Global", "GoTo", "Handles", "If", "Implements", "In", "Inherits", "Interface", "Is", "IsA", "Lib", "Loop", "Me", "Mod", "Module", "Namespace", "New", "Next", "Nil", "Not", /*"Object",*/ "Of", "Optional", "Or", "ParamArray", "Private", "Property", "Protected", "Public", "Raise", "RaiseEvent", "Redim", "Rem", "RemoveHandler", "Return", "Select", "Self", "Shared", "Soft", "Static", "Step", "Structure", "Sub", "Super", "Then", "To", "True", "Try", "Until", "Using", "Var", "WeakAddressOf", "Wend", "While", "With", "Xor", + + // The following are other words we want to reserve + "Void", "COLUMN", "FILE", "FUNCTION", "LINE" + ) + ); + + typeMapping = new HashMap<>(); + typeMapping.put("map", "Dictionary"); + typeMapping.put("set", "Array"); + typeMapping.put("Date", "Date"); + typeMapping.put("DateTime", "Date"); + typeMapping.put("boolean", "Boolean"); + typeMapping.put("string", "String"); + typeMapping.put("char", "Byte"); + typeMapping.put("short", "Int16"); + typeMapping.put("int", "Integer"); + typeMapping.put("long", "Int64"); + typeMapping.put("integer", "Integer"); + typeMapping.put("Integer", "Integer"); + typeMapping.put("float", "Single"); + typeMapping.put("number", "Double"); + typeMapping.put("double", "Double"); + typeMapping.put("file", "FolderItem"); + typeMapping.put("binary", "FolderItem"); + typeMapping.put("ByteArray", "MemoryBlock"); + typeMapping.put("UUID", "String"); + typeMapping.put("URI", "String"); + typeMapping.put("decimal", "Currency"); + typeMapping.put("object", "Object"); + typeMapping.put("AnyType", "Variant"); + typeMapping.put("null", "nil"); + + // in the future we should also support URLConnection + supportedLibraries.put(LIBRARY_HTTPSOCKET, "[DEFAULT] HTTP client: HTTPSocket"); + + CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC); + libraryOption.setEnum(supportedLibraries); + libraryOption.setDefault(LIBRARY_HTTPSOCKET); + cliOptions.add(libraryOption); + setLibrary(LIBRARY_HTTPSOCKET); + + CliOption serializationLibraryOpt = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY, SERIALIZATION_LIBRARY_DESC); + cliOptions.add(serializationLibraryOpt.defaultValue(serializationLibrary.name())); + + cliOptions.add(new CliOption(CodegenConstants.API_NAME_PREFIX, "Prefix that will be appended to all API classes. Default: empty string.")); + cliOptions.add(new CliOption(CodegenConstants.PROJECT_NAME, PROJECT_NAME_DESC)); + cliOptions.add(new CliOption(CodegenConstants.NON_PUBLIC_API, CodegenConstants.NON_PUBLIC_API_DESC)); + cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); + cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ASYNC, CodegenConstants.SUPPORTS_ASYNC_DESC)); + cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); + } + + private static CodegenModel reconcileProperties(CodegenModel codegenModel, + CodegenModel parentCodegenModel) { + // To support inheritance in this generator, we will analyze + // the parent and child models, look for properties that match, and remove + // them from the child models and leave them in the parent. + // Because the child models extend the parents, the properties + // will be available via the parent. + + // Get the properties for the parent and child models + final List parentModelCodegenProperties = parentCodegenModel.vars; + List codegenProperties = codegenModel.vars; + codegenModel.allVars = new ArrayList(codegenProperties); + codegenModel.parentVars = parentCodegenModel.allVars; + + // Iterate over all of the parent model properties + boolean removedChildProperty = false; + + for (CodegenProperty parentModelCodegenProperty : parentModelCodegenProperties) { + // Now that we have found a prop in the parent class, + // and search the child class for the same prop. + Iterator iterator = codegenProperties.iterator(); + while (iterator.hasNext()) { + CodegenProperty codegenProperty = iterator.next(); + if (codegenProperty.baseName.equals(parentModelCodegenProperty.baseName)) { + // We found a property in the child class that is + // a duplicate of the one in the parent, so remove it. + iterator.remove(); + removedChildProperty = true; + } + } + } + + if (removedChildProperty) { + codegenModel.vars = codegenProperties; + } + + return codegenModel; + } + + @Override + public String getTypeDeclaration(Schema p) { + if (ModelUtils.isArraySchema(p)) { + ArraySchema ap = (ArraySchema) p; + Schema inner = ap.getItems(); + return super.getTypeDeclaration(inner); + } + return super.getTypeDeclaration(p); + } + + @Override + public String getSchemaType(Schema p) { + String openAPIType = super.getSchemaType(p); + String type; + if (typeMapping.containsKey(openAPIType)) { + type = typeMapping.get(openAPIType); + if (languageSpecificPrimitives.contains(type) || defaultIncludes.contains(type)) { + return type; + } + } else { + type = openAPIType; + } + return toModelName(type); + } + + @Override + public String escapeReservedWord(String name) { + LOGGER.warn("Escaping word '" + name + "' to 'Escaped" + name + "'. This will likely cause issues at runtime!"); + return "Escaped" + name; + } + + @Override + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + @Override + public String getName() { + return CODEGEN_MODULE_NAME; + } + + @Override + public String getHelp() { + return "Generates a Xojo client module."; + } + + @Override + public void processOpts() { + super.processOpts(); + + // mandatory settings to ensure compilation + setSortParamsByRequiredFlag(true); + setEnsureUniqueParams(true); + setAllowUnicodeIdentifiers(false); + + // Setup nonPublicApi option, which generates code with reduced access + // modifiers; allows embedding elsewhere without exposing non-public API calls + // to consumers + if (additionalProperties.containsKey(CodegenConstants.NON_PUBLIC_API)) { + setNonPublicApi(convertPropertyToBooleanAndWriteBack(CodegenConstants.NON_PUBLIC_API)); + } + additionalProperties.put(CodegenConstants.NON_PUBLIC_API, nonPublicApi); + + if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) { + setSerializationLibrary((String) additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY)); + additionalProperties.put(this.serializationLibrary.name(), true); + } else { + additionalProperties.put(this.serializationLibrary.name(), true); + } + + syncBooleanProperty(additionalProperties, CodegenConstants.SUPPORTS_ASYNC, this::setSupportsAsync, this.supportsAsync); + syncStringProperty(additionalProperties, CodegenConstants.PROJECT_NAME, this::setProjectName, this.projectName); + syncStringProperty(additionalProperties, CodegenConstants.LIBRARY, this::setLibrary, this.library); + + if (supportsAsync) { + apiTemplateFiles.put("CallbackHandler.mustache", "CallbackHandler.xojo_code"); + } + + supportingFiles.add(new SupportingFile("MainModule.mustache", + "", + projectName + ".xojo_code")); + + supportingFiles.add(new SupportingFile("APIsModule.mustache", + projectName, + "APIs.xojo_code")); + + supportingFiles.add(new SupportingFile("ModelModule.mustache", + projectName, + "Models.xojo_code")); + + supportingFiles.add(new SupportingFile("Project.mustache", + "", + projectName + ".xojo_project")); + + supportingFiles.add(new SupportingFile("Exception.mustache", + projectName, + projectName + "Exception.xojo_code")); + + supportingFiles.add(new SupportingFile("Resources.mustache", + "", + projectName + ".xojo_resources")); + } + + @Override + public CodegenModel fromModel(String name, Schema model) { + Map allDefinitions = ModelUtils.getSchemas(this.openAPI); + CodegenModel codegenModel = super.fromModel(name, model); + + codegenModel.vendorExtensions.put("x-xojo-project-id", String.format(Locale.ROOT, "%014XFF", projectObjectNumber)); + projectObjectNumber = projectObjectNumber + 16; + + if (allDefinitions != null) { + String parentSchema = codegenModel.parentSchema; + + // multilevel inheritance: reconcile properties of all the parents + while (parentSchema != null) { + final Schema parentModel = allDefinitions.get(parentSchema); + final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, + parentModel); + codegenModel = XojoClientCodegen.reconcileProperties(codegenModel, parentCodegenModel); + + // get the next parent + parentSchema = parentCodegenModel.parentSchema; + } + } + + return codegenModel; + } + + @Override + public String escapeQuotationMark(String input) { + // escape " in strings to avoid code injection + return input.replace("\"", "\"\""); + } + + @Override + public String escapeUnsafeCharacters(String input) { + // if a backslash occurs in a property note for instance, Xojo crashes. + return input.replace("*/", "*_/").replace("/*", "/_*").replace("\\", ""); + } + + @Override + public ModelsMap postProcessModels(ModelsMap objs) { + ModelsMap postProcessedModelsEnum = postProcessModelsEnum(objs); + return postProcessedModelsEnum; + } + + @Override + public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List allModels) { + objs = super.postProcessOperationsWithModels(objs, allModels); + + Map vendorExtensions = (Map)objs.get("vendorExtensions"); + if (null == vendorExtensions) { + vendorExtensions = new HashMap<>(); + objs.put("vendorExtensions", vendorExtensions); + } + + vendorExtensions.put("x-xojo-project-id", String.format(Locale.ROOT, "%014XFF", projectObjectNumber)); + projectObjectNumber = projectObjectNumber + 16; + + return objs; + } + + @Override + public void postProcess() { + System.out.println("################################################################################"); + System.out.println("# Thanks for using OpenAPI Generator. #"); + System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #"); + System.out.println("# https://opencollective.com/openapi_generator/donate #"); + System.out.println("# #"); + System.out.println("# xojo-client contributed by Christopher Kobusch (https://github.com/Topheee). #"); + System.out.println("################################################################################"); + } + + // escape api key name + @Override + @SuppressWarnings("static-method") + public List fromSecurity(Map securitySchemeMap) { + List securities = super.fromSecurity(securitySchemeMap); + + for (CodegenSecurity sec : securities) { + if (sec.isApiKey) sec.name = toVarName(sec.name); + } + + return securities; + } + + @Override + public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.XOJO; } + + @Override + public String toOperationId(String operationId) { + operationId = camelize(sanitizeName(operationId)); + + // Throw exception if method name is empty. + // This should not happen but keep the check just in case + if (StringUtils.isEmpty(operationId)) { + throw new RuntimeException("Empty method name (operationId) not allowed"); + } + + // method name cannot use reserved keyword, e.g. return + if (isReservedWord(operationId)) { + String newOperationId = camelize(("Call_" + operationId)); + LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId); + return newOperationId; + } + + // operationId starts with a number + if (operationId.matches("^\\d.*")) { + LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER)); + operationId = camelize(sanitizeName("Call_" + operationId)); + } + + return operationId; + } + + @Override + public String toEnumValue(String value, String datatype) { + return "\"" + value + "\""; + } + + @Override + public String toEnumVarName(String name, String datatype) { + if (name.length() == 0) { + return "empty"; + } + + if (enumUnknownDefaultCase) { + if (name.equals(enumUnknownDefaultCaseName)) { + return camelize(name); + } + } + + // Reserved Name + String nameLowercase = StringUtils.lowerCase(name); + if (isReservedWord(nameLowercase)) { + return escapeReservedWord(nameLowercase); + } + + // Prefix with underscore if name starts with number + if (name.matches("[+-]?\\d.*")) { + LOGGER.warn("Escaping enum var name '" + name + "' to 'Escaped" + replaceSpecialCharacters(camelize(name)) + "'. This will likely cause issues at runtime!"); + return "Escaped" + replaceSpecialCharacters(camelize(name)); + } + + // for symbol, e.g. $, # + if (getSymbolName(name) != null) { + return camelize(WordUtils.capitalizeFully(getSymbolName(name).toUpperCase(Locale.ROOT))); + } + + // Camelize only when we have a structure defined below + boolean camelized = false; + if (name.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) { + name = camelize(name); + camelized = true; + } + + // Check for numerical conversions + if ("Int".equals(datatype) || "Int32".equals(datatype) || "Int64".equals(datatype) + || "Float".equals(datatype) || "Double".equals(datatype)) { + String varName = "number" + camelize(name); + return replaceSpecialCharacters(varName); + } + + // If we have already camelized the word, don't progress + // any further + if (camelized) { + return replaceSpecialCharacters(name); + } + + char[] separators = {'-', '_', ' ', ':', '(', ')'}; + return camelize(replaceSpecialCharacters(WordUtils.capitalizeFully(StringUtils.lowerCase(name), separators) + .replaceAll("[-_ :\\(\\)]", ""))); + } + + private String replaceSpecialCharacters(String name) { + for (Map.Entry specialCharacters : specialCharReplacements.entrySet()) { + String specialChar = specialCharacters.getKey(); + String replacement = specialCharacters.getValue(); + // Underscore is the only special character we'll allow + if (!specialChar.equals("_") && name.contains(specialChar)) { + name = replaceCharacters(name, specialChar, replacement); + } + } + + // Fallback, replace unknowns with underscore. + name = name.replaceAll("\\W+", "_"); + + return name; + } + + private String replaceCharacters(String word, String oldValue, String newValue) { + if (!word.contains(oldValue)) { + return word; + } + if (word.equals(oldValue)) { + return newValue; + } + int i = word.indexOf(oldValue); + String start = word.substring(0, i); + String end = recurseOnEndOfWord(word, oldValue, newValue, i); + return start + newValue + end; + } + + private String recurseOnEndOfWord(String word, String oldValue, String newValue, int lastReplacedValue) { + String end = word.substring(lastReplacedValue + 1); + if (!end.isEmpty()) { + end = titleCase(end); + end = replaceCharacters(end, oldValue, newValue); + } + return end; + } + + private String titleCase(final String input) { + return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1); + } + + @Override + public String toVarName(String name) { + // sanitize name + name = sanitizeName(name); + + // if it's all upper case, do nothing + if (name.matches("^[A-Z_]*$")) { + return name; + } + + // for reserved word or word starting with number, append _ + if (isReservedWord(name) || name.matches("^\\d.*")) { + name = escapeReservedWord(name); + } + return name; + } + + @Override + public String toParamName(String name) { + // sanitize name + name = sanitizeName(name); + + // replace - with _ e.g. created-at => created_at + name = name.replaceAll("-", "_"); + + // if it's all upper case, do nothing + if (name.matches("^[A-Z_]*$")) { + return name; + } + + // camelize(lower) the variable name + // pet_id => petId + name = camelize(name, LOWERCASE_FIRST_LETTER); + + // for reserved words prepend with 'Escaped' + if (isReservedWord(name)) { + name = escapeReservedWord(name); + } + + // for words starting with number, prepend _ + if (name.matches("^\\d.*")) { + name = "_" + name; + } + + return name; + } + + @Override + public String toModelFilename(String name) { + name = super.toModelFilename(name); + // sanitize name + name = sanitizeName(name); + + // replace - with _ e.g. created-at => created_at + name = name.replaceAll("-", "_"); + + if (isReservedWord(name)) { + name = escapeReservedWord(name); + } + + // for words starting with number, prepend A + if (name.matches("^\\d.*")) { + name = "A" + name; + } + + if (!name.equals(toModelName(name))) { + LOGGER.error("Model file name '" + name + "' differs from model name '" + toModelName(name) + "'. This will result in compilation errors."); + } + + return name; + } + + @Override + public String toModelName(String name) { + name = sanitizeName(name); + + if (!StringUtils.isEmpty(modelNameSuffix) && !isLanguageSpecificType(name)) { // set model suffix + name = name + "_" + modelNameSuffix; + } + + if (!StringUtils.isEmpty(modelNamePrefix) && !isLanguageSpecificType(name)) { // set model prefix + name = modelNamePrefix + "_" + name; + } + + // camelize the model name + // phone_number => PhoneNumber + name = camelize(name); + + // model name cannot use reserved keyword, e.g. return + if (isReservedWord(name)) { + String modelName = "Model" + name; + LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, modelName); + return modelName; + } + + // model name starts with number + if (name.matches("^\\d.*")) { + // e.g. 200Response => Model200Response (after camelize) + String modelName = "Model" + name; + LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name, + modelName); + return modelName; + } + + return name; + } + + @Override + public String toExampleValue(Schema schema) { + if (schema.getExample() != null) { + return schema.getExample().toString(); + } + + return getPropertyDefaultValue(schema); + } + + @Override + public String toDefaultValue(Schema schema) { + if (schema.getDefault() != null) { + return schema.getDefault().toString(); + } + + return getPropertyDefaultValue(schema); + } + + @Override + public void setParameterExampleValue(CodegenParameter codegenParameter) { + super.setParameterExampleValue(codegenParameter); + if (Boolean.TRUE.equals(codegenParameter.isBinary)) { + codegenParameter.example = "GetTemporaryFolderItem"; + } else if (Boolean.TRUE.equals(codegenParameter.isByteArray)) { + codegenParameter.example = "New MemoryBlock(8)"; + } else if (Boolean.TRUE.equals(codegenParameter.isFile)) { + codegenParameter.example = "GetTemporaryFolderItem"; + } else if (Boolean.TRUE.equals(codegenParameter.isDate)) { + codegenParameter.example = "New Date"; + } else if (Boolean.TRUE.equals(codegenParameter.isDateTime)) { + codegenParameter.example = "New Date"; + } else if (Boolean.TRUE.equals(codegenParameter.isString)) { + codegenParameter.example = codegenParameter.paramName + "_example"; + } else if (Boolean.TRUE.equals(codegenParameter.isFreeFormObject)) { + codegenParameter.example = "New Dictionary"; + } + } + + public SERIALIZATION_LIBRARY_TYPE getSerializationLibrary() { + return this.serializationLibrary; + } + + /** + * Sets the serialization engine for Xojo + * + * @param enumSerializationLibrary The string representation of the serialization library as defined by + * {@link org.openapitools.codegen.languages.XojoClientCodegen.SERIALIZATION_LIBRARY_TYPE} + */ + public void setSerializationLibrary(final String enumSerializationLibrary) { + try { + this.serializationLibrary = SERIALIZATION_LIBRARY_TYPE.valueOf(enumSerializationLibrary); + } catch (IllegalArgumentException ex) { + StringBuilder sb = new StringBuilder(enumSerializationLibrary + " is an invalid enum property naming option. Please choose from:"); + for (SERIALIZATION_LIBRARY_TYPE t : SERIALIZATION_LIBRARY_TYPE.values()) { + sb.append("\n ").append(t.name()); + } + throw new RuntimeException(sb.toString()); + } + } + + private String getPropertyDefaultValue(Schema schema) { + if (ModelUtils.isBooleanSchema(schema)) { + return "False"; + } else if (ModelUtils.isDateSchema(schema)) { + return "Nil"; + } else if (ModelUtils.isDateTimeSchema(schema)) { + return "Nil"; + } else if (ModelUtils.isNumberSchema(schema)) { + return "0"; + } else if (ModelUtils.isIntegerSchema(schema)) { + return "0"; + } else if (ModelUtils.isStringSchema(schema)) { + return "Sample"; + } else if (ModelUtils.isObjectSchema(schema)) { + return "Nil"; + } else { + return "Nil"; + } + } + + private void syncBooleanProperty(final Map additionalProperties, final String key, final Consumer setter, final Boolean defaultValue) { + if (additionalProperties.containsKey(key)) { + setter.accept(convertPropertyToBooleanAndWriteBack(key)); + } else { + additionalProperties.put(key, defaultValue); + setter.accept(defaultValue); + } + } + + private void syncStringProperty(final Map additionalProperties, final String key, final Consumer setter, final String defaultValue) { + if (additionalProperties.containsKey(key)) { + setter.accept((String) additionalProperties.get(key)); + } else { + additionalProperties.put(key, defaultValue); + setter.accept(defaultValue); + } + } + + private Boolean isLanguageSpecificType(String name) { + return languageSpecificPrimitives.contains(name); + } +} diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig index 633534b8f5f7..15bc7e37b7a0 100644 --- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig +++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -140,3 +140,4 @@ org.openapitools.codegen.languages.TypeScriptNodeClientCodegen org.openapitools.codegen.languages.TypeScriptReduxQueryClientCodegen org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen org.openapitools.codegen.languages.WsdlSchemaCodegen +org.openapitools.codegen.languages.XojoClientCodegen diff --git a/modules/openapi-generator/src/main/resources/xojo-client/APIsModule.mustache b/modules/openapi-generator/src/main/resources/xojo-client/APIsModule.mustache new file mode 100644 index 000000000000..cf6534f57b16 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/APIsModule.mustache @@ -0,0 +1,46 @@ +#tag Module +Protected Module {{{apiPackage}}} + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/modules/openapi-generator/src/main/resources/xojo-client/App.mustache b/modules/openapi-generator/src/main/resources/xojo-client/App.mustache new file mode 100644 index 000000000000..d17d57739fa4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/App.mustache @@ -0,0 +1,16 @@ +#tag Class +Protected Class App +Inherits ConsoleApplication + #tag Event + Function Run(args() as String) As Integer + #Pragma Unused args + {{^supportsAsync}}Dim m As New Mock{{#apiInfo}}{{#apis}} + m.test{{classname}}("http://localhost:4010") 'original basePath: {{{basePath}}}{{/apis}}{{/apiInfo}}{{/supportsAsync}} + End Function + #tag EndEvent + + + #tag ViewBehavior + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/modules/openapi-generator/src/main/resources/xojo-client/BuildAutomation.mustache b/modules/openapi-generator/src/main/resources/xojo-client/BuildAutomation.mustache new file mode 100644 index 000000000000..f9b6aeee7312 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/BuildAutomation.mustache @@ -0,0 +1,14 @@ +#tag BuildAutomation + Begin BuildStepList Linux + Begin BuildProjectStep Build + End + End + Begin BuildStepList Mac OS X + Begin BuildProjectStep Build + End + End + Begin BuildStepList Windows + Begin BuildProjectStep Build + End + End +#tag EndBuildAutomation diff --git a/modules/openapi-generator/src/main/resources/xojo-client/CallbackHandler.mustache b/modules/openapi-generator/src/main/resources/xojo-client/CallbackHandler.mustache new file mode 100644 index 000000000000..f82e84fc69dc --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/CallbackHandler.mustache @@ -0,0 +1,53 @@ +{{#operations}}#tag Interface +Protected Interface {{classname}}CallbackHandler +{{#operation}} #tag Method, Flags = &h0 + {{#deprecated}}Attributes( Deprecated = yes ) {{/deprecated}}Sub {{operationId}}Callback(status As {{> nameException}}{{#returnProperty}}, {{^isArray}}Optional {{/isArray}}{{^isBinary}}data{{#isArray}}(){{/isArray}} As {{> inlineModelParameterDatatype}}{{/isBinary}}{{#isBinary}}file As FolderItem{{/isBinary}}{{/returnProperty}}) + + End Sub + #tag EndMethod + +{{#returnProperty}}{{#isBinary}} #tag Method, Flags = &h0 + Sub {{operationId}}DownloadProgress(BytesReceived as Integer, TotalBytes as Integer) + + End Sub + #tag EndMethod +{{/isBinary}}{{/returnProperty}}{{/operation}}{{/operations}} + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag EndViewBehavior +End Interface +#tag EndInterface diff --git a/modules/openapi-generator/src/main/resources/xojo-client/Exception.mustache b/modules/openapi-generator/src/main/resources/xojo-client/Exception.mustache new file mode 100644 index 000000000000..934cbf73919b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/Exception.mustache @@ -0,0 +1,185 @@ +#tag Class +Protected Class {{{projectName}}}Exception +Inherits RuntimeException + #tag Method, Flags = &h0 + Sub Constructor(errorNumber As Integer, message As String) + // Construct an error related to the library. + 'Super.Constructor + Me.Message = message + Me.ErrorNumber = errorNumber + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor(HTTPCode As Integer, message As String, content As String) + // Construct an error related to an HTTP response. + 'Super.Constructor + + Me.HTTPCode = HTTPCode + If message = "" Then + Me.Message = "HTTP Status " + Str(HTTPCode) + Else + Me.Message = message + End If + + If HTTPCode < 200 Or HTTPCode > 299 Then + Me.ErrorNumber = kErrorHTTPFail + Me.OriginalResponseBody = content + End If + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor(socketCode As Integer) + // Construct an error related to a socket. + 'Super.Constructor + Me.SocketCode = socketCode + Me.Message = MessageForSocketErrorCode(socketCode) + + If socketCode <> 0 Then Me.ErrorNumber = kErrorSocketFail + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub Constructor() + // Disallow construction of empty results. + 'Super.Constructor + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function MessageForSocketErrorCode(code As Integer) As String + If code = 0 Then + Return "No error occurred." + ElseIf code = 100 Then + Return "There was an error opening and initializing the drivers." + ElseIf code = 101 Then + Return "This error code is no longer used." + ElseIf code = 102 Then + Return "This code means that you lost your connection." + ElseIf code = 103 Then + Return "The socket was unable to resolve the address that was specified." + ElseIf code = 104 Then + Return "This error code is no longer used." + ElseIf code = 105 Then + Return "The address is currently in use." + ElseIf code = 106 Then + Return "This is an invalid state error, which means that the socket is not in the proper state to be doing a certain operation." + ElseIf code = 107 Then + Return "This error means that the port you specified is invalid." + ElseIf code = 108 Then + Return "This error indicates that your application has run out of memory." + End If + + Return "An unknown socket error " + Str(code) + " occurred." + End Function + #tag EndMethod + + + #tag ComputedProperty, Flags = &h0 + #tag Getter + Get + Return "{{{projectName}}}Exception | ErrorNumber: " + Str(Me.ErrorNumber) + " | HTTP Status: " + Str(Me.HTTPCode) + " | SocketCode: " + Str(Me.SocketCode) + " | Message: " + Me.Message + End Get + #tag EndGetter + Description As String + #tag EndComputedProperty + + #tag Property, Flags = &h0 + HTTPCode As Integer = -1 + #tag EndProperty + + #tag ComputedProperty, Flags = &h0 + #tag Getter + Get + Return ErrorNumber <> 0 + End Get + #tag EndGetter + IsError As Boolean + #tag EndComputedProperty + + #tag Property, Flags = &h0 + OriginalResponseBody As String + #tag EndProperty + + #tag Property, Flags = &h0 + SocketCode As Integer = 0 + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="HTTPCode" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Message" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="SocketCode" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="IsError" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/modules/openapi-generator/src/main/resources/xojo-client/MainModule.mustache b/modules/openapi-generator/src/main/resources/xojo-client/MainModule.mustache new file mode 100644 index 000000000000..0b2d47a4c6d7 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/MainModule.mustache @@ -0,0 +1,198 @@ +#tag Module +Protected Module {{{projectName}}} + #tag Method, Flags = &h21 + Private Function BoolFromString(s As String) As Boolean + If s = "true" Then + Return True + ElseIf s = "false" Then + Return False + ElseIf s = "0" Then + Return True + Else + Return False + End If + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function EncodingFromContentType(contentType As String) As TextEncoding + // Extract the encoding from the contentType header. + // Defaults to Encodings.UTF8. + + Dim contentEncoding As TextEncoding = nil + + Dim components() As String = contentType.SplitB(";") + For Each component As String In components + Dim directive() As String = component.SplitB("=") + If Ubound(directive) > 0 And directive(0).RightB(7) = "charset" Then + contentEncoding = GetInternetTextEncoding(directive(1)) + If contentEncoding <> Nil Then Return contentEncoding + End If + Next + + Return Encodings.UTF8 + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FromRFC3339(Extends stringRepresentation As String) As Date + + Dim d As New Xoson.DateIntermediate(stringRepresentation) + + Return New Date(d.year, d.month, d.day, d.hour, d.minute, d.second, 0.0) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FromRFC3339(Extends stringRepresentation As String) As Xojo.Core.Date + + Dim d As New Xoson.DateIntermediate(stringRepresentation) + + Return New Xojo.Core.Date(d.year, d.month, d.day, d.hour, d.minute, d.second, d.millisecond * 1000, new Xojo.Core.TimeZone("Etc/UTC")) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function LocalFuncSerializeFile(Extends file As FolderItem) As String + If file <> Nil Then + Try + Dim bs As BinaryStream = BinaryStream.Open(file, False) + // read the whole binaryStream + Return bs.Read(bs.Length) + + Catch e As IOException + Dim error As New {{> nameException}}(kErrorFileWrite, e.Message) + error.ErrorNumber = e.ErrorNumber + Raise error + End Try + Else + Dim error As New {{> nameException}}(kErrorInternal, "Nil parameter {{{name}}}") + Raise error + End If + + Return "" + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ToRFC3339(Extends d As Date) As String + Dim utcDate As New Date(d) + utcDate.GMTOffset = 0 + + Dim mb As New MemoryBlock(24) + mb.StringValue(0,4) = Format(utcDate.Year, "0000") + mb.Byte(4) = &h2D + mb.StringValue(5,2) = Format(utcDate.Month, "00") + mb.Byte(7) = &h2D + mb.StringValue(8,2) = Format(utcDate.Day, "00") + mb.Byte(10) = &h54 + mb.StringValue(11,2) = Format(utcDate.Hour, "00") + mb.Byte(13) = &h3A + mb.StringValue(14,2) = Format(utcDate.Minute, "00") + mb.Byte(16) = &h3A + mb.StringValue(17,2) = Format(utcDate.Second, "00") + mb.Byte(19) = &h2E + mb.StringValue(20,3) = "000" 'milliseconds are not available in Date + mb.Byte(23) = &h5A + Return DefineEncoding(mb.StringValue(0, 24), Encodings.UTF8) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ToRFC3339(Extends d As Xojo.Core.Date) As String + Dim utcDate As New Xojo.Core.Date(d.SecondsFrom1970, New Xojo.Core.TimeZone("Etc/UTC")) + + Dim mb As New MemoryBlock(24) + mb.StringValue(0,4) = Format(utcDate.Year, "0000") + mb.Byte(4) = &h2D + mb.StringValue(5,2) = Format(utcDate.Month, "00") + mb.Byte(7) = &h2D + mb.StringValue(8,2) = Format(utcDate.Day, "00") + mb.Byte(10) = &h54 + mb.StringValue(11,2) = Format(utcDate.Hour, "00") + mb.Byte(13) = &h3A + mb.StringValue(14,2) = Format(utcDate.Minute, "00") + mb.Byte(16) = &h3A + mb.StringValue(17,2) = Format(utcDate.Second, "00") + mb.Byte(19) = &h2E + mb.StringValue(20,3) = Format(utcDate.Nanosecond / 1000, "000") + mb.Byte(23) = &h5A + Return DefineEncoding(mb.StringValue(0, 24), Encodings.UTF8) + End Function + #tag EndMethod + + + #tag Constant, Name = kErrorInternal, Type = Double, Dynamic = False, Default = \"-10", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorFileWrite, Type = Double, Dynamic = False, Default = \"-8", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorCannotAuthenticate, Type = Double, Dynamic = False, Default = \"-7", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorUnsupportedFeature, Type = Double, Dynamic = False, Default = \"-6", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorSocketFail, Type = Double, Dynamic = False, Default = \"-5", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorHTTPFail, Type = Double, Dynamic = False, Default = \"-4", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorUnsupportedMediaType, Type = Double, Dynamic = False, Default = \"-3", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorXosonProblem, Type = Double, Dynamic = False, Default = \"-2", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorInvalidJSON, Type = Double, Dynamic = False, Default = \"-1", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kAPITimeoutSeconds, Type = Double, Dynamic = False, Default = \"5", Scope = Private + #tag EndConstant + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/modules/openapi-generator/src/main/resources/xojo-client/MockModule.mustache b/modules/openapi-generator/src/main/resources/xojo-client/MockModule.mustache new file mode 100644 index 000000000000..f29b60760f93 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/MockModule.mustache @@ -0,0 +1,46 @@ +#tag Module +Protected Module Mock + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/modules/openapi-generator/src/main/resources/xojo-client/ModelModule.mustache b/modules/openapi-generator/src/main/resources/xojo-client/ModelModule.mustache new file mode 100644 index 000000000000..39444a4cc49e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/ModelModule.mustache @@ -0,0 +1,66 @@ +#tag Module +Protected Module {{{modelPackage}}} +{{#models}}{{#model}}{{#isEnum}}{{^isInteger}} #tag Method, Flags = &h21 + Protected Function {{classname}}ToString(value As {{classname}}) As String + Select Case value{{#allowableValues}}{{#enumVars}} + Case {{classname}}.{{{name}}} + Return {{{value}}}{{/enumVars}}{{/allowableValues}} + {{#enumUnknownDefaultCase}}Case {{classname}}.{{{enumUnknownDefaultCaseName}}} + Return "{{{enumUnknownDefaultCaseName}}}"{{/enumUnknownDefaultCase}} + End Select + Return "" + End Function + #tag EndMethod + +{{/isInteger}}{{/isEnum}}{{/model}}{{/models}} +{{#models}}{{#model}}{{#isEnum}} #tag Enum, Name = {{classname}}, Type = Integer, Flags = &h1 + {{#allowableValues}}{{#enumVars}} + {{{name}}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{/enumVars}}{{/allowableValues}} + {{#enumUnknownDefaultCase}}Unknown{{#isInteger}} = {{{value}}}{{/isInteger}}{{/enumUnknownDefaultCase}} + #tag EndEnum +{{/isEnum}}{{/model}}{{/models}} + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/modules/openapi-generator/src/main/resources/xojo-client/Project.mustache b/modules/openapi-generator/src/main/resources/xojo-client/Project.mustache new file mode 100644 index 000000000000..1edcf5a272cd --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/Project.mustache @@ -0,0 +1,51 @@ +Type=Console +RBProjectVersion=2019.011 +MinIDEVersion=20070100 +Class=App;App.xojo_code;&h000000005B6127FF;&h0000000000000000;false +BuildSteps=Build Automation;Build Automation.xojo_code;&h000000005D9877FF;&h0000000000000000;false +Module={{projectName}};{{projectName}}.xojo_code;&h000000001FF397FF;&h0000000000000000;false +Class={{projectName}}Exception;{{projectName}}/{{projectName}}Exception.xojo_code;&h0000000054B007FF;&h000000001FF397FF;false +Module={{{modelPackage}}};{{projectName}}/{{{modelPackage}}}.xojo_code;&h000000002FF397FF;&h000000001FF397FF;false +{{#models}}{{#model}}Class={{classname}}{{#isEnum}}{{> suffixOptionalEnum}}{{/isEnum}};{{projectName}}/{{{modelPackage}}}/{{classFilename}}{{#isEnum}}{{> suffixOptionalEnum}}{{/isEnum}}.xojo_code;&h{{{vendorExtensions.x-xojo-project-id}}};&h000000002FF397FF;false{{^-last}} +{{/-last}}{{/model}}{{/models}} +Module={{{apiPackage}}};{{projectName}}/{{{apiPackage}}}.xojo_code;&h000000003FF397FF;&h000000001FF397FF;false +{{#apiInfo}}{{#apis}}Class={{classname}};{{projectName}}/{{{apiPackage}}}/{{classFilename}}.xojo_code;&h{{{vendorExtensions.x-xojo-project-id}}};&h000000003FF397FF;false{{#supportsAsync}} +Class={{classname}}CallbackHandler;{{projectName}}/{{{apiPackage}}}/{{classFilename}}CallbackHandler.xojo_code;&h{{{vendorExtensions.x-xojo-project-id}}};&h000000003FF397FF;false{{/supportsAsync}}{{^-last}} +{{/-last}}{{/apis}}{{/apiInfo}} +Class=Mock;Mock.xojo_code;&h000000002FF407FF;&h0000000000000000;false +MajorVersion=1 +MinorVersion=0 +SubVersion=0 +NonRelease=0 +Release=1 +InfoVersion=openapi-generator Generated Project +LongVersion={{projectName}} +ShortVersion=1.0 +WinCompanyName=OpenAPI-Generator Contributors +WinInternalName= +WinProductName= +WinFileDescription= +AutoIncrementVersionInformation=False +BuildFlags=&h4100 +BuildLanguage=&h0 +DebugLanguage=&h0 +Region= +WindowsName={{projectName}}.exe +MacCarbonMachName={{projectName}} +LinuxX86Name={{projectName}} +MacCreator= +MDI=0 +MDICaption= +DefaultEncoding=&h0 +AppIcon={{projectName}}.xojo_resources;&h0 +OSXBundleID=tech.openapi-generator.{{projectName}} +DebuggerCommandLine= +UseGDIPlus=False +UseBuildsFolder=True +CopyRedistNextToWindowsEXE=False +IsWebProject=False +LinuxBuildArchitecture=1 +MacBuildArchitecture=1 +OptimizationLevel=0 +WindowsVersions={35138b9a-5d96-4fbd-8e2d-a2440225f93a}|{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}|{1f676c76-80e1-4239-95bb-83d0f6d0da78}|{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a} +WindowsRunAs=0 diff --git a/modules/openapi-generator/src/main/resources/xojo-client/README.mustache b/modules/openapi-generator/src/main/resources/xojo-client/README.mustache new file mode 100644 index 000000000000..9a27ce47c516 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/README.mustache @@ -0,0 +1,117 @@ +# Xojo API client for {{{projectName}}} + +{{#appDescriptionWithNewLines}} +{{{.}}} +{{/appDescriptionWithNewLines}} + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client. + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Installation + +This project contains generated code suitable for both Desktop and Console applications on all operating systems. + +The code is generated for Xojo's API v1. + +The generated code is packaged into a single Module (`{{{projectName}}}`), which we suggest copying to your project after opening the generated `{{{projectName}}}.xojo_project` in [Xojo](https://xojo.com/). Working in the generated Xojo project is not recommended. + +> See also Xojo's [Sharing code among multiple projects](https://documentation.xojo.com/topics/code_management/sharing_code_among_multiple_projects.html). + +This project depends on [Xoson](https://github.com/Topheee/xoson) `v2.2.0` (and above). Download it to your computer: +```shell +git clone 'https://github.com/Topheee/xoson.git' +``` + +Open the `Xoson.xojo_project` from the cloned git repository with Xojo and copy the `Xoson` module to your project. Similarily, open the `{{{projectName}}}.xojo_project` file with Xojo and copy `{{{projectName}}}` to your project. + +> Since Xojo currently has no package manager, you need to manually copy both the `Xoson` and the `{{{projectName}}}` modules to your Xojo project. + +Both modules must not be copied into another module, but must reside at the top level of your project. + +### Customization + +The generator can be configured with the following options. + +Option | Used | Description +--- | --- | --- +`projectName` | `{{projectName}}` | The name of the generated project and module. +`nonPublicApi` | `{{nonPublicApi}}` | Generate `Protected` instead of `Public` methods, if set. +`library` | `{{library}}` | Internal Xojo standard library object to use. Currently only `httpsocket` (`HTTPSocket` class) is supported. +`serializationLibrary` | `{xoson` | Internal library to use for serialization. Currently only `xoson` ([Xoson](https://github.com/Topheee/xoson) library) is supported. +`supportsAsync` | `{{supportsAsync}}` | If `true`, generated APIs will use callbacks instead of blocking the main thread. + +### Usage + +Communication with the OpenAPI server is done by instantiating one of the classes below `{{{projectName}}}.{{{apiPackage}}}`, configuring it - by setting `BasePath`, `UseHTTPS`, and `Port` - and invoking the `{{#nonPublicApi}}Protected {{/nonPublicApi}}{{^nonPublicApi}}Public {{/nonPublicApi}}` methods. +{{#supportsAsync}} +The methods always return immediately and the network communication is done in the background. To obtain the results and errors of each request, you need to implement the respective `CallbackHandler` interfaces: + +{{#apiInfo}}{{#apis}}- `{{{projectName}}}.{{{apiPackage}}}.{{{classname}}}CallbackHandler` +{{/apis}}{{/apiInfo}} + +Create an object of your implementing class and assign it to the `CallbackHandler` property of the API object. + +This callback handler has exactly one method definition for each operation. This method is invoked when the operation finishes. It's first parameter `status As {{> nameException}}` is always set. If `status.IsError` is `False`, the operation succeeded and the return value (either `data` or `file`) - if available - contains valid information. +{{/supportsAsync}}{{^supportsAsync}} +If the methods returns `True`, the API request was successful. Otherwise, the `localOutStatus` parameter contains information about the failure. Note that despite this `ByRef` parameter, the methods may still raise an exception! + +The method blocks until the response is received. +{{/supportsAsync}} + +> The property `AdditionalHeaders` allows sending further headers with each request. Set it to a new `Dictionary`, with the Keys being the header names and the values either being a single String or an array of Strings. + +__Error handling__, as well as status reporting, is done via class `{{> nameException}}`. Note that an instance of this class does not always indicate an error - check `IsError` to find out. +- `ErrorNumber` is set to one of the `{{{projectName}}}.kError` constants, or `0` in case of no error. +- `HTTPStatus` is set to the HTTP status code as returned by the server. If the error is unrelated to HTTP, this property is `-1`. +- `SocketCode` contains the socket error, if any; otherwise `0`. + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{{projectName}}}.{{{apiPackage}}}.{{{classname}}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{projectName}}}.{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}## {{{name}}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} +{{/-last}}{{/apis}}{{/apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/xojo-client/Resources.mustache b/modules/openapi-generator/src/main/resources/xojo-client/Resources.mustache new file mode 100644 index 000000000000..a6d4df61c2d3 Binary files /dev/null and b/modules/openapi-generator/src/main/resources/xojo-client/Resources.mustache differ diff --git a/modules/openapi-generator/src/main/resources/xojo-client/api.mustache b/modules/openapi-generator/src/main/resources/xojo-client/api.mustache new file mode 100644 index 000000000000..2f6ca2f6d4e2 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/api.mustache @@ -0,0 +1,461 @@ +{{#operations}}#tag Class +Protected Class {{classname}} +{{#operation}} #tag Method, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} + {{#deprecated}}Attributes( Deprecated ) {{/deprecated}}{{#nonPublicApi}}Protected {{/nonPublicApi}}{{^supportsAsync}}Function{{/supportsAsync}}{{#supportsAsync}}Sub{{/supportsAsync}} {{operationId}}({{^supportsAsync}}ByRef localOutStatus As {{> nameException}}{{/supportsAsync}}{{#returnProperty}}{{^supportsAsync}}, {{/supportsAsync}}{{#isBinary}}downloadToFile As FolderItem{{/isBinary}}{{^isBinary}}{{^supportsAsync}}{{^isArray}}ByRef {{/isArray}}localOutData{{#isArray}}(){{/isArray}} As {{> inlineModelParameterDatatype}}{{/supportsAsync}}{{/isBinary}}{{/returnProperty}}{{#hasParams}}, {{/hasParams}}{{#allParams}}{{^required}}{{^isEnum}}{{^isEnumRef}}{{^isArray}}Optional {{/isArray}}{{/isEnumRef}}{{/isEnum}}{{/required}}{{paramName}}{{#isArray}}(){{/isArray}} As {{#isArray}}{{#items}}{{#isModel}}{{> prefixModel}}{{/isModel}}{{/items}}{{/isArray}}{{#isModel}}{{> prefixModel}}{{/isModel}}{{> inlineNameOperationEnum}}{{^isEnum}}{{> prefixXosonOptional}}{{#schema}}{{#isEnumRef}}{{> prefixModel}}{{/isEnumRef}}{{/schema}}{{{dataType}}}{{^required}}{{#schema}}{{#isEnumRef}}{{> suffixOptionalEnum}}{{/isEnumRef}}{{/schema}}{{/required}}{{/isEnum}}{{^-last}}, {{/-last}}{{/allParams}}){{^supportsAsync}} As Boolean{{/supportsAsync}} + // Operation {{{operationIdOriginal}}}{{#summary}} + // {{{.}}}{{/summary}}{{^supportsAsync}} + // - parameter localOutStatus: Information on whether the operation succeeded.{{/supportsAsync}}{{#returnProperty}} + // - {{#isBinary}}parameter downloadToFile: The writable, non-existing path in the filesystem where the response body should be stored.{{/isBinary}}{{^isBinary}}{{^supportsAsync}}parameter localOutData: On success, contains the data returned by the API.{{/supportsAsync}}{{/isBinary}}{{/returnProperty}}{{#allParams}} + // - parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}} + // + // {{#supportsAsync}}Invokes {{classname}}CallbackHandler.{{operationId}}Callback({{{returnType}}}) on completion.{{#isResponseOptional}} Note that the response is optional.{{/isResponseOptional}} {{/supportsAsync}}{{description}} + // + // - {{httpMethod}} {{{path}}}{{#notes}} + // - {{{.}}}{{/notes}}{{#subresourceOperation}} + // - subresourceOperation: {{.}}{{/subresourceOperation}}{{#defaultResponse}} + // - defaultResponse: {{.}}{{/defaultResponse}} + //{{#authMethods}} + // - {{#isBasic}}BASIC{{/isBasic}}{{#isOAuth}}OAuth{{/isOAuth}}{{#isApiKey}}API Key{{/isApiKey}}: + // - type: {{type}}{{#keyParamName}} {{keyParamName}} {{#isKeyInQuery}}(QUERY){{/isKeyInQuery}}{{#isKeyInHeader}}(HEADER){{/isKeyInHeader}}{{/keyParamName}} + // - name: {{name}}{{/authMethods}} + //{{#hasResponseHeaders}} + // - responseHeaders: [{{#responseHeaders}}{{{baseName}}}({{{dataType}}}){{^-last}}, {{/-last}}{{/responseHeaders}}]{{/hasResponseHeaders}} + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + {{#hasFormParams}} + Dim localVarFormParams As New Dictionary + {{#formParams}}{{> inlineCodeParamCheckNil}}localVarFormParams.Value("{{baseName}}") = {{> inlineCodeParamSerialize}} + {{/formParams}} + If localVarFormParams.Count > 0 Then localVarHTTPSocket.SetFormData(localVarFormParams) + {{/hasFormParams}} + {{#bodyParam}}localVarHTTPSocket.SetRequestContent({{> inlineCodeParamSerialize}}, "application/json"){{/bodyParam}} + {{#hasQueryParams}}Dim localVarQueryParams As String = "?"{{#queryParams}} + {{^isArray}}{{> inlineCodeParamCheckNil}}localVarQueryParams = localVarQueryParams{{^-first}} + "&"{{/-first}} + EncodeURLComponent("{{baseName}}") + "=" + EncodeURLComponent({{> inlineCodeParamSerialize}}){{/isArray}} + {{#isArray}}{{#items}}Dim localVarQueryStrings{{paramName}}() As String + For Each localVarItem{{paramName}} As {{> inlineNameOperationEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}} in {{paramName}} + Dim encodedParameter As String = EncodeURLComponent({{> inlineCodeParamSerializeArray}}) + {{^isExplode}}localVarQueryStrings{{paramName}}.Append(encodedParameter){{/isExplode}}{{#isExplode}}Select Case "{{{style}}}" + Case "form" + localVarQueryStrings{{paramName}}.Append("{{baseName}}=" + encodedParameter) + Case "spaceDelimited" + localVarQueryStrings{{paramName}}.Append("{{baseName}}=" + encodedParameter) + Case "pipeDelimited" + localVarQueryStrings{{paramName}}.Append("{{baseName}}=" + encodedParameter) + Case "deepObject" + Raise New {{> nameException}}(kErrorUnsupportedFeature, "deepObject query parameters are not supported") + End Select{{/isExplode}} + Next + + Dim localVarQueryString{{paramName}} As String + {{#isExplode}}localVarQueryString{{paramName}} = Join(localVarQueryStrings{{paramName}}, "&"){{/isExplode}}{{^isExplode}}Select Case "{{{style}}}" + Case "form" + localVarQueryString{{paramName}} = "{{baseName}}=" + Join(localVarQueryStrings{{paramName}}, ",") + Case "spaceDelimited" + localVarQueryString{{paramName}} = "{{baseName}}=" + Join(localVarQueryStrings{{paramName}}, " ") + Case "pipeDelimited" + localVarQueryString{{paramName}} = "{{baseName}}=" + Join(localVarQueryStrings{{paramName}}, "|") + Case "deepObject" + Raise New {{> nameException}}(kErrorUnsupportedFeature, "deepObject query parameters are not supported") + End Select + If localVarQueryStrings{{paramName}}.Ubound() > -1 Then localVarQueryParams = localVarQueryParams{{^-first}} + "&" {{/-first}} + EncodeURLComponent("{{baseName}}") + "=" + EncodeURLComponent(localVarQueryString{{paramName}}){{/isExplode}}{{/items}}{{/isArray}}{{/queryParams}} + {{/hasQueryParams}} + {{#headerParams}} + {{^isArray}}{{> inlineCodeParamCheckNil}}localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("{{baseName}}"), EncodeURLComponent({{> inlineCodeParamSerialize}})){{/isArray}} + {{#isArray}}{{#items}}Dim localVarHeaderStrings{{paramName}}() As String + For Each localVarItem{{paramName}} As {{> inlineNameOperationEnum}}{{^isEnum}}{{{baseName}}}{{/isEnum}} in {{paramName}} + Dim encodedParameter As String = EncodeURLComponent({{> inlineCodeParamSerializeArray}}) + localVarHeaderStrings{{paramName}}.Append(encodedParameter) + Next + + If localVarHeaderStrings{{paramName}}.Ubound() > -1 Then localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("{{baseName}}"), Join(localVarHeaderStrings{{paramName}}, ","))){{/items}}{{/isArray}}{{/headerParams}} + {{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}If me.ApiKey{{{name}}} = "" Then Raise New {{> nameException}}(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `{{classname}}.ApiKey{{{name}}}` before invoking `{{classname}}.{{operationId}}()`.") + {{#isKeyInQuery}}If localVarQueryParams = "" then + localVarQueryParams = "?" + Else + localVarQueryParams = localVarQueryParams + "&" + End If + localVarQueryParams = localVarQueryParams + "{{keyParamName}}=" + Me.ApiKey{{{name}}}{{/isKeyInQuery}} + {{#isKeyInHeader}}localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("{{keyParamName}}"), EncodeURLComponent(me.ApiKey{{{name}}})){{/isKeyInHeader}}{{/isApiKey}} + {{#isBasic}}AddHandler localVarHTTPSocket.AuthenticationRequired, addressof Me.AuthenticationRequired{{/isBasic}}{{/authMethods}}{{/hasAuthMethods}} + {{#hasCookieParams}} + Dim localVarCookies() As String + {{#cookieParams}} + {{^isArray}}{{> inlineCodeParamCheckNil}}localVarCookies.Append(EncodeURLComponent("{{baseName}}") + "=" + EncodeURLComponent({{> inlineCodeParamSerialize}}){{/isArray}} + {{#isArray}}{{#items}}Dim localVarCookieStrings{{paramName}}() As String + For Each localVarItem{{paramName}} As {{> inlineNameOperationEnum}}{{^isEnum}}{{{baseName}}}{{/isEnum}} in {{paramName}} + Dim encodedParameter As String = EncodeURLComponent({{> inlineCodeParamSerializeArray}}) + localVarCookieStrings{{paramName}}.Append(encodedParameter) + Next + If localVarCookieStrings{{paramName}}.UBound() > -1 Then localVarCookies.Append(EncodeURLComponent("{{baseName}}") + "=" + Join(localVarCookieStrings{{paramName}}, ",")){{/items}}{{/isArray}}{{/cookieParams}} + If localVarCookies.UBound() > -1 Then s.SetRequestHeader("Cookie", Join(localVarCookies, "; "))){{/hasCookieParams}} + + Dim localVarPath As String = "{{{path}}}" + {{#hasPathParams}}{{#pathParams}} + {{^isArray}}Dim localVarPathString{{paramName}} As String = {{> inlineCodeParamSerialize}}{{/isArray}} + {{#isArray}}{{#items}}Dim localVarPathStrings{{paramName}}() As String + For Each localVarItem{{paramName}} As {{> inlineNameOperationEnum}}{{^isEnum}}{{{baseName}}}{{/isEnum}} in {{paramName}} + Dim encodedParameter As String = EncodeURLComponent({{> inlineCodeParamSerializeArray}}) + {{^isExplode}}localVarPathStrings{{paramName}}.Append(encodedParameter){{/isExplode}} + {{#isExplode}}Select Case "{{{style}}}" + Case "simple" + localVarPathStrings{{paramName}}.Append(encodedParameter) + Case "label" + localVarPathStrings{{paramName}}.Append("." + encodedParameter) + Case "matrix" + localVarPathStrings{{paramName}}.Append(";" + "{{baseName}}=" + encodedParameter) + End Select{{/isExplode}} + Next + + Dim localVarPathString{{paramName}} As String + {{#isExplode}}localVarPathString{{paramName}} = Join(localVarPathStrings{{paramName}}, ","){{/isExplode}}{{^isExplode}}Select Case "{{{style}}}" + Case "simple" + localVarPathString{{paramName}} = Join(localVarPathStrings{{paramName}}, ",") + Case "label" + localVarPathString{{paramName}} = "." + Join(localVarPathStrings{{paramName}}, ",") + Case "matrix" + localVarPathString{{paramName}} = ";" + "{{baseName}}=" + Join(localVarPathStrings{{paramName}}, ",") + End Select{{/isExplode}}{{/items}}{{/isArray}} + localVarPath = localVarPath.ReplaceAllB("{{=< >=}}{}<={{ }}=>", localVarPathString{{paramName}}){{/pathParams}}{{/hasPathParams}} + + {{#supportsAsync}}{{#returnProperty}}{{#isBinary}}AddHandler localVarHTTPSocket.DownloadComplete, addressof me.{{operationId}}_handler + AddHandler localVarHTTPSocket.ReceiveProgress, addressof Me.{{operationId}}_progress{{/isBinary}} + {{^isBinary}}AddHandler localVarHTTPSocket.PageReceived, addressof me.{{operationId}}_handler + AddHandler localVarHTTPSocket.Error, addressof Me.{{operationId}}_error{{/isBinary}}{{/returnProperty}} + {{^returnProperty}}AddHandler localVarHTTPSocket.PageReceived, addressof Me.{{operationId}}_handler + AddHandler localVarHTTPSocket.Error, addressof Me.{{operationId}}_error{{/returnProperty}} + + localVarHTTPSocket.SendRequest("{{httpMethod}}", Me.BasePath + localVarPath{{#hasQueryParams}} + localVarQueryParams{{/hasQueryParams}}{{#returnProperty}}{{#isBinary}}, downloadToFile{{/isBinary}}{{/returnProperty}}) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New {{> nameException}}(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if{{/supportsAsync}} + {{^supportsAsync}}localVarHTTPSocket.Yield = True 'recommended in synchronous mode + {{#returnProperty}}{{#isBinary}}Dim localVarSuccessful As Boolean{{/isBinary}}{{^isBinary}}Dim localVarContent As String{{/isBinary}}{{/returnProperty}}{{^returnProperty}}Dim localVarContent As String{{/returnProperty}} = localVarHTTPSocket.SendRequest("{{httpMethod}}", Me.BasePath + localVarPath{{#hasQueryParams}} + localVarQueryParams{{/hasQueryParams}}{{#returnProperty}}{{#isBinary}}, downloadToFile{{/isBinary}}{{/returnProperty}}, {{{projectName}}}.kAPITimeoutSeconds){{^returnProperty}} + #Pragma Unused localVarContent{{/returnProperty}} + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If {{#returnProperty}}{{#isBinary}}Not localVarSuccessful Or {{/isBinary}}{{/returnProperty}}localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New {{> nameException}}(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode{{#returnProperty}}{{^isBinary}} + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders{{/isBinary}}{{/returnProperty}} + + localOutStatus = New {{> nameException}}(localVarHttpStatus, "", {{#returnProperty}}{{^isBinary}}localVarContent{{/isBinary}}{{#isBinary}}""{{/isBinary}}{{/returnProperty}}{{^returnProperty}}""{{/returnProperty}}) + + localVarHTTPSocket.Close + + {{^returnProperty}}Return True{{/returnProperty}}{{#returnProperty}}{{#isBinary}}Return True{{/isBinary}}{{^isBinary}}Return {{operationId}}PrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData){{/isBinary}}{{/returnProperty}}{{/supportsAsync}} + End {{^supportsAsync}}Function{{/supportsAsync}}{{#supportsAsync}}Sub{{/supportsAsync}} + #tag EndMethod + +{{#returnProperty}}{{^isBinary}} #tag Method, Flags = &h21 + Private Function {{operationId}}PrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As {{> nameException}}, Content As String, {{^isArray}}ByRef {{/isArray}}outData{{#isArray}}(){{/isArray}} As {{> inlineModelParameterDatatype}}) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = {{{projectName}}}.EncodingFromContentType(contentType){{^isBinary}} + Content = DefineEncoding(Content, contentEncoding){{/isBinary}} + + If HTTPStatus > 199 and HTTPStatus < 300 then + {{^isBinary}}If contentType.LeftB(16) = "application/json" then + {{^isArray}}{{#isInteger}}outData = Val(Content){{/isInteger}}{{#isNumber}}outData = Val(Content){{/isNumber}}{{#isBoolean}}outData = BoolFromString(Content){{/isBoolean}}{{#isByteArray}}outData = DecodeBase64(Content){{/isByteArray}}{{#isString}}outData = Content{{/isString}}{{^isByteArray}}{{^isString}}{{^isBoolean}}{{^isInteger}}{{^isNumber}} + {{^isFreeFormObject}}outData = New {{> inlineModelParameterDatatype}}{{/isFreeFormObject}} + Try + {{^isMap}}{{^isFreeFormObject}}Xoson.fromJSON(outData, Content.toText()){{/isFreeFormObject}}{{/isMap}}{{#isMap}}outData = ParseJSON(Content){{/isMap}}{{#isFreeFormObject}}outData = ParseJSON(Content){{/isFreeFormObject}} + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try{{/isNumber}}{{/isInteger}}{{/isBoolean}}{{/isString}}{{/isByteArray}}{{/isArray}} + {{#isArray}}Try + {{^isMap}}{{^isFreeFormObject}}Xoson.fromJSON(outData, Content.toText()){{/isFreeFormObject}}{{/isMap}}{{#isMap}}outData = ParseJSON(Content){{/isMap}}{{#isFreeFormObject}}outData = ParseJSON(Content){{/isFreeFormObject}} + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try{{/isArray}} + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + {{/isBinary}} + Else + error.Message = error.Message{{^isBinary}} + ". " + Content{{/isBinary}} + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod +{{/isBinary}}{{/returnProperty}} +{{#supportsAsync}} #tag Method, Flags = &h21 + Private Sub {{operationId}}_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New {{> nameException}}(Code) + {{#returnProperty}}Dim {{#isBinary}}file As FolderItem{{/isBinary}}{{^isBinary}}data{{#isArray}}(){{/isArray}} As {{> inlineModelParameterDatatype}}{{/isBinary}} + {{/returnProperty}}CallbackHandler.{{operationId}}Callback(error{{#returnProperty}}, {{^isBinary}}data{{/isBinary}}{{#isBinary}}file{{/isBinary}}{{/returnProperty}}) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub {{operationId}}_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, {{#returnProperty}}{{#isBinary}}File As FolderItem{{/isBinary}}{{^isBinary}}Content As String{{/isBinary}}{{/returnProperty}}{{^returnProperty}}Content As String{{/returnProperty}}) + #Pragma Unused URL + {{^returnProperty}}#Pragma Unused Headers + #Pragma Unused Content{{/returnProperty}}{{#returnProperty}}{{#isBinary}}#Pragma Unused Headers{{/isBinary}}{{/returnProperty}} + + If sender <> nil Then sender.Close() + + Dim error As New {{> nameException}}(HTTPStatus, "", {{#returnProperty}}{{^isBinary}}Content{{/isBinary}}{{#isBinary}}""{{/isBinary}}{{/returnProperty}}{{^returnProperty}}""{{/returnProperty}}) + + {{#returnProperty}}{{^isBinary}}Dim data{{#isArray}}(){{/isArray}} As {{> inlineModelParameterDatatype}} + Call {{operationId}}PrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data){{/isBinary}}{{/returnProperty}} + + CallbackHandler.{{operationId}}Callback(error{{#returnProperty}}, {{^isBinary}}data{{/isBinary}}{{#isBinary}}File{{/isBinary}}{{/returnProperty}}) + End Sub + #tag EndMethod + +{{#returnProperty}}{{#isBinary}} #tag Method, Flags = &h21 + Private Sub {{operationId}}_progress(sender As HTTPSecureSocket, BytesReceived As Integer, TotalBytes As Integer, NewData As String) + CallbackHandler.{{operationId}}DownloadProgress(BytesReceived, TotalBytes) + End Sub + #tag EndMethod{{/isBinary}}{{/returnProperty}}{{/supportsAsync}} + +{{#allParams}}{{#isEnum}}{{^isInteger}} #tag Method, Flags = &h21 + Private Function {{> inlineNameOperationEnum}}ToString(value As {{> inlineNameOperationEnum}}) As String + Select Case value + {{#allowableValues}}{{#enumVars}} + Case {{> inlineNameOperationEnum}}.{{{name}}} + Return {{{value}}}{{/enumVars}}{{/allowableValues}} + {{#enumUnknownDefaultCase}}Case {{{enumUnknownDefaultCaseName}}} + Return "{{{enumUnknownDefaultCaseName}}}"{{/enumUnknownDefaultCase}} + End Select + Return "" + End Function + #tag EndMethod +{{/isInteger}}{{/isEnum}}{{/allParams}} +{{/operation}}{{/operations}} + + #tag Method, Flags = &h21 + Private Function AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + #Pragma Unused Realm + #Pragma Unused Headers + Name = Me.BasicAuthUser + Password = Me.BasicAuthPassword + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub PrivateFuncPrepareSocket(socket As HTTPSecureSocket) + socket.Secure = Me.useHTTPS + socket.ConnectionType = SSLSocket.TLSv12 + socket.Port = Me.Port + socket.RequestHeaders.Delete("Accept") + socket.RequestHeaders.AppendHeader("Accept", "text/plain") + socket.RequestHeaders.AppendHeader("Accept", "application/json") + socket.RequestHeaders.AppendHeader("Content-Type", "application/json") + + If Me.AdditionalHeaders <> Nil Then + For Each HeaderName As Variant In Me.AdditionalHeaders.Keys + Dim headerValueS As Variant = additionalHeaders.Value(HeaderName) + If headerValueS.IsArray Then + If headerValueS.ArrayElementType = Variant.TypeString Then + Dim values() As String = headerValueS + For Each value As String In values + socket.RequestHeaders.AppendHeader(HeaderName, value) + Next + Else + Raise New {{> nameException}}(kErrorInternal, "AdditionalHeaders only support Strings and String arrays as values.") + End If + Else + socket.RequestHeaders.AppendHeader(HeaderName, headerValueS.StringValue) + End If + Next + End If + End Sub + #tag EndMethod + + +{{#description}} #tag Note, Name = Description + {{{.}}} + + #tag EndNote +{{/description}} + + #tag Property, Flags = &h0 + AdditionalHeaders As Dictionary + #tag EndProperty + +{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}} #tag Property, Flags = &h0 + ApiKey{{{name}}} As String + #tag EndProperty + +{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}} #tag Property, Flags = &h0 + BasePath As String = "{{{basePath}}}" + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthPassword As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthUser As String + #tag EndProperty + +{{#supportsAsync}} #tag Property, Flags = &h0 + CallbackHandler As {{{projectName}}}.{{{apiPackage}}}.{{classname}}CallbackHandler + #tag EndProperty + +{{/supportsAsync}} #tag Property, Flags = &h0 + Host As String = "{{{host}}}" + #tag EndProperty + + #tag Property, Flags = &h0 + Port As Integer + #tag EndProperty + + #tag Property, Flags = &h0 + UseHTTPS As Boolean = true + #tag EndProperty + +{{#operations}}{{#operation}}{{#allParams}}{{#isEnum}} #tag Enum, Name = {{> inlineNameOperationEnum}}, Type = Integer, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} + {{#allowableValues}}{{#enumVars}} + {{{name}}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{/enumVars}}{{/allowableValues}} + {{#enumUnknownDefaultCase}}{{{enumUnknownDefaultCaseName}}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{/enumUnknownDefaultCase}} + #tag EndEnum + +{{/isEnum}} +{{/allParams}}{{/operation}}{{/operations}} + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthUser" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthPassword" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="UseHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/modules/openapi-generator/src/main/resources/xojo-client/api_mock.mustache b/modules/openapi-generator/src/main/resources/xojo-client/api_mock.mustache new file mode 100644 index 000000000000..f989d58fc942 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/api_mock.mustache @@ -0,0 +1,132 @@ +#tag Class +Public Class Mock +{{#apiInfo}}{{#apis}}{{^supportsAsync}} #tag Method, Flags = &h0 + Sub test{{classname}}(basePath As String) + Dim error As New {{> nameException}}(0, "No Error") + Dim tmpDownloadFile As FolderItem = GetTemporaryFolderItem + + Dim api As New {{projectName}}.{{apiPackage}}.{{classname}} + api.BasePath = basePath + api.BasicAuthUser = "user" + api.BasicAuthPassword = "password" + api.UseHTTPS = false + {{#operations}}{{#operation}} + + // Operation {{{operationIdOriginal}}}{{#summary}} + // {{{.}}}{{/summary}}{{^supportsAsync}} + // - parameter localOutStatus: Information on whether the operation succeeded.{{/supportsAsync}}{{#returnProperty}} + // - {{#isBinary}}parameter downloadToFile: The writable, non-existing path in the filesystem where the response body should be stored.{{/isBinary}}{{^isBinary}}{{^supportsAsync}}parameter localOutData: On success, contains the data returned by the API.{{/supportsAsync}}{{/isBinary}}{{/returnProperty}}{{#allParams}} + // - parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}} + // + // - {{httpMethod}} {{{path}}}{{#notes}} + // - {{{.}}}{{/notes}}{{#subresourceOperation}} + // - subresourceOperation: {{.}}{{/subresourceOperation}}{{#defaultResponse}} + // - defaultResponse: {{.}}{{/defaultResponse}} + //{{#authMethods}} + // - {{#isBasic}}BASIC{{/isBasic}}{{#isOAuth}}OAuth{{/isOAuth}}{{#isApiKey}}API Key{{/isApiKey}}: + // - type: {{type}}{{#keyParamName}} {{keyParamName}} {{#isKeyInQuery}}(QUERY){{/isKeyInQuery}}{{#isKeyInHeader}}(HEADER){{/isKeyInHeader}}{{/keyParamName}} + // - name: {{name}}{{/authMethods}} + //{{#hasResponseHeaders}} + // - responseHeaders: [{{#responseHeaders}}{{{baseName}}}({{{dataType}}}){{^-last}}, {{/-last}}{{/responseHeaders}}]{{/hasResponseHeaders}}{{#allParams}}{{#isArray}} + Dim {{operationId}}{{paramName}}Array() As {{#items}}{{#isModel}}{{> prefixModel}}{{/isModel}}{{{dataType}}}{{/items}}{{/isArray}}{{#isModel}} + Dim {{operationId}}{{paramName}}Model As New {{> prefixModel}}{{{dataType}}} + {{#requiredVars}}{{^isArray}}{{^isEnum}}{{^isEnumOrRef}}{{operationId}}{{paramName}}Model.{{{name}}} = {{#isString}}"{{{example}}}"{{/isString}}{{#isDate}}FromRFC3339("{{{example}}}"){{/isDate}}{{#isDateTime}}FromRFC3339("{{{example}}}"){{/isDateTime}}{{^isString}}{{^isDate}}{{^isDateTime}}{{{example}}}{{/isDateTime}}{{/isDate}}{{/isString}} + {{/isEnumOrRef}}{{/isEnum}}{{/isArray}}{{#isEnum}}// TODO: generating in-model enums is not supported. Issue something like: {{> prefixModel}}MODEL_NAME.{{enumName}}ToString({{> prefixModel}}MODEL_NAME.{{enumName}}.SOMETHING){{/isEnum}}{{/requiredVars}}{{/isModel}}{{/allParams}}{{#returnProperty}}{{^isBinary}} + Dim {{operationId}}Data{{#isArray}}(){{/isArray}} As {{#isModel}}{{> prefixModel}}{{/isModel}}{{#isArray}}{{#items}}{{#isModel}}{{> prefixModel}}{{/isModel}}{{{dataType}}}{{/items}}{{/isArray}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isBinary}}{{/returnProperty}} + If api.{{operationId}}(error{{#returnProperty}}, {{^isBinary}}{{operationId}}Data{{/isBinary}}{{#isBinary}}tmpDownloadFile{{/isBinary}}{{/returnProperty}}{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#isModel}}{{operationId}}{{paramName}}Model{{/isModel}}{{^isModel}}{{#isEnum}}{{projectName}}.{{apiPackage}}.{{classname}}.{{enumName}}_{{operationId}}.{{#allowableValues}}{{#enumVars}}{{#-first}}{{{name}}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnum}}{{^isEnum}}{{#isArray}}{{operationId}}{{paramName}}Array{{/isArray}}{{^isArray}}{{#isString}}"{{/isString}}{{{example}}}{{#isString}}"{{/isString}}{{/isArray}}{{#schema}}{{#isEnumRef}}{{projectName}}.{{apiPackage}}.{{classname}}.{{dataType}}.{{#allowableValues}}{{#enumVars}}{{#-first}}{{{name}}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnumRef}}{{/schema}}{{/isEnum}}{{/isModel}}{{^-last}}, {{/-last}}{{/allParams}}) Then + Print("[+] {{classname}}.{{operationId}} successful.") + Else + Print("[-] {{classname}}.{{operationId}} unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + {{/operation}}{{/operations}} + End Sub + #tag EndMethod +{{/supportsAsync}}{{/apis}}{{/apiInfo}} + + #tag Method, Flags = &h21 + Private Function FromRFC3339(stringRepresentation As String) As Date + + Dim d As New Xoson.DateIntermediate(stringRepresentation) + + return New Date(d.year, d.month, d.day, d.hour, d.minute, d.second, 0.0) + End Function + #tag EndMethod + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="useHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/modules/openapi-generator/src/main/resources/xojo-client/inlineCodeParamCheckNil.mustache b/modules/openapi-generator/src/main/resources/xojo-client/inlineCodeParamCheckNil.mustache new file mode 100644 index 000000000000..9f3b9f6a373f --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/inlineCodeParamCheckNil.mustache @@ -0,0 +1 @@ +{{^required}}{{^isEnum}}If {{paramName}} <> nil Then {{/isEnum}}{{#model}}{{^isEnum}}If {{paramName}} <> nil Then {{/isEnum}}{{/model}}{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/xojo-client/inlineCodeParamSerialize.mustache b/modules/openapi-generator/src/main/resources/xojo-client/inlineCodeParamSerialize.mustache new file mode 100644 index 000000000000..8b80cb1f0f54 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/inlineCodeParamSerialize.mustache @@ -0,0 +1 @@ +{{#isEnum}}{{enumName}}_{{operationId}}ToString({{{paramName}}}){{/isEnum}}{{^isEnum}}{{^isPrimitiveType}}Xoson.toJSON({{{paramName}}}){{/isPrimitiveType}}{{#isPrimitiveType}}{{{paramName}}}{{^isString}}{{^isByteArray}}.{{#isBinary}}LocalFuncSerializeFile{{/isBinary}}{{^isBinary}}{{#isDate}}ToRFC3339{{/isDate}}{{^isDate}}{{#isDateTime}}ToRFC3339{{/isDateTime}}{{^isDateTime}}ToString{{/isDateTime}}{{/isDate}}{{/isBinary}}{{/isByteArray}}{{/isString}}{{/isPrimitiveType}}{{/isEnum}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/xojo-client/inlineCodeParamSerializeArray.mustache b/modules/openapi-generator/src/main/resources/xojo-client/inlineCodeParamSerializeArray.mustache new file mode 100644 index 000000000000..f6fa98c6d3a3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/inlineCodeParamSerializeArray.mustache @@ -0,0 +1 @@ +{{#isEnum}}{{enumName}}_{{operationId}}ToString(localVarItem{{{paramName}}}){{/isEnum}}{{^isEnum}}{{^isPrimitiveType}}Xoson.toJSON(localVarItem{{{paramName}}}){{/isPrimitiveType}}{{#isPrimitiveType}}localVarItem{{{paramName}}}{{^isString}}.ToString{{/isString}}{{/isPrimitiveType}}{{/isEnum}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/xojo-client/inlineModelParameterDatatype.mustache b/modules/openapi-generator/src/main/resources/xojo-client/inlineModelParameterDatatype.mustache new file mode 100644 index 000000000000..741c0b7f301e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/inlineModelParameterDatatype.mustache @@ -0,0 +1 @@ +{{#isModel}}{{> prefixModel}}{{/isModel}}{{#isArray}}{{#items}}{{#isModel}}{{> prefixModel}}{{/isModel}}{{{dataType}}}{{/items}}{{/isArray}}{{^isArray}}{{{dataType}}}{{/isArray}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/xojo-client/inlineNameOperationEnum.mustache b/modules/openapi-generator/src/main/resources/xojo-client/inlineNameOperationEnum.mustache new file mode 100644 index 000000000000..01be2950140b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/inlineNameOperationEnum.mustache @@ -0,0 +1 @@ +{{#isEnum}}{{enumName}}_{{operationId}}{{/isEnum}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/xojo-client/model.mustache b/modules/openapi-generator/src/main/resources/xojo-client/model.mustache new file mode 100644 index 000000000000..42f2d87512d2 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/model.mustache @@ -0,0 +1,2 @@ +{{#models}}{{#model}}{{#isEnum}}{{> modelOptionalEnum}}{{/isEnum}}{{^isEnum}}{{> modelClass}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/modules/openapi-generator/src/main/resources/xojo-client/modelClass.mustache b/modules/openapi-generator/src/main/resources/xojo-client/modelClass.mustache new file mode 100644 index 000000000000..cc07d2b31c86 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/modelClass.mustache @@ -0,0 +1,73 @@ +#tag Class +Protected Class {{classname}} +{{#parentModel}}Inherits {{{.}}}{{/parentModel}}{{#allVars}} + #tag Property, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} +{{#description}} #tag Note + {{{.}}} + #tag EndNote +{{/description}} + {{#deprecated}}Attributes( Deprecated ) {{/deprecated}}{{#nonPublicApi}}Protected {{/nonPublicApi}}{{{name}}}{{#isArray}}(){{/isArray}} As {{#isModel}}{{{projectName}}}.{{{modelPackage}}}.{{/isModel}}{{^required}}{{^isModel}}{{^isContainer}}{{^isDateTime}}{{^isDate}}{{^isAnyType}}{{^isObject}}{{^isFreeFormObject}}Xoson.O.Optional{{/isFreeFormObject}}{{/isObject}}{{/isAnyType}}{{/isDate}}{{/isDateTime}}{{/isContainer}}{{/isModel}}{{/required}}{{^isArray}}{{^isEnumRef}}{{{dataType}}}{{/isEnumRef}}{{#isEnumRef}}{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}String{{/isString}}{{^isString}}Integer{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnumRef}}{{/isArray}}{{#isArray}}{{#items}}{{#isModel}}{{{projectName}}}.{{{modelPackage}}}.{{/isModel}}{{{dataType}}}{{/items}}{{/isArray}} + #tag EndProperty + +{{/allVars}} + +{{#allVars}}{{#isEnum}}{{> modelInlineEnumDeclaration}} +{{/isEnum}}{{/allVars}} +{{#allVars}}{{#isEnum}}{{^isInteger}} #tag {{#nonPublicApi}}Protected {{/nonPublicApi}}Method, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} + {{#nonPublicApi}}Protected {{/nonPublicApi}}Shared Function {{enumName}}ToString(value As {{enumName}}) As String + Select Case value + {{#allowableValues}}{{#enumVars}} + Case {{enumName}}.{{{name}}} + Return {{{value}}}{{/enumVars}}{{/allowableValues}} + {{#enumUnknownDefaultCase}}Case {{{enumUnknownDefaultCaseName}}} + Return "{{{enumUnknownDefaultCaseName}}}"{{/enumUnknownDefaultCase}} + End Select + Return "" + End Function + #tag EndMethod +{{/isInteger}}{{/isEnum}}{{/allVars}} + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty{{#allVars}}{{^isEnum}}{{^isByteArray}} + #tag ViewProperty + Name="{{{name}}}" + Visible=false + Group="Behavior" + InitialValue="" + Type="{{{datatype}}}" + EditorType="{{#isStringSchema}}MultiLineEditor{{/isStringSchema}}" + #tag EndViewProperty{{/isByteArray}}{{/isEnum}}{{/allVars}} + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/modules/openapi-generator/src/main/resources/xojo-client/modelInlineEnumDeclaration.mustache b/modules/openapi-generator/src/main/resources/xojo-client/modelInlineEnumDeclaration.mustache new file mode 100644 index 000000000000..db72b688c349 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/modelInlineEnumDeclaration.mustache @@ -0,0 +1,5 @@ + #tag Enum, Name = {{enumName}}, Type = Integer, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}21{{/nonPublicApi}} + {{#allowableValues}}{{#enumVars}} + {{{name}}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{/enumVars}}{{/allowableValues}} + {{#enumUnknownDefaultCase}}Unknown{{#isInteger}} = {{{value}}}{{/isInteger}}{{/enumUnknownDefaultCase}} + #tag EndEnum diff --git a/modules/openapi-generator/src/main/resources/xojo-client/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/xojo-client/modelOneOf.mustache new file mode 100644 index 000000000000..5151b32982ea --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/modelOneOf.mustache @@ -0,0 +1,88 @@ +#tag Class +Protected Class {{classname}} + #tag Property, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} + {{#nonPublicApi}}Protected {{/nonPublicApi}}kind As Kind + #tag EndProperty + +{{#oneOf}} #tag Property, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} + {{#nonPublicApi}}Protected {{/nonPublicApi}}{{{.}}} As {{{.}}} + #tag EndProperty + +{{/oneOf}} + + #tag Method, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} + {{#nonPublicApi}}Protected {{/nonPublicApi}}Function Deserialize(value As String) As Boolean + {{#oneOf}}Try + Dim data As New {{{.}}} + Xoson.fromJSON(data, value.toText()) 'TODO here we would need the `strictness` feature of Xoson + Me.{{{.}}} = data + Return True + Catch e As JSONException + Return False 'early exit, since this is invalid JSON + + Catch e As Xoson.XosonException + 'this was not the right oneOf, try next one + End Try{{/oneOf}} + Return False + End Function + #tag EndMethod + + #tag Method, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} + {{#nonPublicApi}}Protected {{/nonPublicApi}}Function Serialize() As String + Select Case Me.Kind{{#oneOf}} + Case {{{.}}} + Return Xoson.toJSON(Me.{{{.}}}{{/oneOf}} + End Select + Return "" + End Function + #tag EndMethod + + #tag Enum, Name = Kind, Type = Integer, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} + {{#oneOf}} + {{{.}}}{{/oneOf}} + #tag EndEnum + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty{{#allVars}}{{^isEnum}}{{^isByteArray}} + #tag ViewProperty + Name="{{{name}}}" + Visible=false + Group="Behavior" + InitialValue="" + Type="{{{datatype}}}" + EditorType="{{#isStringSchema}}MultiLineEditor{{/isStringSchema}}" + #tag EndViewProperty{{/isByteArray}}{{/isEnum}}{{/allVars}} + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/modules/openapi-generator/src/main/resources/xojo-client/modelOptionalEnum.mustache b/modules/openapi-generator/src/main/resources/xojo-client/modelOptionalEnum.mustache new file mode 100644 index 000000000000..a7bc681e9ab2 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/modelOptionalEnum.mustache @@ -0,0 +1,68 @@ +#tag Class +Protected Class {{classname}}{{> suffixOptionalEnum}} + #tag Method, Flags = &h0 + Function Operator_Convert() As {{{projectName}}}.{{{modelPackage}}}.{{classname}} + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As {{{projectName}}}.{{{modelPackage}}}.{{classname}}) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As {{{projectName}}}.{{{modelPackage}}}.{{classname}}) + Value = rhs + End Sub + #tag EndMethod + +{{^isInteger}} #tag Method, Flags = &h0 + Function ToString() As String + Return {{{projectName}}}.{{{modelPackage}}}.{{classname}}ToString(Value) + End Function + #tag EndMethod +{{/isInteger}} + + #tag Property, Flags = &h{{^nonPublicApi}}0{{/nonPublicApi}}{{#nonPublicApi}}1{{/nonPublicApi}} + Value As {{{projectName}}}.{{{modelPackage}}}.{{classname}} + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/modules/openapi-generator/src/main/resources/xojo-client/nameException.mustache b/modules/openapi-generator/src/main/resources/xojo-client/nameException.mustache new file mode 100644 index 000000000000..7c98d98f24b4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/nameException.mustache @@ -0,0 +1 @@ +{{{projectName}}}.{{{projectName}}}Exception \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/xojo-client/prefixModel.mustache b/modules/openapi-generator/src/main/resources/xojo-client/prefixModel.mustache new file mode 100644 index 000000000000..13470897d268 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/prefixModel.mustache @@ -0,0 +1 @@ +{{{projectName}}}.{{{modelPackage}}}. \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/xojo-client/prefixXosonOptional.mustache b/modules/openapi-generator/src/main/resources/xojo-client/prefixXosonOptional.mustache new file mode 100644 index 000000000000..7b273e82ac9e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/prefixXosonOptional.mustache @@ -0,0 +1 @@ +{{^required}}{{#isPrimitiveType}}{{^isContainer}}{{^isDate}}{{^isDateTime}}{{^isFile}}{{^isBinary}}{{^isByteArray}}{{^isAnyType}}Xoson.O.Optional{{/isAnyType}}{{/isByteArray}}{{/isBinary}}{{/isFile}}{{/isDateTime}}{{/isDate}}{{/isContainer}}{{/isPrimitiveType}}{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/xojo-client/suffixOptionalEnum.mustache b/modules/openapi-generator/src/main/resources/xojo-client/suffixOptionalEnum.mustache new file mode 100644 index 000000000000..3869ccbc9753 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/xojo-client/suffixOptionalEnum.mustache @@ -0,0 +1 @@ +Optional \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/XojoClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/XojoClientOptionsProvider.java new file mode 100644 index 000000000000..05a6f60a4347 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/XojoClientOptionsProvider.java @@ -0,0 +1,69 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * Copyright 2018 SmartBear Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen.options; + +import com.google.common.collect.ImmutableMap; +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.languages.XojoClientCodegen; + +import java.io.File; +import java.util.Map; + +public class XojoClientOptionsProvider implements OptionsProvider { + public static final String NON_PUBLIC_API_VALUE = "false"; + public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "false"; + public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false"; + public static final String LIBRARY_VALUE = "httpsocket"; + public static final String SERIALIZATION_LIBRARY_VALUE = "xoson"; + public static final String PROJECT_NAME_VALUE = "OpenAPIClient"; + public static final String SUPPORTS_ASYNC_VALUE = "true"; + public static final String API_PACKAGE_VALUE = "APIs"; + public static final String MODEL_PACKAGE_VALUE = "Models"; + + @Override + public String getLanguage() { + return "swift5"; + } + + @Override + public Map createOptions() { + ImmutableMap.Builder builder = new ImmutableMap.Builder(); + return builder.put(CodegenConstants.NON_PUBLIC_API, NON_PUBLIC_API_VALUE) + .put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE) + .put(CodegenConstants.LIBRARY, LIBRARY_VALUE) + .put(CodegenConstants.SERIALIZATION_LIBRARY, SERIALIZATION_LIBRARY_VALUE) + .put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE) + .put(CodegenConstants.SUPPORTS_ASYNC, SUPPORTS_ASYNC_VALUE) + .put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE) + .put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE) + .put(CodegenConstants.API_NAME_PREFIX, "") + .put(CodegenConstants.PROJECT_NAME, PROJECT_NAME_VALUE) + .put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true") + .put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, "true") + .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true") + .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, "true") + .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, "false") + .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "false") + .build(); + } + + @Override + public boolean isServer() { + return false; + } +} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/xojo/client/ModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/xojo/client/ModelTest.java new file mode 100644 index 000000000000..18c8cff07917 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/xojo/client/ModelTest.java @@ -0,0 +1,29 @@ +package org.openapitools.codegen.xojo.client; + +import org.openapitools.codegen.*; +import org.openapitools.codegen.languages.XojoClientCodegen; +import io.swagger.models.*; +import io.swagger.models.properties.*; + +import org.testng.Assert; +import org.testng.annotations.Test; + +@SuppressWarnings("static-method") +public class ModelTest { + + @Test(description = "convert a simple java model") + public void simpleModelTest() { + final Model model = new ModelImpl() + .description("a sample model") + .property("id", new LongProperty()) + .property("name", new StringProperty()) + .required("id") + .required("name"); + final DefaultCodegen codegen = new XojoClientCodegen(); + + // TODO: Complete this test. + //Assert.fail("Not implemented."); + } + +} + diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/xojo/client/OptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/xojo/client/OptionsTest.java new file mode 100644 index 000000000000..3cd79d3ba607 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/xojo/client/OptionsTest.java @@ -0,0 +1,35 @@ +package org.openapitools.codegen.xojo.client; + +import org.openapitools.codegen.AbstractOptionsTest; +import org.openapitools.codegen.CodegenConfig; +import org.openapitools.codegen.languages.XojoClientCodegen; +import org.openapitools.codegen.options.OptionsProvider; +import org.openapitools.codegen.options.XojoClientOptionsProvider; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +public class OptionsTest extends AbstractOptionsTest { + private XojoClientCodegen clientCodegen = mock(XojoClientCodegen.class, mockSettings); + + public OptionsTest() { + super(new XojoClientOptionsProvider()); + } + + @Override + protected CodegenConfig getCodegenConfig() { + return clientCodegen; + } + + @SuppressWarnings("unused") + @Override + protected void verifyOptions() { + verify(clientCodegen).setProjectName(XojoClientOptionsProvider.PROJECT_NAME_VALUE); + verify(clientCodegen).setNonPublicApi(Boolean.parseBoolean(XojoClientOptionsProvider.NON_PUBLIC_API_VALUE)); + verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(XojoClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE)); + verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(XojoClientOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE)); + verify(clientCodegen).setSerializationLibrary(XojoClientOptionsProvider.SERIALIZATION_LIBRARY_VALUE); + verify(clientCodegen).setLibrary(XojoClientOptionsProvider.LIBRARY_VALUE); + } +} + diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/xojo/client/XojoClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/xojo/client/XojoClientCodegenTest.java new file mode 100644 index 000000000000..21a779e30e55 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/xojo/client/XojoClientCodegenTest.java @@ -0,0 +1,144 @@ +package org.openapitools.codegen.xojo.client; + +import org.openapitools.codegen.*; +import org.openapitools.codegen.languages.XojoClientCodegen; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.Operation; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class XojoClientCodegenTest { + + XojoClientCodegen codegen = new XojoClientCodegen(); + + @Test(enabled = true) + public void testToEnumVarNameCapitalizedReservedWord() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("AS", null), "Escapedas"); + } + + @Test(enabled = true) + public void testToEnumVarNameReservedWord() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("Public", null), "Escapedpublic"); + } + + @Test(enabled = true) + public void testToEnumVarNameShouldNotBreakNonReservedWord() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("Error", null), "Error"); + } + + @Test(enabled = true) + public void testToEnumVarNameShouldNotBreakCorrectName() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("EntryName", null), "EntryName"); + } + + @Test(enabled = true) + public void testToEnumVarNameSingleWordAllCaps() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("VALUE", null), "Value"); + } + + @Test(enabled = true) + public void testToEnumVarNameSingleWordLowercase() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("value", null), "Value"); + } + + @Test(enabled = true) + public void testToEnumVarNameCapitalsWithUnderscore() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("ENTRY_NAME", null), "EntryName"); + } + + @Test(enabled = true) + public void testToEnumVarNameCapitalsWithDash() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("ENTRY-NAME", null), "EntryName"); + } + + @Test(enabled = true) + public void testToEnumVarNameCapitalsWithSpace() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("ENTRY NAME", null), "EntryName"); + } + + @Test(enabled = true) + public void testToEnumVarNameLowercaseWithUnderscore() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("entry_name", null), "EntryName"); + } + + @Test(enabled = true) + public void testToEnumVarNameStartingWithNumber() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("123EntryName", null), "Escaped123EntryName"); + Assert.assertEquals(codegen.toEnumVarName("123Entry_name", null), "Escaped123EntryName"); + Assert.assertEquals(codegen.toEnumVarName("123EntryName123", null), "Escaped123EntryName123"); + } + + @Test(enabled = true) + public void testToEnumVarNameSpecialCharacters() throws Exception { + Assert.assertEquals(codegen.toEnumVarName("1:1", null), "Escaped1Colon1"); + Assert.assertEquals(codegen.toEnumVarName("1:One", null), "Escaped1ColonOne"); + Assert.assertEquals(codegen.toEnumVarName("Apple&Pie", null), "AppleAmpersandPie"); + Assert.assertEquals(codegen.toEnumVarName("$", null), "Dollar"); + Assert.assertEquals(codegen.toEnumVarName("+1", null), "EscapedPlus1"); + Assert.assertEquals(codegen.toEnumVarName(">=", null), "GreaterThanOrEqualTo"); + } + + @Test(description = "returns Data when response format is binary", enabled = true) + public void binaryDataTest() { + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/binaryDataTest.json"); + final DefaultCodegen codegen = new XojoClientCodegen(); + codegen.setOpenAPI(openAPI); + final String path = "/tests/binaryResponse"; + final Operation p = openAPI.getPaths().get(path).getPost(); + final CodegenOperation op = codegen.fromOperation(path, "post", p, null); + + Assert.assertEquals(op.returnType, "FolderItem"); + Assert.assertEquals(op.bodyParam.dataType, "FolderItem"); + Assert.assertTrue(op.bodyParam.isBinary); + Assert.assertTrue(op.responses.get(0).isBinary); + } + + @Test(description = "returns Date when response format is date per default", enabled = true) + public void dateDefaultTest() { + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/datePropertyTest.json"); + final DefaultCodegen codegen = new XojoClientCodegen(); + codegen.setOpenAPI(openAPI); + final String path = "/tests/dateResponse"; + final Operation p = openAPI.getPaths().get(path).getPost(); + final CodegenOperation op = codegen.fromOperation(path, "post", p, null); + + Assert.assertEquals(op.returnType, "Date"); + Assert.assertEquals(op.bodyParam.dataType, "Date"); + } + + @Test(description = "type from languageSpecificPrimitives should not be prefixed", enabled = true) + public void prefixExceptionTest() { + final DefaultCodegen codegen = new XojoClientCodegen(); + codegen.setModelNamePrefix("API"); + + final String result = codegen.toModelName("Currency"); + Assert.assertEquals(result, "Currency"); + } + + @Test(description = "type from languageSpecificPrimitives should not be suffixed", enabled = true) + public void suffixExceptionTest() { + final DefaultCodegen codegen = new XojoClientCodegen(); + codegen.setModelNameSuffix("API"); + + final String result = codegen.toModelName("Currency"); + Assert.assertEquals(result, "Currency"); + } + + @Test(description = "Other types should be prefixed", enabled = true) + public void prefixTest() { + final DefaultCodegen codegen = new XojoClientCodegen(); + codegen.setModelNamePrefix("API"); + + final String result = codegen.toModelName("MyType"); + Assert.assertEquals(result, "APIMyType"); + } + + @Test(description = "Other types should be suffixed", enabled = true) + public void suffixTest() { + final DefaultCodegen codegen = new XojoClientCodegen(); + codegen.setModelNameSuffix("API"); + + final String result = codegen.toModelName("MyType"); + Assert.assertEquals(result, "MyTypeAPI"); + } +} diff --git a/samples/client/petstore/xojo/client-synchronous/.openapi-generator-ignore b/samples/client/petstore/xojo/client-synchronous/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# 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 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 (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/xojo/client-synchronous/.openapi-generator/FILES b/samples/client/petstore/xojo/client-synchronous/.openapi-generator/FILES new file mode 100644 index 000000000000..10eb1fcff85f --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/.openapi-generator/FILES @@ -0,0 +1,25 @@ +App.xojo_code +Build Automation.xojo_code +Mock.xojo_code +README.md +XojoOpenAPIClientSynchronous.xojo_code +XojoOpenAPIClientSynchronous.xojo_project +XojoOpenAPIClientSynchronous.xojo_resources +XojoOpenAPIClientSynchronous/APIs.xojo_code +XojoOpenAPIClientSynchronous/APIs/PetApi.xojo_code +XojoOpenAPIClientSynchronous/APIs/StoreApi.xojo_code +XojoOpenAPIClientSynchronous/APIs/UserApi.xojo_code +XojoOpenAPIClientSynchronous/Models.xojo_code +XojoOpenAPIClientSynchronous/Models/ApiResponse.xojo_code +XojoOpenAPIClientSynchronous/Models/ApiResponseOptional.xojo_code +XojoOpenAPIClientSynchronous/Models/Category.xojo_code +XojoOpenAPIClientSynchronous/Models/CategoryOptional.xojo_code +XojoOpenAPIClientSynchronous/Models/Order.xojo_code +XojoOpenAPIClientSynchronous/Models/OrderOptional.xojo_code +XojoOpenAPIClientSynchronous/Models/Pet.xojo_code +XojoOpenAPIClientSynchronous/Models/PetOptional.xojo_code +XojoOpenAPIClientSynchronous/Models/Tag.xojo_code +XojoOpenAPIClientSynchronous/Models/TagOptional.xojo_code +XojoOpenAPIClientSynchronous/Models/User.xojo_code +XojoOpenAPIClientSynchronous/Models/UserOptional.xojo_code +XojoOpenAPIClientSynchronous/XojoOpenAPIClientSynchronousException.xojo_code diff --git a/samples/client/petstore/xojo/client-synchronous/.openapi-generator/VERSION b/samples/client/petstore/xojo/client-synchronous/.openapi-generator/VERSION new file mode 100644 index 000000000000..ba8a874deab9 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/xojo/client-synchronous/App.xojo_code b/samples/client/petstore/xojo/client-synchronous/App.xojo_code new file mode 100644 index 000000000000..22b1c314af18 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/App.xojo_code @@ -0,0 +1,18 @@ +#tag Class +Protected Class App +Inherits ConsoleApplication + #tag Event + Function Run(args() as String) As Integer + #Pragma Unused args + Dim m As New Mock + m.testPetApi("http://localhost:4010") 'original basePath: http://petstore.swagger.io/v2 + m.testStoreApi("http://localhost:4010") 'original basePath: http://petstore.swagger.io/v2 + m.testUserApi("http://localhost:4010") 'original basePath: http://petstore.swagger.io/v2 + End Function + #tag EndEvent + + + #tag ViewBehavior + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/Build Automation.xojo_code b/samples/client/petstore/xojo/client-synchronous/Build Automation.xojo_code new file mode 100644 index 000000000000..f9b6aeee7312 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/Build Automation.xojo_code @@ -0,0 +1,14 @@ +#tag BuildAutomation + Begin BuildStepList Linux + Begin BuildProjectStep Build + End + End + Begin BuildStepList Mac OS X + Begin BuildProjectStep Build + End + End + Begin BuildStepList Windows + Begin BuildProjectStep Build + End + End +#tag EndBuildAutomation diff --git a/samples/client/petstore/xojo/client-synchronous/Mock.xojo_code b/samples/client/petstore/xojo/client-synchronous/Mock.xojo_code new file mode 100644 index 000000000000..d433ed95a9f5 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/Mock.xojo_code @@ -0,0 +1,569 @@ +#tag Class +Public Class Mock + #tag Method, Flags = &h0 + Sub testPetApi(basePath As String) + Dim error As New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(0, "No Error") + Dim tmpDownloadFile As FolderItem = GetTemporaryFolderItem + + Dim api As New XojoOpenAPIClientSynchronous.APIs.PetApi + api.BasePath = basePath + api.BasicAuthUser = "user" + api.BasicAuthPassword = "password" + api.UseHTTPS = false + + + // Operation addPet + // Add a new pet to the store + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter pet: (body) Pet object that needs to be added to the store + // + // - POST /pet + // - + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + Dim AddPetpetModel As New XojoOpenAPIClientSynchronous.Models.Pet + AddPetpetModel.name = "doggie" + + Dim AddPetData As XojoOpenAPIClientSynchronous.Models.Pet + If api.AddPet(error, AddPetData, AddPetpetModel) Then + Print("[+] PetApi.AddPet successful.") + Else + Print("[-] PetApi.AddPet unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation deletePet + // Deletes a pet + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter petId: (path) Pet id to delete + // - parameter apiKey: (header) (optional, default to Sample) + // + // - DELETE /pet/{petId} + // - + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + If api.DeletePet(error, 789, "apiKey_example") Then + Print("[+] PetApi.DeletePet successful.") + Else + Print("[-] PetApi.DeletePet unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation findPetsByStatus + // Finds Pets by status + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter status: (query) Status values that need to be considered for filter + // + // - GET /pet/findByStatus + // - Multiple status values can be provided with comma separated strings + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + Dim FindPetsByStatusstatusArray() As String + Dim FindPetsByStatusData() As XojoOpenAPIClientSynchronous.Models.Pet + If api.FindPetsByStatus(error, FindPetsByStatusData, XojoOpenAPIClientSynchronous.APIs.PetApi.StatusEnum_FindPetsByStatus.Available) Then + Print("[+] PetApi.FindPetsByStatus successful.") + Else + Print("[-] PetApi.FindPetsByStatus unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation findPetsByTags + // Finds Pets by tags + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter tags: (query) Tags to filter by + // + // - GET /pet/findByTags + // - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + Dim FindPetsByTagstagsArray() As String + Dim FindPetsByTagsData() As XojoOpenAPIClientSynchronous.Models.Pet + If api.FindPetsByTags(error, FindPetsByTagsData, FindPetsByTagstagsArray) Then + Print("[+] PetApi.FindPetsByTags successful.") + Else + Print("[-] PetApi.FindPetsByTags unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation getPetById + // Find pet by ID + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter petId: (path) ID of pet to return + // + // - GET /pet/{petId} + // - Returns a single pet + // - defaultResponse: Nil + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + Dim GetPetByIdData As XojoOpenAPIClientSynchronous.Models.Pet + If api.GetPetById(error, GetPetByIdData, 789) Then + Print("[+] PetApi.GetPetById successful.") + Else + Print("[-] PetApi.GetPetById unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation updatePet + // Update an existing pet + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter pet: (body) Pet object that needs to be added to the store + // + // - PUT /pet + // - + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + Dim UpdatePetpetModel As New XojoOpenAPIClientSynchronous.Models.Pet + UpdatePetpetModel.name = "doggie" + + Dim UpdatePetData As XojoOpenAPIClientSynchronous.Models.Pet + If api.UpdatePet(error, UpdatePetData, UpdatePetpetModel) Then + Print("[+] PetApi.UpdatePet successful.") + Else + Print("[-] PetApi.UpdatePet unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation updatePetWithForm + // Updates a pet in the store with form data + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter petId: (path) ID of pet that needs to be updated + // - parameter name: (form) Updated name of the pet (optional, default to Sample) + // - parameter status: (form) Updated status of the pet (optional, default to Sample) + // + // - POST /pet/{petId} + // - + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + If api.UpdatePetWithForm(error, 789, "name_example", "status_example") Then + Print("[+] PetApi.UpdatePetWithForm successful.") + Else + Print("[-] PetApi.UpdatePetWithForm unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation uploadFile + // uploads an image + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter petId: (path) ID of pet to update + // - parameter additionalMetadata: (form) Additional data to pass to server (optional, default to Sample) + // - parameter Escapedfile: (form) file to upload (optional, default to Sample) + // + // - POST /pet/{petId}/uploadImage + // - + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + Dim UploadFileData As XojoOpenAPIClientSynchronous.Models.ApiResponse + If api.UploadFile(error, UploadFileData, 789, "additionalMetadata_example", GetTemporaryFolderItem) Then + Print("[+] PetApi.UploadFile successful.") + Else + Print("[-] PetApi.UploadFile unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + End Sub + #tag EndMethod + #tag Method, Flags = &h0 + Sub testStoreApi(basePath As String) + Dim error As New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(0, "No Error") + Dim tmpDownloadFile As FolderItem = GetTemporaryFolderItem + + Dim api As New XojoOpenAPIClientSynchronous.APIs.StoreApi + api.BasePath = basePath + api.BasicAuthUser = "user" + api.BasicAuthPassword = "password" + api.UseHTTPS = false + + + // Operation deleteOrder + // Delete purchase order by ID + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter orderId: (path) ID of the order that needs to be deleted + // + // - DELETE /store/order/{orderId} + // - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + // + // + If api.DeleteOrder(error, "orderId_example") Then + Print("[+] StoreApi.DeleteOrder successful.") + Else + Print("[-] StoreApi.DeleteOrder unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation getInventory + // Returns pet inventories by status + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // + // - GET /store/inventory + // - Returns a map of status codes to quantities + // - defaultResponse: Nil + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + Dim GetInventoryData As Dictionary + If api.GetInventory(error, GetInventoryData) Then + Print("[+] StoreApi.GetInventory successful.") + Else + Print("[-] StoreApi.GetInventory unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation getOrderById + // Find purchase order by ID + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter orderId: (path) ID of pet that needs to be fetched + // + // - GET /store/order/{orderId} + // - For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + // - defaultResponse: Nil + // + // + Dim GetOrderByIdData As XojoOpenAPIClientSynchronous.Models.Order + If api.GetOrderById(error, GetOrderByIdData, 789) Then + Print("[+] StoreApi.GetOrderById successful.") + Else + Print("[-] StoreApi.GetOrderById unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation placeOrder + // Place an order for a pet + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter order: (body) order placed for purchasing the pet + // + // - POST /store/order + // - + // - defaultResponse: Nil + // + // + Dim PlaceOrderorderModel As New XojoOpenAPIClientSynchronous.Models.Order + + Dim PlaceOrderData As XojoOpenAPIClientSynchronous.Models.Order + If api.PlaceOrder(error, PlaceOrderData, PlaceOrderorderModel) Then + Print("[+] StoreApi.PlaceOrder successful.") + Else + Print("[-] StoreApi.PlaceOrder unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + End Sub + #tag EndMethod + #tag Method, Flags = &h0 + Sub testUserApi(basePath As String) + Dim error As New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(0, "No Error") + Dim tmpDownloadFile As FolderItem = GetTemporaryFolderItem + + Dim api As New XojoOpenAPIClientSynchronous.APIs.UserApi + api.BasePath = basePath + api.BasicAuthUser = "user" + api.BasicAuthPassword = "password" + api.UseHTTPS = false + + + // Operation createUser + // Create user + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter user: (body) Created user object + // + // - POST /user + // - This can only be done by the logged in user. + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + Dim CreateUseruserModel As New XojoOpenAPIClientSynchronous.Models.User + + If api.CreateUser(error, CreateUseruserModel) Then + Print("[+] UserApi.CreateUser successful.") + Else + Print("[-] UserApi.CreateUser unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation createUsersWithArrayInput + // Creates list of users with given input array + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter user: (body) List of user object + // + // - POST /user/createWithArray + // - + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + Dim CreateUsersWithArrayInputuserArray() As XojoOpenAPIClientSynchronous.Models.User + If api.CreateUsersWithArrayInput(error, CreateUsersWithArrayInputuserArray) Then + Print("[+] UserApi.CreateUsersWithArrayInput successful.") + Else + Print("[-] UserApi.CreateUsersWithArrayInput unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation createUsersWithListInput + // Creates list of users with given input array + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter user: (body) List of user object + // + // - POST /user/createWithList + // - + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + Dim CreateUsersWithListInputuserArray() As XojoOpenAPIClientSynchronous.Models.User + If api.CreateUsersWithListInput(error, CreateUsersWithListInputuserArray) Then + Print("[+] UserApi.CreateUsersWithListInput successful.") + Else + Print("[-] UserApi.CreateUsersWithListInput unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation deleteUser + // Delete user + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter username: (path) The name that needs to be deleted + // + // - DELETE /user/{username} + // - This can only be done by the logged in user. + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + If api.DeleteUser(error, "username_example") Then + Print("[+] UserApi.DeleteUser successful.") + Else + Print("[-] UserApi.DeleteUser unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation getUserByName + // Get user by user name + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + // + // - GET /user/{username} + // - + // - defaultResponse: Nil + // + // + Dim GetUserByNameData As XojoOpenAPIClientSynchronous.Models.User + If api.GetUserByName(error, GetUserByNameData, "username_example") Then + Print("[+] UserApi.GetUserByName successful.") + Else + Print("[-] UserApi.GetUserByName unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation loginUser + // Logs user into the system + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter username: (query) The user name for login + // - parameter password: (query) The password for login in clear text + // + // - GET /user/login + // - + // - defaultResponse: Sample + // + // + // - responseHeaders: [Set-Cookie(String), X-Rate-Limit(Integer), X-Expires-After(Date)] + Dim LoginUserData As String + If api.LoginUser(error, LoginUserData, "username_example", "password_example") Then + Print("[+] UserApi.LoginUser successful.") + Else + Print("[-] UserApi.LoginUser unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation logoutUser + // Logs out current logged in user session + // - parameter localOutStatus: Information on whether the operation succeeded. + // + // - GET /user/logout + // - + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + If api.LogoutUser(error) Then + Print("[+] UserApi.LogoutUser successful.") + Else + Print("[-] UserApi.LogoutUser unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + + // Operation updateUser + // Updated user + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter username: (path) name that need to be deleted + // - parameter user: (body) Updated user object + // + // - PUT /user/{username} + // - This can only be done by the logged in user. + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + Dim UpdateUseruserModel As New XojoOpenAPIClientSynchronous.Models.User + + If api.UpdateUser(error, "username_example", UpdateUseruserModel) Then + Print("[+] UserApi.UpdateUser successful.") + Else + Print("[-] UserApi.UpdateUser unsuccessful.") + Print(" " + " | ErrorNumber: " + Str(error.ErrorNumber) + " | HTTP Status: " + Str(error.HTTPCode) + " | SocketCode: " + Str(error.SocketCode) + " | Message: " + error.Message) + End If + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Function FromRFC3339(stringRepresentation As String) As Date + + Dim d As New Xoson.DateIntermediate(stringRepresentation) + + return New Date(d.year, d.month, d.day, d.hour, d.minute, d.second, 0.0) + End Function + #tag EndMethod + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="useHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/README.md b/samples/client/petstore/xojo/client-synchronous/README.md new file mode 100644 index 000000000000..bd6bac863c76 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/README.md @@ -0,0 +1,120 @@ +# Xojo API client for XojoOpenAPIClientSynchronous + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: +- Build package: org.openapitools.codegen.languages.XojoClientCodegen + +## Installation + +This project contains generated code suitable for both Desktop and Console applications on all operating systems. + +The code is generated for Xojo's API v1. + +The generated code is packaged into a single Module (`XojoOpenAPIClientSynchronous`), which we suggest copying to your project after opening the generated `XojoOpenAPIClientSynchronous.xojo_project` in [Xojo](https://xojo.com/). Working in the generated Xojo project is not recommended. + +> See also Xojo's [Sharing code among multiple projects](https://documentation.xojo.com/topics/code_management/sharing_code_among_multiple_projects.html). + +This project depends on [Xoson](https://github.com/Topheee/xoson) `v2.2.0` (and above). Download it to your computer: +```shell +git clone 'https://github.com/Topheee/xoson.git' +``` + +Open the `Xoson.xojo_project` from the cloned git repository with Xojo and copy the `Xoson` module to your project. Similarily, open the `XojoOpenAPIClientSynchronous.xojo_project` file with Xojo and copy `XojoOpenAPIClientSynchronous` to your project. + +> Since Xojo currently has no package manager, you need to manually copy both the `Xoson` and the `XojoOpenAPIClientSynchronous` modules to your Xojo project. + +Both modules must not be copied into another module, but must reside at the top level of your project. + +### Customization + +The generator can be configured with the following options. + +Option | Used | Description +--- | --- | --- +`projectName` | `XojoOpenAPIClientSynchronous` | The name of the generated project and module. +`nonPublicApi` | `false` | Generate `Protected` instead of `Public` methods, if set. +`library` | `httpsocket` | Internal Xojo standard library object to use. Currently only `httpsocket` (`HTTPSocket` class) is supported. +`serializationLibrary` | `{xoson` | Internal library to use for serialization. Currently only `xoson` ([Xoson](https://github.com/Topheee/xoson) library) is supported. +`supportsAsync` | `false` | If `true`, generated APIs will use callbacks instead of blocking the main thread. + +### Usage + +Communication with the OpenAPI server is done by instantiating one of the classes below `XojoOpenAPIClientSynchronous.APIs`, configuring it - by setting `BasePath`, `UseHTTPS`, and `Port` - and invoking the `Public ` methods. + +If the methods returns `True`, the API request was successful. Otherwise, the `localOutStatus` parameter contains information about the failure. Note that despite this `ByRef` parameter, the methods may still raise an exception! + +The method blocks until the response is received. + +> The property `AdditionalHeaders` allows sending further headers with each request. Set it to a new `Dictionary`, with the Keys being the header names and the values either being a single String or an array of Strings. + +__Error handling__, as well as status reporting, is done via class `XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException`. Note that an instance of this class does not always indicate an error - check `IsError` to find out. +- `ErrorNumber` is set to one of the `XojoOpenAPIClientSynchronous.kError` constants, or `0` in case of no error. +- `HTTPStatus` is set to the HTTP status code as returned by the server. If the error is unrelated to HTTP, this property is `-1`. +- `SocketCode` contains the socket error, if any; otherwise `0`. + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*XojoOpenAPIClientSynchronous.APIs.PetApi* | [**AddPet**](PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*XojoOpenAPIClientSynchronous.APIs.PetApi* | [**DeletePet**](PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*XojoOpenAPIClientSynchronous.APIs.PetApi* | [**FindPetsByStatus**](PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*XojoOpenAPIClientSynchronous.APIs.PetApi* | [**FindPetsByTags**](PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*XojoOpenAPIClientSynchronous.APIs.PetApi* | [**GetPetById**](PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*XojoOpenAPIClientSynchronous.APIs.PetApi* | [**UpdatePet**](PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*XojoOpenAPIClientSynchronous.APIs.PetApi* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*XojoOpenAPIClientSynchronous.APIs.PetApi* | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*XojoOpenAPIClientSynchronous.APIs.StoreApi* | [**DeleteOrder**](StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*XojoOpenAPIClientSynchronous.APIs.StoreApi* | [**GetInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*XojoOpenAPIClientSynchronous.APIs.StoreApi* | [**GetOrderById**](StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*XojoOpenAPIClientSynchronous.APIs.StoreApi* | [**PlaceOrder**](StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*XojoOpenAPIClientSynchronous.APIs.UserApi* | [**CreateUser**](UserApi.md#createuser) | **POST** /user | Create user +*XojoOpenAPIClientSynchronous.APIs.UserApi* | [**CreateUsersWithArrayInput**](UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*XojoOpenAPIClientSynchronous.APIs.UserApi* | [**CreateUsersWithListInput**](UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*XojoOpenAPIClientSynchronous.APIs.UserApi* | [**DeleteUser**](UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*XojoOpenAPIClientSynchronous.APIs.UserApi* | [**GetUserByName**](UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*XojoOpenAPIClientSynchronous.APIs.UserApi* | [**LoginUser**](UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*XojoOpenAPIClientSynchronous.APIs.UserApi* | [**LogoutUser**](UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*XojoOpenAPIClientSynchronous.APIs.UserApi* | [**UpdateUser**](UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [XojoOpenAPIClientSynchronous.Models.ApiResponse](ApiResponse.md) + - [XojoOpenAPIClientSynchronous.Models.Category](Category.md) + - [XojoOpenAPIClientSynchronous.Models.Order](Order.md) + - [XojoOpenAPIClientSynchronous.Models.Pet](Pet.md) + - [XojoOpenAPIClientSynchronous.Models.Tag](Tag.md) + - [XojoOpenAPIClientSynchronous.Models.User](User.md) + + +## Documentation For Authorization + + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +## Author + + + diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous.xojo_code new file mode 100644 index 000000000000..5131e62c9b1f --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous.xojo_code @@ -0,0 +1,198 @@ +#tag Module +Protected Module XojoOpenAPIClientSynchronous + #tag Method, Flags = &h21 + Private Function BoolFromString(s As String) As Boolean + If s = "true" Then + Return True + ElseIf s = "false" Then + Return False + ElseIf s = "0" Then + Return True + Else + Return False + End If + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function EncodingFromContentType(contentType As String) As TextEncoding + // Extract the encoding from the contentType header. + // Defaults to Encodings.UTF8. + + Dim contentEncoding As TextEncoding = nil + + Dim components() As String = contentType.SplitB(";") + For Each component As String In components + Dim directive() As String = component.SplitB("=") + If Ubound(directive) > 0 And directive(0).RightB(7) = "charset" Then + contentEncoding = GetInternetTextEncoding(directive(1)) + If contentEncoding <> Nil Then Return contentEncoding + End If + Next + + Return Encodings.UTF8 + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FromRFC3339(Extends stringRepresentation As String) As Date + + Dim d As New Xoson.DateIntermediate(stringRepresentation) + + Return New Date(d.year, d.month, d.day, d.hour, d.minute, d.second, 0.0) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FromRFC3339(Extends stringRepresentation As String) As Xojo.Core.Date + + Dim d As New Xoson.DateIntermediate(stringRepresentation) + + Return New Xojo.Core.Date(d.year, d.month, d.day, d.hour, d.minute, d.second, d.millisecond * 1000, new Xojo.Core.TimeZone("Etc/UTC")) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function LocalFuncSerializeFile(Extends file As FolderItem) As String + If file <> Nil Then + Try + Dim bs As BinaryStream = BinaryStream.Open(file, False) + // read the whole binaryStream + Return bs.Read(bs.Length) + + Catch e As IOException + Dim error As New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorFileWrite, e.Message) + error.ErrorNumber = e.ErrorNumber + Raise error + End Try + Else + Dim error As New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorInternal, "Nil parameter ") + Raise error + End If + + Return "" + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ToRFC3339(Extends d As Date) As String + Dim utcDate As New Date(d) + utcDate.GMTOffset = 0 + + Dim mb As New MemoryBlock(24) + mb.StringValue(0,4) = Format(utcDate.Year, "0000") + mb.Byte(4) = &h2D + mb.StringValue(5,2) = Format(utcDate.Month, "00") + mb.Byte(7) = &h2D + mb.StringValue(8,2) = Format(utcDate.Day, "00") + mb.Byte(10) = &h54 + mb.StringValue(11,2) = Format(utcDate.Hour, "00") + mb.Byte(13) = &h3A + mb.StringValue(14,2) = Format(utcDate.Minute, "00") + mb.Byte(16) = &h3A + mb.StringValue(17,2) = Format(utcDate.Second, "00") + mb.Byte(19) = &h2E + mb.StringValue(20,3) = "000" 'milliseconds are not available in Date + mb.Byte(23) = &h5A + Return DefineEncoding(mb.StringValue(0, 24), Encodings.UTF8) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ToRFC3339(Extends d As Xojo.Core.Date) As String + Dim utcDate As New Xojo.Core.Date(d.SecondsFrom1970, New Xojo.Core.TimeZone("Etc/UTC")) + + Dim mb As New MemoryBlock(24) + mb.StringValue(0,4) = Format(utcDate.Year, "0000") + mb.Byte(4) = &h2D + mb.StringValue(5,2) = Format(utcDate.Month, "00") + mb.Byte(7) = &h2D + mb.StringValue(8,2) = Format(utcDate.Day, "00") + mb.Byte(10) = &h54 + mb.StringValue(11,2) = Format(utcDate.Hour, "00") + mb.Byte(13) = &h3A + mb.StringValue(14,2) = Format(utcDate.Minute, "00") + mb.Byte(16) = &h3A + mb.StringValue(17,2) = Format(utcDate.Second, "00") + mb.Byte(19) = &h2E + mb.StringValue(20,3) = Format(utcDate.Nanosecond / 1000, "000") + mb.Byte(23) = &h5A + Return DefineEncoding(mb.StringValue(0, 24), Encodings.UTF8) + End Function + #tag EndMethod + + + #tag Constant, Name = kErrorInternal, Type = Double, Dynamic = False, Default = \"-10", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorFileWrite, Type = Double, Dynamic = False, Default = \"-8", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorCannotAuthenticate, Type = Double, Dynamic = False, Default = \"-7", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorUnsupportedFeature, Type = Double, Dynamic = False, Default = \"-6", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorSocketFail, Type = Double, Dynamic = False, Default = \"-5", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorHTTPFail, Type = Double, Dynamic = False, Default = \"-4", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorUnsupportedMediaType, Type = Double, Dynamic = False, Default = \"-3", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorXosonProblem, Type = Double, Dynamic = False, Default = \"-2", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorInvalidJSON, Type = Double, Dynamic = False, Default = \"-1", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kAPITimeoutSeconds, Type = Double, Dynamic = False, Default = \"5", Scope = Private + #tag EndConstant + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous.xojo_project b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous.xojo_project new file mode 100644 index 000000000000..35c291e953bc --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous.xojo_project @@ -0,0 +1,55 @@ +Type=Console +RBProjectVersion=2019.011 +MinIDEVersion=20070100 +Class=App;App.xojo_code;&h000000005B6127FF;&h0000000000000000;false +BuildSteps=Build Automation;Build Automation.xojo_code;&h000000005D9877FF;&h0000000000000000;false +Module=XojoOpenAPIClientSynchronous;XojoOpenAPIClientSynchronous.xojo_code;&h000000001FF397FF;&h0000000000000000;false +Class=XojoOpenAPIClientSynchronousException;XojoOpenAPIClientSynchronous/XojoOpenAPIClientSynchronousException.xojo_code;&h0000000054B007FF;&h000000001FF397FF;false +Module=Models;XojoOpenAPIClientSynchronous/Models.xojo_code;&h000000002FF397FF;&h000000001FF397FF;false +Class=ApiResponse;XojoOpenAPIClientSynchronous/Models/ApiResponse.xojo_code;&h0000000001871AFF;&h000000002FF397FF;false +Class=Category;XojoOpenAPIClientSynchronous/Models/Category.xojo_code;&h000000000186DAFF;&h000000002FF397FF;false +Class=Order;XojoOpenAPIClientSynchronous/Models/Order.xojo_code;&h000000000186CAFF;&h000000002FF397FF;false +Class=Pet;XojoOpenAPIClientSynchronous/Models/Pet.xojo_code;&h0000000001870AFF;&h000000002FF397FF;false +Class=Tag;XojoOpenAPIClientSynchronous/Models/Tag.xojo_code;&h000000000186FAFF;&h000000002FF397FF;false +Class=User;XojoOpenAPIClientSynchronous/Models/User.xojo_code;&h000000000186EAFF;&h000000002FF397FF;false +Module=APIs;XojoOpenAPIClientSynchronous/APIs.xojo_code;&h000000003FF397FF;&h000000001FF397FF;false +Class=PetApi;XojoOpenAPIClientSynchronous/APIs/PetApi.xojo_code;&h0000000001880AFF;&h000000003FF397FF;false +Class=StoreApi;XojoOpenAPIClientSynchronous/APIs/StoreApi.xojo_code;&h0000000001881AFF;&h000000003FF397FF;false +Class=UserApi;XojoOpenAPIClientSynchronous/APIs/UserApi.xojo_code;&h0000000001882AFF;&h000000003FF397FF;false +Class=Mock;Mock.xojo_code;&h000000002FF407FF;&h0000000000000000;false +MajorVersion=1 +MinorVersion=0 +SubVersion=0 +NonRelease=0 +Release=1 +InfoVersion=openapi-generator Generated Project +LongVersion=XojoOpenAPIClientSynchronous +ShortVersion=1.0 +WinCompanyName=OpenAPI-Generator Contributors +WinInternalName= +WinProductName= +WinFileDescription= +AutoIncrementVersionInformation=False +BuildFlags=&h4100 +BuildLanguage=&h0 +DebugLanguage=&h0 +Region= +WindowsName=XojoOpenAPIClientSynchronous.exe +MacCarbonMachName=XojoOpenAPIClientSynchronous +LinuxX86Name=XojoOpenAPIClientSynchronous +MacCreator= +MDI=0 +MDICaption= +DefaultEncoding=&h0 +AppIcon=XojoOpenAPIClientSynchronous.xojo_resources;&h0 +OSXBundleID=tech.openapi-generator.XojoOpenAPIClientSynchronous +DebuggerCommandLine= +UseGDIPlus=False +UseBuildsFolder=True +CopyRedistNextToWindowsEXE=False +IsWebProject=False +LinuxBuildArchitecture=1 +MacBuildArchitecture=1 +OptimizationLevel=0 +WindowsVersions={35138b9a-5d96-4fbd-8e2d-a2440225f93a}|{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}|{1f676c76-80e1-4239-95bb-83d0f6d0da78}|{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a} +WindowsRunAs=0 diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous.xojo_resources b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous.xojo_resources new file mode 100644 index 000000000000..a6d4df61c2d3 Binary files /dev/null and b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous.xojo_resources differ diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs.xojo_code new file mode 100644 index 000000000000..afdbb3abef16 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs.xojo_code @@ -0,0 +1,46 @@ +#tag Module +Protected Module APIs + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs/PetApi.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs/PetApi.xojo_code new file mode 100644 index 000000000000..09ab79866b09 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs/PetApi.xojo_code @@ -0,0 +1,1038 @@ +#tag Class +Protected Class PetApi + #tag Method, Flags = &h0 + Function AddPet(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, ByRef localOutData As XojoOpenAPIClientSynchronous.Models.Pet, pet As XojoOpenAPIClientSynchronous.Models.Pet) As Boolean + // Operation addPet + // Add a new pet to the store + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter pet: (body) Pet object that needs to be added to the store + // + // + // + // - POST /pet + // - + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(pet), "application/json") + + + + + + Dim localVarPath As String = "/pet" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return AddPetPrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function AddPetPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, ByRef outData As XojoOpenAPIClientSynchronous.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New XojoOpenAPIClientSynchronous.Models.Pet + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Function DeletePet(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, petId As Int64, Optional apiKey As Xoson.O.OptionalString) As Boolean + // Operation deletePet + // Deletes a pet + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter petId: (path) Pet id to delete + // - parameter apiKey: (header) (optional, default to Sample) + // + // + // + // - DELETE /pet/{petId} + // - + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + If apiKey <> nil Then localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(apiKey)) + + + + + + Dim localVarPath As String = "/pet/{petId}" + + Dim localVarPathStringpetId As String = petId.ToString + + localVarPath = localVarPath.ReplaceAllB("{petId}", localVarPathStringpetId) + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("DELETE", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + #Pragma Unused localVarContent + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", "") + + localVarHTTPSocket.Close + + Return True + End Function + #tag EndMethod + + + + + + #tag Method, Flags = &h0 + Function FindPetsByStatus(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, localOutData() As XojoOpenAPIClientSynchronous.Models.Pet, status() As StatusEnum_FindPetsByStatus) As Boolean + // Operation findPetsByStatus + // Finds Pets by status + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter status: (query) Status values that need to be considered for filter + // + // + // + // - GET /pet/findByStatus + // - Multiple status values can be provided with comma separated strings + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + Dim localVarQueryParams As String = "?" + + Dim localVarQueryStringsstatus() As String + For Each localVarItemstatus As StatusEnum_FindPetsByStatus in status + Dim encodedParameter As String = EncodeURLComponent(StatusEnum_FindPetsByStatusToString(localVarItemstatus)) + localVarQueryStringsstatus.Append(encodedParameter) + Next + + Dim localVarQueryStringstatus As String + Select Case "form" + Case "form" + localVarQueryStringstatus = "status=" + Join(localVarQueryStringsstatus, ",") + Case "spaceDelimited" + localVarQueryStringstatus = "status=" + Join(localVarQueryStringsstatus, " ") + Case "pipeDelimited" + localVarQueryStringstatus = "status=" + Join(localVarQueryStringsstatus, "|") + Case "deepObject" + Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorUnsupportedFeature, "deepObject query parameters are not supported") + End Select + If localVarQueryStringsstatus.Ubound() > -1 Then localVarQueryParams = localVarQueryParams + EncodeURLComponent("status") + "=" + EncodeURLComponent(localVarQueryStringstatus) + + + + + + Dim localVarPath As String = "/pet/findByStatus" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath + localVarQueryParams, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return FindPetsByStatusPrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FindPetsByStatusPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, outData() As XojoOpenAPIClientSynchronous.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + #tag Method, Flags = &h21 + Private Function StatusEnum_FindPetsByStatusToString(value As StatusEnum_FindPetsByStatus) As String + Select Case value + + Case StatusEnum_FindPetsByStatus.Available + Return "available" + Case StatusEnum_FindPetsByStatus.Pending + Return "pending" + Case StatusEnum_FindPetsByStatus.Sold + Return "sold" + + End Select + Return "" + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Function FindPetsByTags(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, localOutData() As XojoOpenAPIClientSynchronous.Models.Pet, tags() As String) As Boolean + // Operation findPetsByTags + // Finds Pets by tags + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter tags: (query) Tags to filter by + // + // + // + // - GET /pet/findByTags + // - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + Dim localVarQueryParams As String = "?" + + Dim localVarQueryStringstags() As String + For Each localVarItemtags As String in tags + Dim encodedParameter As String = EncodeURLComponent(localVarItemtags) + localVarQueryStringstags.Append(encodedParameter) + Next + + Dim localVarQueryStringtags As String + Select Case "form" + Case "form" + localVarQueryStringtags = "inner=" + Join(localVarQueryStringstags, ",") + Case "spaceDelimited" + localVarQueryStringtags = "inner=" + Join(localVarQueryStringstags, " ") + Case "pipeDelimited" + localVarQueryStringtags = "inner=" + Join(localVarQueryStringstags, "|") + Case "deepObject" + Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorUnsupportedFeature, "deepObject query parameters are not supported") + End Select + If localVarQueryStringstags.Ubound() > -1 Then localVarQueryParams = localVarQueryParams + EncodeURLComponent("inner") + "=" + EncodeURLComponent(localVarQueryStringtags) + + + + + + Dim localVarPath As String = "/pet/findByTags" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath + localVarQueryParams, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return FindPetsByTagsPrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FindPetsByTagsPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, outData() As XojoOpenAPIClientSynchronous.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Function GetPetById(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, ByRef localOutData As XojoOpenAPIClientSynchronous.Models.Pet, petId As Int64) As Boolean + // Operation getPetById + // Find pet by ID + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter petId: (path) ID of pet to return + // + // + // + // - GET /pet/{petId} + // - Returns a single pet + // - defaultResponse: Nil + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + If me.ApiKeyapi_key = "" Then Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `PetApi.ApiKeyapi_key` before invoking `PetApi.GetPetById()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/pet/{petId}" + + Dim localVarPathStringpetId As String = petId.ToString + + localVarPath = localVarPath.ReplaceAllB("{petId}", localVarPathStringpetId) + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return GetPetByIdPrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetPetByIdPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, ByRef outData As XojoOpenAPIClientSynchronous.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New XojoOpenAPIClientSynchronous.Models.Pet + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Function UpdatePet(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, ByRef localOutData As XojoOpenAPIClientSynchronous.Models.Pet, pet As XojoOpenAPIClientSynchronous.Models.Pet) As Boolean + // Operation updatePet + // Update an existing pet + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter pet: (body) Pet object that needs to be added to the store + // + // + // + // - PUT /pet + // - + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(pet), "application/json") + + + + + + Dim localVarPath As String = "/pet" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("PUT", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return UpdatePetPrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function UpdatePetPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, ByRef outData As XojoOpenAPIClientSynchronous.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New XojoOpenAPIClientSynchronous.Models.Pet + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Function UpdatePetWithForm(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, petId As Int64, Optional name As Xoson.O.OptionalString, Optional status As Xoson.O.OptionalString) As Boolean + // Operation updatePetWithForm + // Updates a pet in the store with form data + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter petId: (path) ID of pet that needs to be updated + // - parameter name: (form) Updated name of the pet (optional, default to Sample) + // - parameter status: (form) Updated status of the pet (optional, default to Sample) + // + // + // + // - POST /pet/{petId} + // - + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + Dim localVarFormParams As New Dictionary + If name <> nil Then localVarFormParams.Value("name") = name +If status <> nil Then localVarFormParams.Value("status") = status + If localVarFormParams.Count > 0 Then localVarHTTPSocket.SetFormData(localVarFormParams) + + + + + + + Dim localVarPath As String = "/pet/{petId}" + + Dim localVarPathStringpetId As String = petId.ToString + + localVarPath = localVarPath.ReplaceAllB("{petId}", localVarPathStringpetId) + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + #Pragma Unused localVarContent + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", "") + + localVarHTTPSocket.Close + + Return True + End Function + #tag EndMethod + + + + + + #tag Method, Flags = &h0 + Function UploadFile(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, ByRef localOutData As XojoOpenAPIClientSynchronous.Models.ApiResponse, petId As Int64, Optional additionalMetadata As Xoson.O.OptionalString, Optional Escapedfile As FolderItem) As Boolean + // Operation uploadFile + // uploads an image + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter petId: (path) ID of pet to update + // - parameter additionalMetadata: (form) Additional data to pass to server (optional, default to Sample) + // - parameter Escapedfile: (form) file to upload (optional, default to Sample) + // + // + // + // - POST /pet/{petId}/uploadImage + // - + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + Dim localVarFormParams As New Dictionary + If additionalMetadata <> nil Then localVarFormParams.Value("additionalMetadata") = additionalMetadata +If Escapedfile <> nil Then localVarFormParams.Value("file") = Escapedfile.LocalFuncSerializeFile + If localVarFormParams.Count > 0 Then localVarHTTPSocket.SetFormData(localVarFormParams) + + + + + + + Dim localVarPath As String = "/pet/{petId}/uploadImage" + + Dim localVarPathStringpetId As String = petId.ToString + + localVarPath = localVarPath.ReplaceAllB("{petId}", localVarPathStringpetId) + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return UploadFilePrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function UploadFilePrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, ByRef outData As XojoOpenAPIClientSynchronous.Models.ApiResponse) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New XojoOpenAPIClientSynchronous.Models.ApiResponse + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + + + #tag Method, Flags = &h21 + Private Function AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + #Pragma Unused Realm + #Pragma Unused Headers + Name = Me.BasicAuthUser + Password = Me.BasicAuthPassword + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub PrivateFuncPrepareSocket(socket As HTTPSecureSocket) + socket.Secure = Me.useHTTPS + socket.ConnectionType = SSLSocket.TLSv12 + socket.Port = Me.Port + socket.RequestHeaders.Delete("Accept") + socket.RequestHeaders.AppendHeader("Accept", "text/plain") + socket.RequestHeaders.AppendHeader("Accept", "application/json") + socket.RequestHeaders.AppendHeader("Content-Type", "application/json") + + If Me.AdditionalHeaders <> Nil Then + For Each HeaderName As Variant In Me.AdditionalHeaders.Keys + Dim headerValueS As Variant = additionalHeaders.Value(HeaderName) + If headerValueS.IsArray Then + If headerValueS.ArrayElementType = Variant.TypeString Then + Dim values() As String = headerValueS + For Each value As String In values + socket.RequestHeaders.AppendHeader(HeaderName, value) + Next + Else + Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorInternal, "AdditionalHeaders only support Strings and String arrays as values.") + End If + Else + socket.RequestHeaders.AppendHeader(HeaderName, headerValueS.StringValue) + End If + Next + End If + End Sub + #tag EndMethod + + + + #tag Property, Flags = &h0 + AdditionalHeaders As Dictionary + #tag EndProperty + + #tag Property, Flags = &h0 + ApiKeyapi_key As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasePath As String = "http://petstore.swagger.io/v2" + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthPassword As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthUser As String + #tag EndProperty + + #tag Property, Flags = &h0 + Host As String = "" + #tag EndProperty + + #tag Property, Flags = &h0 + Port As Integer + #tag EndProperty + + #tag Property, Flags = &h0 + UseHTTPS As Boolean = true + #tag EndProperty + + #tag Enum, Name = StatusEnum_FindPetsByStatus, Type = Integer, Flags = &h0 + + Available + Pending + Sold + + #tag EndEnum + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthUser" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthPassword" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="UseHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs/StoreApi.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs/StoreApi.xojo_code new file mode 100644 index 000000000000..5b2f029bfba1 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs/StoreApi.xojo_code @@ -0,0 +1,556 @@ +#tag Class +Protected Class StoreApi + #tag Method, Flags = &h0 + Function DeleteOrder(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, orderId As String) As Boolean + // Operation deleteOrder + // Delete purchase order by ID + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter orderId: (path) ID of the order that needs to be deleted + // + // + // + // - DELETE /store/order/{orderId} + // - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + // + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + + + + Dim localVarPath As String = "/store/order/{orderId}" + + Dim localVarPathStringorderId As String = orderId + + localVarPath = localVarPath.ReplaceAllB("{orderId}", localVarPathStringorderId) + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("DELETE", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + #Pragma Unused localVarContent + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", "") + + localVarHTTPSocket.Close + + Return True + End Function + #tag EndMethod + + + + + + #tag Method, Flags = &h0 + Function GetInventory(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, ByRef localOutData As Dictionary) As Boolean + // Operation getInventory + // Returns pet inventories by status + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // + // + // + // - GET /store/inventory + // - Returns a map of status codes to quantities + // - defaultResponse: Nil + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + If me.ApiKeyapi_key = "" Then Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `StoreApi.ApiKeyapi_key` before invoking `StoreApi.GetInventory()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/store/inventory" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return GetInventoryPrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetInventoryPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, ByRef outData As Dictionary) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New Dictionary + Try + outData = ParseJSON(Content) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Function GetOrderById(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, ByRef localOutData As XojoOpenAPIClientSynchronous.Models.Order, orderId As Int64) As Boolean + // Operation getOrderById + // Find purchase order by ID + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter orderId: (path) ID of pet that needs to be fetched + // + // + // + // - GET /store/order/{orderId} + // - For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + // - defaultResponse: Nil + // + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + + + + Dim localVarPath As String = "/store/order/{orderId}" + + Dim localVarPathStringorderId As String = orderId.ToString + + localVarPath = localVarPath.ReplaceAllB("{orderId}", localVarPathStringorderId) + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return GetOrderByIdPrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetOrderByIdPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, ByRef outData As XojoOpenAPIClientSynchronous.Models.Order) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New XojoOpenAPIClientSynchronous.Models.Order + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Function PlaceOrder(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, ByRef localOutData As XojoOpenAPIClientSynchronous.Models.Order, order As XojoOpenAPIClientSynchronous.Models.Order) As Boolean + // Operation placeOrder + // Place an order for a pet + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter order: (body) order placed for purchasing the pet + // + // + // + // - POST /store/order + // - + // - defaultResponse: Nil + // + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(order), "application/json") + + + + + Dim localVarPath As String = "/store/order" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return PlaceOrderPrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function PlaceOrderPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, ByRef outData As XojoOpenAPIClientSynchronous.Models.Order) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New XojoOpenAPIClientSynchronous.Models.Order + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + + + #tag Method, Flags = &h21 + Private Function AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + #Pragma Unused Realm + #Pragma Unused Headers + Name = Me.BasicAuthUser + Password = Me.BasicAuthPassword + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub PrivateFuncPrepareSocket(socket As HTTPSecureSocket) + socket.Secure = Me.useHTTPS + socket.ConnectionType = SSLSocket.TLSv12 + socket.Port = Me.Port + socket.RequestHeaders.Delete("Accept") + socket.RequestHeaders.AppendHeader("Accept", "text/plain") + socket.RequestHeaders.AppendHeader("Accept", "application/json") + socket.RequestHeaders.AppendHeader("Content-Type", "application/json") + + If Me.AdditionalHeaders <> Nil Then + For Each HeaderName As Variant In Me.AdditionalHeaders.Keys + Dim headerValueS As Variant = additionalHeaders.Value(HeaderName) + If headerValueS.IsArray Then + If headerValueS.ArrayElementType = Variant.TypeString Then + Dim values() As String = headerValueS + For Each value As String In values + socket.RequestHeaders.AppendHeader(HeaderName, value) + Next + Else + Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorInternal, "AdditionalHeaders only support Strings and String arrays as values.") + End If + Else + socket.RequestHeaders.AppendHeader(HeaderName, headerValueS.StringValue) + End If + Next + End If + End Sub + #tag EndMethod + + + + #tag Property, Flags = &h0 + AdditionalHeaders As Dictionary + #tag EndProperty + + #tag Property, Flags = &h0 + ApiKeyapi_key As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasePath As String = "http://petstore.swagger.io/v2" + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthPassword As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthUser As String + #tag EndProperty + + #tag Property, Flags = &h0 + Host As String = "" + #tag EndProperty + + #tag Property, Flags = &h0 + Port As Integer + #tag EndProperty + + #tag Property, Flags = &h0 + UseHTTPS As Boolean = true + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthUser" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthPassword" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="UseHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs/UserApi.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs/UserApi.xojo_code new file mode 100644 index 000000000000..53ec6104814d --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/APIs/UserApi.xojo_code @@ -0,0 +1,719 @@ +#tag Class +Protected Class UserApi + #tag Method, Flags = &h0 + Function CreateUser(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, user As XojoOpenAPIClientSynchronous.Models.User) As Boolean + // Operation createUser + // Create user + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter user: (body) Created user object + // + // + // + // - POST /user + // - This can only be done by the logged in user. + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(user), "application/json") + + If me.ApiKeyapi_key = "" Then Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.CreateUser()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + #Pragma Unused localVarContent + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", "") + + localVarHTTPSocket.Close + + Return True + End Function + #tag EndMethod + + + + + + #tag Method, Flags = &h0 + Function CreateUsersWithArrayInput(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, user() As XojoOpenAPIClientSynchronous.Models.User) As Boolean + // Operation createUsersWithArrayInput + // Creates list of users with given input array + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter user: (body) List of user object + // + // + // + // - POST /user/createWithArray + // - + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(user), "application/json") + + If me.ApiKeyapi_key = "" Then Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.CreateUsersWithArrayInput()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/createWithArray" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + #Pragma Unused localVarContent + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", "") + + localVarHTTPSocket.Close + + Return True + End Function + #tag EndMethod + + + + + + #tag Method, Flags = &h0 + Function CreateUsersWithListInput(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, user() As XojoOpenAPIClientSynchronous.Models.User) As Boolean + // Operation createUsersWithListInput + // Creates list of users with given input array + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter user: (body) List of user object + // + // + // + // - POST /user/createWithList + // - + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(user), "application/json") + + If me.ApiKeyapi_key = "" Then Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.CreateUsersWithListInput()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/createWithList" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + #Pragma Unused localVarContent + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", "") + + localVarHTTPSocket.Close + + Return True + End Function + #tag EndMethod + + + + + + #tag Method, Flags = &h0 + Function DeleteUser(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, username As String) As Boolean + // Operation deleteUser + // Delete user + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter username: (path) The name that needs to be deleted + // + // + // + // - DELETE /user/{username} + // - This can only be done by the logged in user. + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + If me.ApiKeyapi_key = "" Then Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.DeleteUser()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/{username}" + + Dim localVarPathStringusername As String = username + + localVarPath = localVarPath.ReplaceAllB("{username}", localVarPathStringusername) + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("DELETE", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + #Pragma Unused localVarContent + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", "") + + localVarHTTPSocket.Close + + Return True + End Function + #tag EndMethod + + + + + + #tag Method, Flags = &h0 + Function GetUserByName(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, ByRef localOutData As XojoOpenAPIClientSynchronous.Models.User, username As String) As Boolean + // Operation getUserByName + // Get user by user name + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + // + // + // + // - GET /user/{username} + // - + // - defaultResponse: Nil + // + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + + + + Dim localVarPath As String = "/user/{username}" + + Dim localVarPathStringusername As String = username + + localVarPath = localVarPath.ReplaceAllB("{username}", localVarPathStringusername) + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return GetUserByNamePrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetUserByNamePrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, ByRef outData As XojoOpenAPIClientSynchronous.Models.User) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New XojoOpenAPIClientSynchronous.Models.User + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Function LoginUser(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, ByRef localOutData As String, username As String, password As String) As Boolean + // Operation loginUser + // Logs user into the system + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter localOutData: On success, contains the data returned by the API. + // - parameter username: (query) The user name for login + // - parameter password: (query) The password for login in clear text + // + // + // + // - GET /user/login + // - + // - defaultResponse: Sample + // + // + // - responseHeaders: [Set-Cookie(String), X-Rate-Limit(Integer), X-Expires-After(Date)] + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + Dim localVarQueryParams As String = "?" + localVarQueryParams = localVarQueryParams + EncodeURLComponent("username") + "=" + EncodeURLComponent(username) + + localVarQueryParams = localVarQueryParams + "&" + EncodeURLComponent("password") + "=" + EncodeURLComponent(password) + + + + + + Dim localVarPath As String = "/user/login" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath + localVarQueryParams, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + Dim localVarHeaders As InternetHeaders = localVarHTTPSocket.PageHeaders + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", localVarContent) + + localVarHTTPSocket.Close + + Return LoginUserPrivateFuncDeserializeResponse(localVarHTTPStatus, localVarHeaders, localOutStatus, localVarContent, localOutData) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function LoginUserPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, Content As String, ByRef outData As String) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = XojoOpenAPIClientSynchronous.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + outData = Content + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Function LogoutUser(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException) As Boolean + // Operation logoutUser + // Logs out current logged in user session + // - parameter localOutStatus: Information on whether the operation succeeded. + // + // + // + // - GET /user/logout + // - + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + If me.ApiKeyapi_key = "" Then Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.LogoutUser()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/logout" + + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + #Pragma Unused localVarContent + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", "") + + localVarHTTPSocket.Close + + Return True + End Function + #tag EndMethod + + + + + + #tag Method, Flags = &h0 + Function UpdateUser(ByRef localOutStatus As XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException, username As String, user As XojoOpenAPIClientSynchronous.Models.User) As Boolean + // Operation updateUser + // Updated user + // - parameter localOutStatus: Information on whether the operation succeeded. + // - parameter username: (path) name that need to be deleted + // - parameter user: (body) Updated user object + // + // + // + // - PUT /user/{username} + // - This can only be done by the logged in user. + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(user), "application/json") + + If me.ApiKeyapi_key = "" Then Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.UpdateUser()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/{username}" + + Dim localVarPathStringusername As String = username + + localVarPath = localVarPath.ReplaceAllB("{username}", localVarPathStringusername) + + + localVarHTTPSocket.Yield = True 'recommended in synchronous mode + Dim localVarContent As String = localVarHTTPSocket.SendRequest("PUT", Me.BasePath + localVarPath, XojoOpenAPIClientSynchronous.kAPITimeoutSeconds) + #Pragma Unused localVarContent + + Dim localVarSocketError As Integer = localVarHTTPSocket.ErrorCode + If localVarSocketError <> 0 Then + localVarHTTPSocket.Close + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarSocketError) + Return False + End If + + Dim localVarHttpStatus As Integer = localVarHTTPSocket.HTTPStatusCode + + localOutStatus = New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(localVarHttpStatus, "", "") + + localVarHTTPSocket.Close + + Return True + End Function + #tag EndMethod + + + + + + + + #tag Method, Flags = &h21 + Private Function AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + #Pragma Unused Realm + #Pragma Unused Headers + Name = Me.BasicAuthUser + Password = Me.BasicAuthPassword + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub PrivateFuncPrepareSocket(socket As HTTPSecureSocket) + socket.Secure = Me.useHTTPS + socket.ConnectionType = SSLSocket.TLSv12 + socket.Port = Me.Port + socket.RequestHeaders.Delete("Accept") + socket.RequestHeaders.AppendHeader("Accept", "text/plain") + socket.RequestHeaders.AppendHeader("Accept", "application/json") + socket.RequestHeaders.AppendHeader("Content-Type", "application/json") + + If Me.AdditionalHeaders <> Nil Then + For Each HeaderName As Variant In Me.AdditionalHeaders.Keys + Dim headerValueS As Variant = additionalHeaders.Value(HeaderName) + If headerValueS.IsArray Then + If headerValueS.ArrayElementType = Variant.TypeString Then + Dim values() As String = headerValueS + For Each value As String In values + socket.RequestHeaders.AppendHeader(HeaderName, value) + Next + Else + Raise New XojoOpenAPIClientSynchronous.XojoOpenAPIClientSynchronousException(kErrorInternal, "AdditionalHeaders only support Strings and String arrays as values.") + End If + Else + socket.RequestHeaders.AppendHeader(HeaderName, headerValueS.StringValue) + End If + Next + End If + End Sub + #tag EndMethod + + + + #tag Property, Flags = &h0 + AdditionalHeaders As Dictionary + #tag EndProperty + + #tag Property, Flags = &h0 + ApiKeyapi_key As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasePath As String = "http://petstore.swagger.io/v2" + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthPassword As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthUser As String + #tag EndProperty + + #tag Property, Flags = &h0 + Host As String = "" + #tag EndProperty + + #tag Property, Flags = &h0 + Port As Integer + #tag EndProperty + + #tag Property, Flags = &h0 + UseHTTPS As Boolean = true + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthUser" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthPassword" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="UseHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models.xojo_code new file mode 100644 index 000000000000..5b5dda1f1f7a --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models.xojo_code @@ -0,0 +1,49 @@ +#tag Module +Protected Module Models + + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/ApiResponse.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/ApiResponse.xojo_code new file mode 100644 index 000000000000..38e0bef08187 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/ApiResponse.xojo_code @@ -0,0 +1,83 @@ +#tag Class +Protected Class ApiResponse + + #tag Property, Flags = &h0 + code As Xoson.O.OptionalInteger + #tag EndProperty + + + #tag Property, Flags = &h0 + type As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + message As Xoson.O.OptionalString + #tag EndProperty + + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="code" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="type" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="message" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/ApiResponseOptional.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/ApiResponseOptional.xojo_code new file mode 100644 index 000000000000..ed36753ed207 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/ApiResponseOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class ApiResponseOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As XojoOpenAPIClientSynchronous.Models.ApiResponse + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As XojoOpenAPIClientSynchronous.Models.ApiResponse) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As XojoOpenAPIClientSynchronous.Models.ApiResponse) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return XojoOpenAPIClientSynchronous.Models.ApiResponseToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As XojoOpenAPIClientSynchronous.Models.ApiResponse + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Category.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Category.xojo_code new file mode 100644 index 000000000000..45d782fba259 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Category.xojo_code @@ -0,0 +1,70 @@ +#tag Class +Protected Class Category + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + name As Xoson.O.OptionalString + #tag EndProperty + + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="name" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/CategoryOptional.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/CategoryOptional.xojo_code new file mode 100644 index 000000000000..d78c9b2776ca --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/CategoryOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class CategoryOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As XojoOpenAPIClientSynchronous.Models.Category + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As XojoOpenAPIClientSynchronous.Models.Category) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As XojoOpenAPIClientSynchronous.Models.Category) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return XojoOpenAPIClientSynchronous.Models.CategoryToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As XojoOpenAPIClientSynchronous.Models.Category + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Order.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Order.xojo_code new file mode 100644 index 000000000000..a26fb8a9aef3 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Order.xojo_code @@ -0,0 +1,140 @@ +#tag Class +Protected Class Order + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + petId As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + quantity As Xoson.O.OptionalInteger + #tag EndProperty + + + #tag Property, Flags = &h0 + shipDate As Date + #tag EndProperty + + + #tag Property, Flags = &h0 + #tag Note + Order Status + #tag EndNote + status As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + complete As Xoson.O.OptionalBoolean + #tag EndProperty + + + #tag Enum, Name = StatusEnum, Type = Integer, Flags = &h0 + + Placed + Approved + Delivered + + #tag EndEnum + + + #tag Method, Flags = &h0 + Shared Function StatusEnumToString(value As StatusEnum) As String + Select Case value + + Case StatusEnum.Placed + Return "placed" + Case StatusEnum.Approved + Return "approved" + Case StatusEnum.Delivered + Return "delivered" + + End Select + Return "" + End Function + #tag EndMethod + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="petId" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="quantity" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="shipDate" + Visible=false + Group="Behavior" + InitialValue="" + Type="Date" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="complete" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/OrderOptional.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/OrderOptional.xojo_code new file mode 100644 index 000000000000..e5c2a9eed60a --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/OrderOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class OrderOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As XojoOpenAPIClientSynchronous.Models.Order + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As XojoOpenAPIClientSynchronous.Models.Order) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As XojoOpenAPIClientSynchronous.Models.Order) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return XojoOpenAPIClientSynchronous.Models.OrderToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As XojoOpenAPIClientSynchronous.Models.Order + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Pet.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Pet.xojo_code new file mode 100644 index 000000000000..cdc79f9ec094 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Pet.xojo_code @@ -0,0 +1,140 @@ +#tag Class +Protected Class Pet + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + category As XojoOpenAPIClientSynchronous.Models.Category + #tag EndProperty + + + #tag Property, Flags = &h0 + name As String + #tag EndProperty + + + #tag Property, Flags = &h0 + photoUrls() As String + #tag EndProperty + + + #tag Property, Flags = &h0 + tags() As XojoOpenAPIClientSynchronous.Models.Tag + #tag EndProperty + + + #tag Property, Flags = &h0 + #tag Note + pet status in the store + #tag EndNote + Attributes( Deprecated ) status As Xoson.O.OptionalString + #tag EndProperty + + + #tag Enum, Name = StatusEnum, Type = Integer, Flags = &h0 + + Available + Pending + Sold + + #tag EndEnum + + + #tag Method, Flags = &h0 + Shared Function StatusEnumToString(value As StatusEnum) As String + Select Case value + + Case StatusEnum.Available + Return "available" + Case StatusEnum.Pending + Return "pending" + Case StatusEnum.Sold + Return "sold" + + End Select + Return "" + End Function + #tag EndMethod + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="category" + Visible=false + Group="Behavior" + InitialValue="" + Type="Category" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="name" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="photoUrls" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="tags" + Visible=false + Group="Behavior" + InitialValue="" + Type="Tag" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/PetOptional.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/PetOptional.xojo_code new file mode 100644 index 000000000000..88485d981662 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/PetOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class PetOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As XojoOpenAPIClientSynchronous.Models.Pet + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As XojoOpenAPIClientSynchronous.Models.Pet) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As XojoOpenAPIClientSynchronous.Models.Pet) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return XojoOpenAPIClientSynchronous.Models.PetToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As XojoOpenAPIClientSynchronous.Models.Pet + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Tag.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Tag.xojo_code new file mode 100644 index 000000000000..2cb9a08524aa --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/Tag.xojo_code @@ -0,0 +1,70 @@ +#tag Class +Protected Class Tag + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + name As Xoson.O.OptionalString + #tag EndProperty + + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="name" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/TagOptional.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/TagOptional.xojo_code new file mode 100644 index 000000000000..761147099780 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/TagOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class TagOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As XojoOpenAPIClientSynchronous.Models.Tag + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As XojoOpenAPIClientSynchronous.Models.Tag) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As XojoOpenAPIClientSynchronous.Models.Tag) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return XojoOpenAPIClientSynchronous.Models.TagToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As XojoOpenAPIClientSynchronous.Models.Tag + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/User.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/User.xojo_code new file mode 100644 index 000000000000..776ce15170f2 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/User.xojo_code @@ -0,0 +1,151 @@ +#tag Class +Protected Class User + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + username As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + firstName As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + lastName As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + email As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + password As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + phone As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + #tag Note + User Status + #tag EndNote + userStatus As Xoson.O.OptionalInteger + #tag EndProperty + + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="username" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="firstName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="lastName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="email" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="password" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="phone" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="userStatus" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/UserOptional.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/UserOptional.xojo_code new file mode 100644 index 000000000000..f30afe7e0fdb --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/Models/UserOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class UserOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As XojoOpenAPIClientSynchronous.Models.User + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As XojoOpenAPIClientSynchronous.Models.User) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As XojoOpenAPIClientSynchronous.Models.User) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return XojoOpenAPIClientSynchronous.Models.UserToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As XojoOpenAPIClientSynchronous.Models.User + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/XojoOpenAPIClientSynchronousException.xojo_code b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/XojoOpenAPIClientSynchronousException.xojo_code new file mode 100644 index 000000000000..942e9f4649e8 --- /dev/null +++ b/samples/client/petstore/xojo/client-synchronous/XojoOpenAPIClientSynchronous/XojoOpenAPIClientSynchronousException.xojo_code @@ -0,0 +1,185 @@ +#tag Class +Protected Class XojoOpenAPIClientSynchronousException +Inherits RuntimeException + #tag Method, Flags = &h0 + Sub Constructor(errorNumber As Integer, message As String) + // Construct an error related to the library. + 'Super.Constructor + Me.Message = message + Me.ErrorNumber = errorNumber + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor(HTTPCode As Integer, message As String, content As String) + // Construct an error related to an HTTP response. + 'Super.Constructor + + Me.HTTPCode = HTTPCode + If message = "" Then + Me.Message = "HTTP Status " + Str(HTTPCode) + Else + Me.Message = message + End If + + If HTTPCode < 200 Or HTTPCode > 299 Then + Me.ErrorNumber = kErrorHTTPFail + Me.OriginalResponseBody = content + End If + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor(socketCode As Integer) + // Construct an error related to a socket. + 'Super.Constructor + Me.SocketCode = socketCode + Me.Message = MessageForSocketErrorCode(socketCode) + + If socketCode <> 0 Then Me.ErrorNumber = kErrorSocketFail + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub Constructor() + // Disallow construction of empty results. + 'Super.Constructor + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function MessageForSocketErrorCode(code As Integer) As String + If code = 0 Then + Return "No error occurred." + ElseIf code = 100 Then + Return "There was an error opening and initializing the drivers." + ElseIf code = 101 Then + Return "This error code is no longer used." + ElseIf code = 102 Then + Return "This code means that you lost your connection." + ElseIf code = 103 Then + Return "The socket was unable to resolve the address that was specified." + ElseIf code = 104 Then + Return "This error code is no longer used." + ElseIf code = 105 Then + Return "The address is currently in use." + ElseIf code = 106 Then + Return "This is an invalid state error, which means that the socket is not in the proper state to be doing a certain operation." + ElseIf code = 107 Then + Return "This error means that the port you specified is invalid." + ElseIf code = 108 Then + Return "This error indicates that your application has run out of memory." + End If + + Return "An unknown socket error " + Str(code) + " occurred." + End Function + #tag EndMethod + + + #tag ComputedProperty, Flags = &h0 + #tag Getter + Get + Return "XojoOpenAPIClientSynchronousException | ErrorNumber: " + Str(Me.ErrorNumber) + " | HTTP Status: " + Str(Me.HTTPCode) + " | SocketCode: " + Str(Me.SocketCode) + " | Message: " + Me.Message + End Get + #tag EndGetter + Description As String + #tag EndComputedProperty + + #tag Property, Flags = &h0 + HTTPCode As Integer = -1 + #tag EndProperty + + #tag ComputedProperty, Flags = &h0 + #tag Getter + Get + Return ErrorNumber <> 0 + End Get + #tag EndGetter + IsError As Boolean + #tag EndComputedProperty + + #tag Property, Flags = &h0 + OriginalResponseBody As String + #tag EndProperty + + #tag Property, Flags = &h0 + SocketCode As Integer = 0 + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="HTTPCode" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Message" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="SocketCode" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="IsError" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/.openapi-generator-ignore b/samples/client/petstore/xojo/client/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/xojo/client/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# 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 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 (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/xojo/client/.openapi-generator/FILES b/samples/client/petstore/xojo/client/.openapi-generator/FILES new file mode 100644 index 000000000000..22991f8f6773 --- /dev/null +++ b/samples/client/petstore/xojo/client/.openapi-generator/FILES @@ -0,0 +1,28 @@ +App.xojo_code +Build Automation.xojo_code +Mock.xojo_code +OpenAPIClient.xojo_code +OpenAPIClient.xojo_project +OpenAPIClient.xojo_resources +OpenAPIClient/APIs.xojo_code +OpenAPIClient/APIs/PetApi.xojo_code +OpenAPIClient/APIs/PetApiCallbackHandler.xojo_code +OpenAPIClient/APIs/StoreApi.xojo_code +OpenAPIClient/APIs/StoreApiCallbackHandler.xojo_code +OpenAPIClient/APIs/UserApi.xojo_code +OpenAPIClient/APIs/UserApiCallbackHandler.xojo_code +OpenAPIClient/Models.xojo_code +OpenAPIClient/Models/ApiResponse.xojo_code +OpenAPIClient/Models/ApiResponseOptional.xojo_code +OpenAPIClient/Models/Category.xojo_code +OpenAPIClient/Models/CategoryOptional.xojo_code +OpenAPIClient/Models/Order.xojo_code +OpenAPIClient/Models/OrderOptional.xojo_code +OpenAPIClient/Models/Pet.xojo_code +OpenAPIClient/Models/PetOptional.xojo_code +OpenAPIClient/Models/Tag.xojo_code +OpenAPIClient/Models/TagOptional.xojo_code +OpenAPIClient/Models/User.xojo_code +OpenAPIClient/Models/UserOptional.xojo_code +OpenAPIClient/OpenAPIClientException.xojo_code +README.md diff --git a/samples/client/petstore/xojo/client/.openapi-generator/VERSION b/samples/client/petstore/xojo/client/.openapi-generator/VERSION new file mode 100644 index 000000000000..ba8a874deab9 --- /dev/null +++ b/samples/client/petstore/xojo/client/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/xojo/client/App.xojo_code b/samples/client/petstore/xojo/client/App.xojo_code new file mode 100644 index 000000000000..ca73c8b6d455 --- /dev/null +++ b/samples/client/petstore/xojo/client/App.xojo_code @@ -0,0 +1,15 @@ +#tag Class +Protected Class App +Inherits ConsoleApplication + #tag Event + Function Run(args() as String) As Integer + #Pragma Unused args + + End Function + #tag EndEvent + + + #tag ViewBehavior + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/Build Automation.xojo_code b/samples/client/petstore/xojo/client/Build Automation.xojo_code new file mode 100644 index 000000000000..f9b6aeee7312 --- /dev/null +++ b/samples/client/petstore/xojo/client/Build Automation.xojo_code @@ -0,0 +1,14 @@ +#tag BuildAutomation + Begin BuildStepList Linux + Begin BuildProjectStep Build + End + End + Begin BuildStepList Mac OS X + Begin BuildProjectStep Build + End + End + Begin BuildStepList Windows + Begin BuildProjectStep Build + End + End +#tag EndBuildAutomation diff --git a/samples/client/petstore/xojo/client/Mock.xojo_code b/samples/client/petstore/xojo/client/Mock.xojo_code new file mode 100644 index 000000000000..37eb149b5c42 --- /dev/null +++ b/samples/client/petstore/xojo/client/Mock.xojo_code @@ -0,0 +1,90 @@ +#tag Class +Public Class Mock + + + #tag Method, Flags = &h21 + Private Function FromRFC3339(stringRepresentation As String) As Date + + Dim d As New Xoson.DateIntermediate(stringRepresentation) + + return New Date(d.year, d.month, d.day, d.hour, d.minute, d.second, 0.0) + End Function + #tag EndMethod + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="useHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient.xojo_code new file mode 100644 index 000000000000..2b0b2cd49cb7 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient.xojo_code @@ -0,0 +1,198 @@ +#tag Module +Protected Module OpenAPIClient + #tag Method, Flags = &h21 + Private Function BoolFromString(s As String) As Boolean + If s = "true" Then + Return True + ElseIf s = "false" Then + Return False + ElseIf s = "0" Then + Return True + Else + Return False + End If + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function EncodingFromContentType(contentType As String) As TextEncoding + // Extract the encoding from the contentType header. + // Defaults to Encodings.UTF8. + + Dim contentEncoding As TextEncoding = nil + + Dim components() As String = contentType.SplitB(";") + For Each component As String In components + Dim directive() As String = component.SplitB("=") + If Ubound(directive) > 0 And directive(0).RightB(7) = "charset" Then + contentEncoding = GetInternetTextEncoding(directive(1)) + If contentEncoding <> Nil Then Return contentEncoding + End If + Next + + Return Encodings.UTF8 + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FromRFC3339(Extends stringRepresentation As String) As Date + + Dim d As New Xoson.DateIntermediate(stringRepresentation) + + Return New Date(d.year, d.month, d.day, d.hour, d.minute, d.second, 0.0) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FromRFC3339(Extends stringRepresentation As String) As Xojo.Core.Date + + Dim d As New Xoson.DateIntermediate(stringRepresentation) + + Return New Xojo.Core.Date(d.year, d.month, d.day, d.hour, d.minute, d.second, d.millisecond * 1000, new Xojo.Core.TimeZone("Etc/UTC")) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function LocalFuncSerializeFile(Extends file As FolderItem) As String + If file <> Nil Then + Try + Dim bs As BinaryStream = BinaryStream.Open(file, False) + // read the whole binaryStream + Return bs.Read(bs.Length) + + Catch e As IOException + Dim error As New OpenAPIClient.OpenAPIClientException(kErrorFileWrite, e.Message) + error.ErrorNumber = e.ErrorNumber + Raise error + End Try + Else + Dim error As New OpenAPIClient.OpenAPIClientException(kErrorInternal, "Nil parameter ") + Raise error + End If + + Return "" + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ToRFC3339(Extends d As Date) As String + Dim utcDate As New Date(d) + utcDate.GMTOffset = 0 + + Dim mb As New MemoryBlock(24) + mb.StringValue(0,4) = Format(utcDate.Year, "0000") + mb.Byte(4) = &h2D + mb.StringValue(5,2) = Format(utcDate.Month, "00") + mb.Byte(7) = &h2D + mb.StringValue(8,2) = Format(utcDate.Day, "00") + mb.Byte(10) = &h54 + mb.StringValue(11,2) = Format(utcDate.Hour, "00") + mb.Byte(13) = &h3A + mb.StringValue(14,2) = Format(utcDate.Minute, "00") + mb.Byte(16) = &h3A + mb.StringValue(17,2) = Format(utcDate.Second, "00") + mb.Byte(19) = &h2E + mb.StringValue(20,3) = "000" 'milliseconds are not available in Date + mb.Byte(23) = &h5A + Return DefineEncoding(mb.StringValue(0, 24), Encodings.UTF8) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ToRFC3339(Extends d As Xojo.Core.Date) As String + Dim utcDate As New Xojo.Core.Date(d.SecondsFrom1970, New Xojo.Core.TimeZone("Etc/UTC")) + + Dim mb As New MemoryBlock(24) + mb.StringValue(0,4) = Format(utcDate.Year, "0000") + mb.Byte(4) = &h2D + mb.StringValue(5,2) = Format(utcDate.Month, "00") + mb.Byte(7) = &h2D + mb.StringValue(8,2) = Format(utcDate.Day, "00") + mb.Byte(10) = &h54 + mb.StringValue(11,2) = Format(utcDate.Hour, "00") + mb.Byte(13) = &h3A + mb.StringValue(14,2) = Format(utcDate.Minute, "00") + mb.Byte(16) = &h3A + mb.StringValue(17,2) = Format(utcDate.Second, "00") + mb.Byte(19) = &h2E + mb.StringValue(20,3) = Format(utcDate.Nanosecond / 1000, "000") + mb.Byte(23) = &h5A + Return DefineEncoding(mb.StringValue(0, 24), Encodings.UTF8) + End Function + #tag EndMethod + + + #tag Constant, Name = kErrorInternal, Type = Double, Dynamic = False, Default = \"-10", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorFileWrite, Type = Double, Dynamic = False, Default = \"-8", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorCannotAuthenticate, Type = Double, Dynamic = False, Default = \"-7", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorUnsupportedFeature, Type = Double, Dynamic = False, Default = \"-6", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorSocketFail, Type = Double, Dynamic = False, Default = \"-5", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorHTTPFail, Type = Double, Dynamic = False, Default = \"-4", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorUnsupportedMediaType, Type = Double, Dynamic = False, Default = \"-3", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorXosonProblem, Type = Double, Dynamic = False, Default = \"-2", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kErrorInvalidJSON, Type = Double, Dynamic = False, Default = \"-1", Scope = Protected + #tag EndConstant + + #tag Constant, Name = kAPITimeoutSeconds, Type = Double, Dynamic = False, Default = \"5", Scope = Private + #tag EndConstant + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/samples/client/petstore/xojo/client/OpenAPIClient.xojo_project b/samples/client/petstore/xojo/client/OpenAPIClient.xojo_project new file mode 100644 index 000000000000..1c5a69780df8 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient.xojo_project @@ -0,0 +1,58 @@ +Type=Console +RBProjectVersion=2019.011 +MinIDEVersion=20070100 +Class=App;App.xojo_code;&h000000005B6127FF;&h0000000000000000;false +BuildSteps=Build Automation;Build Automation.xojo_code;&h000000005D9877FF;&h0000000000000000;false +Module=OpenAPIClient;OpenAPIClient.xojo_code;&h000000001FF397FF;&h0000000000000000;false +Class=OpenAPIClientException;OpenAPIClient/OpenAPIClientException.xojo_code;&h0000000054B007FF;&h000000001FF397FF;false +Module=Models;OpenAPIClient/Models.xojo_code;&h000000002FF397FF;&h000000001FF397FF;false +Class=ApiResponse;OpenAPIClient/Models/ApiResponse.xojo_code;&h0000000001871AFF;&h000000002FF397FF;false +Class=Category;OpenAPIClient/Models/Category.xojo_code;&h000000000186DAFF;&h000000002FF397FF;false +Class=Order;OpenAPIClient/Models/Order.xojo_code;&h000000000186CAFF;&h000000002FF397FF;false +Class=Pet;OpenAPIClient/Models/Pet.xojo_code;&h0000000001870AFF;&h000000002FF397FF;false +Class=Tag;OpenAPIClient/Models/Tag.xojo_code;&h000000000186FAFF;&h000000002FF397FF;false +Class=User;OpenAPIClient/Models/User.xojo_code;&h000000000186EAFF;&h000000002FF397FF;false +Module=APIs;OpenAPIClient/APIs.xojo_code;&h000000003FF397FF;&h000000001FF397FF;false +Class=PetApi;OpenAPIClient/APIs/PetApi.xojo_code;&h0000000001880AFF;&h000000003FF397FF;false +Class=PetApiCallbackHandler;OpenAPIClient/APIs/PetApiCallbackHandler.xojo_code;&h0000000001880AFF;&h000000003FF397FF;false +Class=StoreApi;OpenAPIClient/APIs/StoreApi.xojo_code;&h0000000001881AFF;&h000000003FF397FF;false +Class=StoreApiCallbackHandler;OpenAPIClient/APIs/StoreApiCallbackHandler.xojo_code;&h0000000001881AFF;&h000000003FF397FF;false +Class=UserApi;OpenAPIClient/APIs/UserApi.xojo_code;&h0000000001882AFF;&h000000003FF397FF;false +Class=UserApiCallbackHandler;OpenAPIClient/APIs/UserApiCallbackHandler.xojo_code;&h0000000001882AFF;&h000000003FF397FF;false +Class=Mock;Mock.xojo_code;&h000000002FF407FF;&h0000000000000000;false +MajorVersion=1 +MinorVersion=0 +SubVersion=0 +NonRelease=0 +Release=1 +InfoVersion=openapi-generator Generated Project +LongVersion=OpenAPIClient +ShortVersion=1.0 +WinCompanyName=OpenAPI-Generator Contributors +WinInternalName= +WinProductName= +WinFileDescription= +AutoIncrementVersionInformation=False +BuildFlags=&h4100 +BuildLanguage=&h0 +DebugLanguage=&h0 +Region= +WindowsName=OpenAPIClient.exe +MacCarbonMachName=OpenAPIClient +LinuxX86Name=OpenAPIClient +MacCreator= +MDI=0 +MDICaption= +DefaultEncoding=&h0 +AppIcon=OpenAPIClient.xojo_resources;&h0 +OSXBundleID=tech.openapi-generator.OpenAPIClient +DebuggerCommandLine= +UseGDIPlus=False +UseBuildsFolder=True +CopyRedistNextToWindowsEXE=False +IsWebProject=False +LinuxBuildArchitecture=1 +MacBuildArchitecture=1 +OptimizationLevel=0 +WindowsVersions={35138b9a-5d96-4fbd-8e2d-a2440225f93a}|{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}|{1f676c76-80e1-4239-95bb-83d0f6d0da78}|{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a} +WindowsRunAs=0 diff --git a/samples/client/petstore/xojo/client/OpenAPIClient.xojo_resources b/samples/client/petstore/xojo/client/OpenAPIClient.xojo_resources new file mode 100644 index 000000000000..a6d4df61c2d3 Binary files /dev/null and b/samples/client/petstore/xojo/client/OpenAPIClient.xojo_resources differ diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/APIs.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/APIs.xojo_code new file mode 100644 index 000000000000..afdbb3abef16 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/APIs.xojo_code @@ -0,0 +1,46 @@ +#tag Module +Protected Module APIs + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/APIs/PetApi.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/PetApi.xojo_code new file mode 100644 index 000000000000..f8f1bc1acb59 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/PetApi.xojo_code @@ -0,0 +1,1174 @@ +#tag Class +Protected Class PetApi + #tag Method, Flags = &h0 + Sub AddPet(, pet As OpenAPIClient.Models.Pet) + // Operation addPet + // Add a new pet to the store + // - + // - parameter pet: (body) Pet object that needs to be added to the store + // + // Invokes PetApiCallbackHandler.AddPetCallback(Pet) on completion. + // + // - POST /pet + // - + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(pet), "application/json") + + + + + + Dim localVarPath As String = "/pet" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.AddPet_handler + AddHandler localVarHTTPSocket.Error, addressof Me.AddPet_error + + + localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function AddPetPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, ByRef outData As OpenAPIClient.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New OpenAPIClient.Models.Pet + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub AddPet_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data As OpenAPIClient.Models.Pet + CallbackHandler.AddPetCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub AddPet_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data As OpenAPIClient.Models.Pet + Call AddPetPrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.AddPetCallback(error, data) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub DeletePet(, petId As Int64, Optional apiKey As Xoson.O.OptionalString) + // Operation deletePet + // Deletes a pet + // - parameter petId: (path) Pet id to delete + // - parameter apiKey: (header) (optional, default to Sample) + // + // Invokes PetApiCallbackHandler.DeletePetCallback() on completion. + // + // - DELETE /pet/{petId} + // - + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + If apiKey <> nil Then localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(apiKey)) + + + + + + Dim localVarPath As String = "/pet/{petId}" + + Dim localVarPathStringpetId As String = petId.ToString + + localVarPath = localVarPath.ReplaceAllB("{petId}", localVarPathStringpetId) + + + AddHandler localVarHTTPSocket.PageReceived, addressof Me.DeletePet_handler + AddHandler localVarHTTPSocket.Error, addressof Me.DeletePet_error + + localVarHTTPSocket.SendRequest("DELETE", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Sub DeletePet_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + CallbackHandler.DeletePetCallback(error) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub DeletePet_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + #Pragma Unused Headers + #Pragma Unused Content + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", "") + + + + CallbackHandler.DeletePetCallback(error) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub FindPetsByStatus(, status() As StatusEnum_FindPetsByStatus) + // Operation findPetsByStatus + // Finds Pets by status + // - + // - parameter status: (query) Status values that need to be considered for filter + // + // Invokes PetApiCallbackHandler.FindPetsByStatusCallback(Pet) on completion. + // + // - GET /pet/findByStatus + // - Multiple status values can be provided with comma separated strings + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + Dim localVarQueryParams As String = "?" + + Dim localVarQueryStringsstatus() As String + For Each localVarItemstatus As StatusEnum_FindPetsByStatus in status + Dim encodedParameter As String = EncodeURLComponent(StatusEnum_FindPetsByStatusToString(localVarItemstatus)) + localVarQueryStringsstatus.Append(encodedParameter) + Next + + Dim localVarQueryStringstatus As String + Select Case "form" + Case "form" + localVarQueryStringstatus = "status=" + Join(localVarQueryStringsstatus, ",") + Case "spaceDelimited" + localVarQueryStringstatus = "status=" + Join(localVarQueryStringsstatus, " ") + Case "pipeDelimited" + localVarQueryStringstatus = "status=" + Join(localVarQueryStringsstatus, "|") + Case "deepObject" + Raise New OpenAPIClient.OpenAPIClientException(kErrorUnsupportedFeature, "deepObject query parameters are not supported") + End Select + If localVarQueryStringsstatus.Ubound() > -1 Then localVarQueryParams = localVarQueryParams + EncodeURLComponent("status") + "=" + EncodeURLComponent(localVarQueryStringstatus) + + + + + + Dim localVarPath As String = "/pet/findByStatus" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.FindPetsByStatus_handler + AddHandler localVarHTTPSocket.Error, addressof Me.FindPetsByStatus_error + + + localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath + localVarQueryParams) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FindPetsByStatusPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, outData() As OpenAPIClient.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub FindPetsByStatus_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data() As OpenAPIClient.Models.Pet + CallbackHandler.FindPetsByStatusCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub FindPetsByStatus_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data() As OpenAPIClient.Models.Pet + Call FindPetsByStatusPrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.FindPetsByStatusCallback(error, data) + End Sub + #tag EndMethod + + + + #tag Method, Flags = &h21 + Private Function StatusEnum_FindPetsByStatusToString(value As StatusEnum_FindPetsByStatus) As String + Select Case value + + Case StatusEnum_FindPetsByStatus.Available + Return "available" + Case StatusEnum_FindPetsByStatus.Pending + Return "pending" + Case StatusEnum_FindPetsByStatus.Sold + Return "sold" + + End Select + Return "" + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub FindPetsByTags(, tags() As String) + // Operation findPetsByTags + // Finds Pets by tags + // - + // - parameter tags: (query) Tags to filter by + // + // Invokes PetApiCallbackHandler.FindPetsByTagsCallback(Pet) on completion. + // + // - GET /pet/findByTags + // - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + Dim localVarQueryParams As String = "?" + + Dim localVarQueryStringstags() As String + For Each localVarItemtags As String in tags + Dim encodedParameter As String = EncodeURLComponent(localVarItemtags) + localVarQueryStringstags.Append(encodedParameter) + Next + + Dim localVarQueryStringtags As String + Select Case "form" + Case "form" + localVarQueryStringtags = "inner=" + Join(localVarQueryStringstags, ",") + Case "spaceDelimited" + localVarQueryStringtags = "inner=" + Join(localVarQueryStringstags, " ") + Case "pipeDelimited" + localVarQueryStringtags = "inner=" + Join(localVarQueryStringstags, "|") + Case "deepObject" + Raise New OpenAPIClient.OpenAPIClientException(kErrorUnsupportedFeature, "deepObject query parameters are not supported") + End Select + If localVarQueryStringstags.Ubound() > -1 Then localVarQueryParams = localVarQueryParams + EncodeURLComponent("inner") + "=" + EncodeURLComponent(localVarQueryStringtags) + + + + + + Dim localVarPath As String = "/pet/findByTags" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.FindPetsByTags_handler + AddHandler localVarHTTPSocket.Error, addressof Me.FindPetsByTags_error + + + localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath + localVarQueryParams) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function FindPetsByTagsPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, outData() As OpenAPIClient.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub FindPetsByTags_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data() As OpenAPIClient.Models.Pet + CallbackHandler.FindPetsByTagsCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub FindPetsByTags_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data() As OpenAPIClient.Models.Pet + Call FindPetsByTagsPrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.FindPetsByTagsCallback(error, data) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub GetPetById(, petId As Int64) + // Operation getPetById + // Find pet by ID + // - + // - parameter petId: (path) ID of pet to return + // + // Invokes PetApiCallbackHandler.GetPetByIdCallback(Pet) on completion. + // + // - GET /pet/{petId} + // - Returns a single pet + // - defaultResponse: Nil + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + If me.ApiKeyapi_key = "" Then Raise New OpenAPIClient.OpenAPIClientException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `PetApi.ApiKeyapi_key` before invoking `PetApi.GetPetById()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/pet/{petId}" + + Dim localVarPathStringpetId As String = petId.ToString + + localVarPath = localVarPath.ReplaceAllB("{petId}", localVarPathStringpetId) + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.GetPetById_handler + AddHandler localVarHTTPSocket.Error, addressof Me.GetPetById_error + + + localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetPetByIdPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, ByRef outData As OpenAPIClient.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New OpenAPIClient.Models.Pet + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub GetPetById_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data As OpenAPIClient.Models.Pet + CallbackHandler.GetPetByIdCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub GetPetById_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data As OpenAPIClient.Models.Pet + Call GetPetByIdPrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.GetPetByIdCallback(error, data) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub UpdatePet(, pet As OpenAPIClient.Models.Pet) + // Operation updatePet + // Update an existing pet + // - + // - parameter pet: (body) Pet object that needs to be added to the store + // + // Invokes PetApiCallbackHandler.UpdatePetCallback(Pet) on completion. + // + // - PUT /pet + // - + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(pet), "application/json") + + + + + + Dim localVarPath As String = "/pet" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.UpdatePet_handler + AddHandler localVarHTTPSocket.Error, addressof Me.UpdatePet_error + + + localVarHTTPSocket.SendRequest("PUT", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function UpdatePetPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, ByRef outData As OpenAPIClient.Models.Pet) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New OpenAPIClient.Models.Pet + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub UpdatePet_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data As OpenAPIClient.Models.Pet + CallbackHandler.UpdatePetCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub UpdatePet_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data As OpenAPIClient.Models.Pet + Call UpdatePetPrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.UpdatePetCallback(error, data) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub UpdatePetWithForm(, petId As Int64, Optional name As Xoson.O.OptionalString, Optional status As Xoson.O.OptionalString) + // Operation updatePetWithForm + // Updates a pet in the store with form data + // - parameter petId: (path) ID of pet that needs to be updated + // - parameter name: (form) Updated name of the pet (optional, default to Sample) + // - parameter status: (form) Updated status of the pet (optional, default to Sample) + // + // Invokes PetApiCallbackHandler.UpdatePetWithFormCallback() on completion. + // + // - POST /pet/{petId} + // - + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + Dim localVarFormParams As New Dictionary + If name <> nil Then localVarFormParams.Value("name") = name +If status <> nil Then localVarFormParams.Value("status") = status + If localVarFormParams.Count > 0 Then localVarHTTPSocket.SetFormData(localVarFormParams) + + + + + + + Dim localVarPath As String = "/pet/{petId}" + + Dim localVarPathStringpetId As String = petId.ToString + + localVarPath = localVarPath.ReplaceAllB("{petId}", localVarPathStringpetId) + + + AddHandler localVarHTTPSocket.PageReceived, addressof Me.UpdatePetWithForm_handler + AddHandler localVarHTTPSocket.Error, addressof Me.UpdatePetWithForm_error + + localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Sub UpdatePetWithForm_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + CallbackHandler.UpdatePetWithFormCallback(error) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub UpdatePetWithForm_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + #Pragma Unused Headers + #Pragma Unused Content + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", "") + + + + CallbackHandler.UpdatePetWithFormCallback(error) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub UploadFile(, petId As Int64, Optional additionalMetadata As Xoson.O.OptionalString, Optional Escapedfile As FolderItem) + // Operation uploadFile + // uploads an image + // - + // - parameter petId: (path) ID of pet to update + // - parameter additionalMetadata: (form) Additional data to pass to server (optional, default to Sample) + // - parameter Escapedfile: (form) file to upload (optional, default to Sample) + // + // Invokes PetApiCallbackHandler.UploadFileCallback(ApiResponse) on completion. + // + // - POST /pet/{petId}/uploadImage + // - + // - defaultResponse: Nil + // + // - OAuth: + // - type: oauth2 + // - name: petstore_auth + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + Dim localVarFormParams As New Dictionary + If additionalMetadata <> nil Then localVarFormParams.Value("additionalMetadata") = additionalMetadata +If Escapedfile <> nil Then localVarFormParams.Value("file") = Escapedfile.LocalFuncSerializeFile + If localVarFormParams.Count > 0 Then localVarHTTPSocket.SetFormData(localVarFormParams) + + + + + + + Dim localVarPath As String = "/pet/{petId}/uploadImage" + + Dim localVarPathStringpetId As String = petId.ToString + + localVarPath = localVarPath.ReplaceAllB("{petId}", localVarPathStringpetId) + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.UploadFile_handler + AddHandler localVarHTTPSocket.Error, addressof Me.UploadFile_error + + + localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function UploadFilePrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, ByRef outData As OpenAPIClient.Models.ApiResponse) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New OpenAPIClient.Models.ApiResponse + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub UploadFile_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data As OpenAPIClient.Models.ApiResponse + CallbackHandler.UploadFileCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub UploadFile_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data As OpenAPIClient.Models.ApiResponse + Call UploadFilePrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.UploadFileCallback(error, data) + End Sub + #tag EndMethod + + + + + + + #tag Method, Flags = &h21 + Private Function AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + #Pragma Unused Realm + #Pragma Unused Headers + Name = Me.BasicAuthUser + Password = Me.BasicAuthPassword + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub PrivateFuncPrepareSocket(socket As HTTPSecureSocket) + socket.Secure = Me.useHTTPS + socket.ConnectionType = SSLSocket.TLSv12 + socket.Port = Me.Port + socket.RequestHeaders.Delete("Accept") + socket.RequestHeaders.AppendHeader("Accept", "text/plain") + socket.RequestHeaders.AppendHeader("Accept", "application/json") + socket.RequestHeaders.AppendHeader("Content-Type", "application/json") + + If Me.AdditionalHeaders <> Nil Then + For Each HeaderName As Variant In Me.AdditionalHeaders.Keys + Dim headerValueS As Variant = additionalHeaders.Value(HeaderName) + If headerValueS.IsArray Then + If headerValueS.ArrayElementType = Variant.TypeString Then + Dim values() As String = headerValueS + For Each value As String In values + socket.RequestHeaders.AppendHeader(HeaderName, value) + Next + Else + Raise New OpenAPIClient.OpenAPIClientException(kErrorInternal, "AdditionalHeaders only support Strings and String arrays as values.") + End If + Else + socket.RequestHeaders.AppendHeader(HeaderName, headerValueS.StringValue) + End If + Next + End If + End Sub + #tag EndMethod + + + + #tag Property, Flags = &h0 + AdditionalHeaders As Dictionary + #tag EndProperty + + #tag Property, Flags = &h0 + ApiKeyapi_key As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasePath As String = "http://petstore.swagger.io/v2" + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthPassword As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthUser As String + #tag EndProperty + + #tag Property, Flags = &h0 + CallbackHandler As OpenAPIClient.APIs.PetApiCallbackHandler + #tag EndProperty + + #tag Property, Flags = &h0 + Host As String = "" + #tag EndProperty + + #tag Property, Flags = &h0 + Port As Integer + #tag EndProperty + + #tag Property, Flags = &h0 + UseHTTPS As Boolean = true + #tag EndProperty + + #tag Enum, Name = StatusEnum_FindPetsByStatus, Type = Integer, Flags = &h0 + + Available + Pending + Sold + + #tag EndEnum + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthUser" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthPassword" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="UseHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/APIs/PetApiCallbackHandler.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/PetApiCallbackHandler.xojo_code new file mode 100644 index 000000000000..54acf0aa44d1 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/PetApiCallbackHandler.xojo_code @@ -0,0 +1,90 @@ +#tag Interface +Protected Interface PetApiCallbackHandler + #tag Method, Flags = &h0 + Sub AddPetCallback(status As OpenAPIClient.OpenAPIClientException, Optional data As OpenAPIClient.Models.Pet) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub DeletePetCallback(status As OpenAPIClient.OpenAPIClientException) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub FindPetsByStatusCallback(status As OpenAPIClient.OpenAPIClientException, data() As OpenAPIClient.Models.Pet) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub FindPetsByTagsCallback(status As OpenAPIClient.OpenAPIClientException, data() As OpenAPIClient.Models.Pet) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub GetPetByIdCallback(status As OpenAPIClient.OpenAPIClientException, Optional data As OpenAPIClient.Models.Pet) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub UpdatePetCallback(status As OpenAPIClient.OpenAPIClientException, Optional data As OpenAPIClient.Models.Pet) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub UpdatePetWithFormCallback(status As OpenAPIClient.OpenAPIClientException) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub UploadFileCallback(status As OpenAPIClient.OpenAPIClientException, Optional data As OpenAPIClient.Models.ApiResponse) + + End Sub + #tag EndMethod + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag EndViewBehavior +End Interface +#tag EndInterface diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/APIs/StoreApi.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/StoreApi.xojo_code new file mode 100644 index 000000000000..dd799a01da30 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/StoreApi.xojo_code @@ -0,0 +1,626 @@ +#tag Class +Protected Class StoreApi + #tag Method, Flags = &h0 + Sub DeleteOrder(, orderId As String) + // Operation deleteOrder + // Delete purchase order by ID + // - parameter orderId: (path) ID of the order that needs to be deleted + // + // Invokes StoreApiCallbackHandler.DeleteOrderCallback() on completion. + // + // - DELETE /store/order/{orderId} + // - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + // + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + + + + Dim localVarPath As String = "/store/order/{orderId}" + + Dim localVarPathStringorderId As String = orderId + + localVarPath = localVarPath.ReplaceAllB("{orderId}", localVarPathStringorderId) + + + AddHandler localVarHTTPSocket.PageReceived, addressof Me.DeleteOrder_handler + AddHandler localVarHTTPSocket.Error, addressof Me.DeleteOrder_error + + localVarHTTPSocket.SendRequest("DELETE", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Sub DeleteOrder_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + CallbackHandler.DeleteOrderCallback(error) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub DeleteOrder_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + #Pragma Unused Headers + #Pragma Unused Content + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", "") + + + + CallbackHandler.DeleteOrderCallback(error) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub GetInventory() + // Operation getInventory + // Returns pet inventories by status + // - + // + // Invokes StoreApiCallbackHandler.GetInventoryCallback(Dictionary) on completion. + // + // - GET /store/inventory + // - Returns a map of status codes to quantities + // - defaultResponse: Nil + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + If me.ApiKeyapi_key = "" Then Raise New OpenAPIClient.OpenAPIClientException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `StoreApi.ApiKeyapi_key` before invoking `StoreApi.GetInventory()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/store/inventory" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.GetInventory_handler + AddHandler localVarHTTPSocket.Error, addressof Me.GetInventory_error + + + localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetInventoryPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, ByRef outData As Dictionary) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New Dictionary + Try + outData = ParseJSON(Content) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub GetInventory_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data As Dictionary + CallbackHandler.GetInventoryCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub GetInventory_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data As Dictionary + Call GetInventoryPrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.GetInventoryCallback(error, data) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub GetOrderById(, orderId As Int64) + // Operation getOrderById + // Find purchase order by ID + // - + // - parameter orderId: (path) ID of pet that needs to be fetched + // + // Invokes StoreApiCallbackHandler.GetOrderByIdCallback(Order) on completion. + // + // - GET /store/order/{orderId} + // - For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + // - defaultResponse: Nil + // + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + + + + Dim localVarPath As String = "/store/order/{orderId}" + + Dim localVarPathStringorderId As String = orderId.ToString + + localVarPath = localVarPath.ReplaceAllB("{orderId}", localVarPathStringorderId) + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.GetOrderById_handler + AddHandler localVarHTTPSocket.Error, addressof Me.GetOrderById_error + + + localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetOrderByIdPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, ByRef outData As OpenAPIClient.Models.Order) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New OpenAPIClient.Models.Order + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub GetOrderById_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data As OpenAPIClient.Models.Order + CallbackHandler.GetOrderByIdCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub GetOrderById_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data As OpenAPIClient.Models.Order + Call GetOrderByIdPrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.GetOrderByIdCallback(error, data) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub PlaceOrder(, order As OpenAPIClient.Models.Order) + // Operation placeOrder + // Place an order for a pet + // - + // - parameter order: (body) order placed for purchasing the pet + // + // Invokes StoreApiCallbackHandler.PlaceOrderCallback(Order) on completion. + // + // - POST /store/order + // - + // - defaultResponse: Nil + // + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(order), "application/json") + + + + + Dim localVarPath As String = "/store/order" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.PlaceOrder_handler + AddHandler localVarHTTPSocket.Error, addressof Me.PlaceOrder_error + + + localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function PlaceOrderPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, ByRef outData As OpenAPIClient.Models.Order) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New OpenAPIClient.Models.Order + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub PlaceOrder_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data As OpenAPIClient.Models.Order + CallbackHandler.PlaceOrderCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub PlaceOrder_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data As OpenAPIClient.Models.Order + Call PlaceOrderPrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.PlaceOrderCallback(error, data) + End Sub + #tag EndMethod + + + + + + + #tag Method, Flags = &h21 + Private Function AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + #Pragma Unused Realm + #Pragma Unused Headers + Name = Me.BasicAuthUser + Password = Me.BasicAuthPassword + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub PrivateFuncPrepareSocket(socket As HTTPSecureSocket) + socket.Secure = Me.useHTTPS + socket.ConnectionType = SSLSocket.TLSv12 + socket.Port = Me.Port + socket.RequestHeaders.Delete("Accept") + socket.RequestHeaders.AppendHeader("Accept", "text/plain") + socket.RequestHeaders.AppendHeader("Accept", "application/json") + socket.RequestHeaders.AppendHeader("Content-Type", "application/json") + + If Me.AdditionalHeaders <> Nil Then + For Each HeaderName As Variant In Me.AdditionalHeaders.Keys + Dim headerValueS As Variant = additionalHeaders.Value(HeaderName) + If headerValueS.IsArray Then + If headerValueS.ArrayElementType = Variant.TypeString Then + Dim values() As String = headerValueS + For Each value As String In values + socket.RequestHeaders.AppendHeader(HeaderName, value) + Next + Else + Raise New OpenAPIClient.OpenAPIClientException(kErrorInternal, "AdditionalHeaders only support Strings and String arrays as values.") + End If + Else + socket.RequestHeaders.AppendHeader(HeaderName, headerValueS.StringValue) + End If + Next + End If + End Sub + #tag EndMethod + + + + #tag Property, Flags = &h0 + AdditionalHeaders As Dictionary + #tag EndProperty + + #tag Property, Flags = &h0 + ApiKeyapi_key As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasePath As String = "http://petstore.swagger.io/v2" + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthPassword As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthUser As String + #tag EndProperty + + #tag Property, Flags = &h0 + CallbackHandler As OpenAPIClient.APIs.StoreApiCallbackHandler + #tag EndProperty + + #tag Property, Flags = &h0 + Host As String = "" + #tag EndProperty + + #tag Property, Flags = &h0 + Port As Integer + #tag EndProperty + + #tag Property, Flags = &h0 + UseHTTPS As Boolean = true + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthUser" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthPassword" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="UseHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/APIs/StoreApiCallbackHandler.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/StoreApiCallbackHandler.xojo_code new file mode 100644 index 000000000000..6b0f1a5a3e40 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/StoreApiCallbackHandler.xojo_code @@ -0,0 +1,66 @@ +#tag Interface +Protected Interface StoreApiCallbackHandler + #tag Method, Flags = &h0 + Sub DeleteOrderCallback(status As OpenAPIClient.OpenAPIClientException) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub GetInventoryCallback(status As OpenAPIClient.OpenAPIClientException, Optional data As Dictionary) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub GetOrderByIdCallback(status As OpenAPIClient.OpenAPIClientException, Optional data As OpenAPIClient.Models.Order) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub PlaceOrderCallback(status As OpenAPIClient.OpenAPIClientException, Optional data As OpenAPIClient.Models.Order) + + End Sub + #tag EndMethod + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag EndViewBehavior +End Interface +#tag EndInterface diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/APIs/UserApi.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/UserApi.xojo_code new file mode 100644 index 000000000000..d1ec2ced1c4e --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/UserApi.xojo_code @@ -0,0 +1,847 @@ +#tag Class +Protected Class UserApi + #tag Method, Flags = &h0 + Sub CreateUser(, user As OpenAPIClient.Models.User) + // Operation createUser + // Create user + // - parameter user: (body) Created user object + // + // Invokes UserApiCallbackHandler.CreateUserCallback() on completion. + // + // - POST /user + // - This can only be done by the logged in user. + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(user), "application/json") + + If me.ApiKeyapi_key = "" Then Raise New OpenAPIClient.OpenAPIClientException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.CreateUser()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof Me.CreateUser_handler + AddHandler localVarHTTPSocket.Error, addressof Me.CreateUser_error + + localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Sub CreateUser_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + CallbackHandler.CreateUserCallback(error) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub CreateUser_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + #Pragma Unused Headers + #Pragma Unused Content + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", "") + + + + CallbackHandler.CreateUserCallback(error) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub CreateUsersWithArrayInput(, user() As OpenAPIClient.Models.User) + // Operation createUsersWithArrayInput + // Creates list of users with given input array + // - parameter user: (body) List of user object + // + // Invokes UserApiCallbackHandler.CreateUsersWithArrayInputCallback() on completion. + // + // - POST /user/createWithArray + // - + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(user), "application/json") + + If me.ApiKeyapi_key = "" Then Raise New OpenAPIClient.OpenAPIClientException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.CreateUsersWithArrayInput()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/createWithArray" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof Me.CreateUsersWithArrayInput_handler + AddHandler localVarHTTPSocket.Error, addressof Me.CreateUsersWithArrayInput_error + + localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Sub CreateUsersWithArrayInput_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + CallbackHandler.CreateUsersWithArrayInputCallback(error) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub CreateUsersWithArrayInput_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + #Pragma Unused Headers + #Pragma Unused Content + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", "") + + + + CallbackHandler.CreateUsersWithArrayInputCallback(error) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub CreateUsersWithListInput(, user() As OpenAPIClient.Models.User) + // Operation createUsersWithListInput + // Creates list of users with given input array + // - parameter user: (body) List of user object + // + // Invokes UserApiCallbackHandler.CreateUsersWithListInputCallback() on completion. + // + // - POST /user/createWithList + // - + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(user), "application/json") + + If me.ApiKeyapi_key = "" Then Raise New OpenAPIClient.OpenAPIClientException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.CreateUsersWithListInput()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/createWithList" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof Me.CreateUsersWithListInput_handler + AddHandler localVarHTTPSocket.Error, addressof Me.CreateUsersWithListInput_error + + localVarHTTPSocket.SendRequest("POST", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Sub CreateUsersWithListInput_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + CallbackHandler.CreateUsersWithListInputCallback(error) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub CreateUsersWithListInput_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + #Pragma Unused Headers + #Pragma Unused Content + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", "") + + + + CallbackHandler.CreateUsersWithListInputCallback(error) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub DeleteUser(, username As String) + // Operation deleteUser + // Delete user + // - parameter username: (path) The name that needs to be deleted + // + // Invokes UserApiCallbackHandler.DeleteUserCallback() on completion. + // + // - DELETE /user/{username} + // - This can only be done by the logged in user. + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + If me.ApiKeyapi_key = "" Then Raise New OpenAPIClient.OpenAPIClientException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.DeleteUser()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/{username}" + + Dim localVarPathStringusername As String = username + + localVarPath = localVarPath.ReplaceAllB("{username}", localVarPathStringusername) + + + AddHandler localVarHTTPSocket.PageReceived, addressof Me.DeleteUser_handler + AddHandler localVarHTTPSocket.Error, addressof Me.DeleteUser_error + + localVarHTTPSocket.SendRequest("DELETE", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Sub DeleteUser_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + CallbackHandler.DeleteUserCallback(error) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub DeleteUser_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + #Pragma Unused Headers + #Pragma Unused Content + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", "") + + + + CallbackHandler.DeleteUserCallback(error) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub GetUserByName(, username As String) + // Operation getUserByName + // Get user by user name + // - + // - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + // + // Invokes UserApiCallbackHandler.GetUserByNameCallback(User) on completion. + // + // - GET /user/{username} + // - + // - defaultResponse: Nil + // + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + + + + Dim localVarPath As String = "/user/{username}" + + Dim localVarPathStringusername As String = username + + localVarPath = localVarPath.ReplaceAllB("{username}", localVarPathStringusername) + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.GetUserByName_handler + AddHandler localVarHTTPSocket.Error, addressof Me.GetUserByName_error + + + localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetUserByNamePrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, ByRef outData As OpenAPIClient.Models.User) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + + outData = New OpenAPIClient.Models.User + Try + Xoson.fromJSON(outData, Content.toText()) + + Catch e As JSONException + error.Message = error.Message + " with JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xojo.Data.InvalidJSONException + error.Message = error.Message + " with Xojo.Data.JSON parse exception: " + e.Message + error.ErrorNumber = kErrorInvalidJSON + Return False + + Catch e As Xoson.XosonException + error.Message = error.Message + " with Xoson parse exception: " + e.Message + error.ErrorNumber = kErrorXosonProblem + Return False + + End Try + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub GetUserByName_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data As OpenAPIClient.Models.User + CallbackHandler.GetUserByNameCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub GetUserByName_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data As OpenAPIClient.Models.User + Call GetUserByNamePrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.GetUserByNameCallback(error, data) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub LoginUser(, username As String, password As String) + // Operation loginUser + // Logs user into the system + // - + // - parameter username: (query) The user name for login + // - parameter password: (query) The password for login in clear text + // + // Invokes UserApiCallbackHandler.LoginUserCallback(String) on completion. + // + // - GET /user/login + // - + // - defaultResponse: Sample + // + // + // - responseHeaders: [Set-Cookie(String), X-Rate-Limit(Integer), X-Expires-After(Date)] + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + Dim localVarQueryParams As String = "?" + localVarQueryParams = localVarQueryParams + EncodeURLComponent("username") + "=" + EncodeURLComponent(username) + + localVarQueryParams = localVarQueryParams + "&" + EncodeURLComponent("password") + "=" + EncodeURLComponent(password) + + + + + + Dim localVarPath As String = "/user/login" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof me.LoginUser_handler + AddHandler localVarHTTPSocket.Error, addressof Me.LoginUser_error + + + localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath + localVarQueryParams) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function LoginUserPrivateFuncDeserializeResponse(HTTPStatus As Integer, Headers As InternetHeaders, error As OpenAPIClient.OpenAPIClientException, Content As String, ByRef outData As String) As Boolean + Dim contentType As String = Headers.Value("Content-Type") + Dim contentEncoding As TextEncoding = OpenAPIClient.EncodingFromContentType(contentType) + Content = DefineEncoding(Content, contentEncoding) + + If HTTPStatus > 199 and HTTPStatus < 300 then + If contentType.LeftB(16) = "application/json" then + outData = Content + + + ElseIf contentType.LeftB(19) = "multipart/form-data" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + ElseIf contentType.LeftB(33) = "application/x-www-form-urlencoded" then + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + Else + error.Message = "Unsupported media type: " + contentType + error.ErrorNumber = kErrorUnsupportedMediaType + Return False + + End If + Else + error.Message = error.Message + ". " + Content + error.ErrorNumber = kErrorHTTPFail + Return False + End If + + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoginUser_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + Dim data As String + CallbackHandler.LoginUserCallback(error, data) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoginUser_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", Content) + + Dim data As String + Call LoginUserPrivateFuncDeserializeResponse(HTTPStatus, Headers, error, Content, data) + + CallbackHandler.LoginUserCallback(error, data) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub LogoutUser() + // Operation logoutUser + // Logs out current logged in user session + // + // Invokes UserApiCallbackHandler.LogoutUserCallback() on completion. + // + // - GET /user/logout + // - + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + + + If me.ApiKeyapi_key = "" Then Raise New OpenAPIClient.OpenAPIClientException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.LogoutUser()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/logout" + + + + AddHandler localVarHTTPSocket.PageReceived, addressof Me.LogoutUser_handler + AddHandler localVarHTTPSocket.Error, addressof Me.LogoutUser_error + + localVarHTTPSocket.SendRequest("GET", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Sub LogoutUser_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + CallbackHandler.LogoutUserCallback(error) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LogoutUser_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + #Pragma Unused Headers + #Pragma Unused Content + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", "") + + + + CallbackHandler.LogoutUserCallback(error) + End Sub + #tag EndMethod + + + + + #tag Method, Flags = &h0 + Sub UpdateUser(, username As String, user As OpenAPIClient.Models.User) + // Operation updateUser + // Updated user + // - parameter username: (path) name that need to be deleted + // - parameter user: (body) Updated user object + // + // Invokes UserApiCallbackHandler.UpdateUserCallback() on completion. + // + // - PUT /user/{username} + // - This can only be done by the logged in user. + // + // - API Key: + // - type: apiKey api_key (HEADER) + // - name: api_key + // + + Dim localVarHTTPSocket As New HTTPSecureSocket + Me.PrivateFuncPrepareSocket(localVarHTTPSocket) + localVarHTTPSocket.SetRequestContent(Xoson.toJSON(user), "application/json") + + If me.ApiKeyapi_key = "" Then Raise New OpenAPIClient.OpenAPIClientException(kErrorCannotAuthenticate, "API key is unset. Please assign a value to `UserApi.ApiKeyapi_key` before invoking `UserApi.UpdateUser()`.") + + localVarHTTPSocket.SetRequestHeader(EncodeURLComponent("api_key"), EncodeURLComponent(me.ApiKeyapi_key)) + + + + Dim localVarPath As String = "/user/{username}" + + Dim localVarPathStringusername As String = username + + localVarPath = localVarPath.ReplaceAllB("{username}", localVarPathStringusername) + + + AddHandler localVarHTTPSocket.PageReceived, addressof Me.UpdateUser_handler + AddHandler localVarHTTPSocket.Error, addressof Me.UpdateUser_error + + localVarHTTPSocket.SendRequest("PUT", Me.BasePath + localVarPath) + if localVarHTTPSocket.LastErrorCode <> 0 then + Dim localVarException As New OpenAPIClient.OpenAPIClientException(localVarHTTPSocket.LastErrorCode) + Raise localVarException + end if + + End Sub + #tag EndMethod + + + #tag Method, Flags = &h21 + Private Sub UpdateUser_error(sender As HTTPSecureSocket, Code As Integer) + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(Code) + CallbackHandler.UpdateUserCallback(error) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub UpdateUser_handler(sender As HTTPSecureSocket, URL As String, HTTPStatus As Integer, Headers As InternetHeaders, Content As String) + #Pragma Unused URL + #Pragma Unused Headers + #Pragma Unused Content + + If sender <> nil Then sender.Close() + + Dim error As New OpenAPIClient.OpenAPIClientException(HTTPStatus, "", "") + + + + CallbackHandler.UpdateUserCallback(error) + End Sub + #tag EndMethod + + + + + + + #tag Method, Flags = &h21 + Private Function AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + #Pragma Unused Realm + #Pragma Unused Headers + Name = Me.BasicAuthUser + Password = Me.BasicAuthPassword + Return True + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub PrivateFuncPrepareSocket(socket As HTTPSecureSocket) + socket.Secure = Me.useHTTPS + socket.ConnectionType = SSLSocket.TLSv12 + socket.Port = Me.Port + socket.RequestHeaders.Delete("Accept") + socket.RequestHeaders.AppendHeader("Accept", "text/plain") + socket.RequestHeaders.AppendHeader("Accept", "application/json") + socket.RequestHeaders.AppendHeader("Content-Type", "application/json") + + If Me.AdditionalHeaders <> Nil Then + For Each HeaderName As Variant In Me.AdditionalHeaders.Keys + Dim headerValueS As Variant = additionalHeaders.Value(HeaderName) + If headerValueS.IsArray Then + If headerValueS.ArrayElementType = Variant.TypeString Then + Dim values() As String = headerValueS + For Each value As String In values + socket.RequestHeaders.AppendHeader(HeaderName, value) + Next + Else + Raise New OpenAPIClient.OpenAPIClientException(kErrorInternal, "AdditionalHeaders only support Strings and String arrays as values.") + End If + Else + socket.RequestHeaders.AppendHeader(HeaderName, headerValueS.StringValue) + End If + Next + End If + End Sub + #tag EndMethod + + + + #tag Property, Flags = &h0 + AdditionalHeaders As Dictionary + #tag EndProperty + + #tag Property, Flags = &h0 + ApiKeyapi_key As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasePath As String = "http://petstore.swagger.io/v2" + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthPassword As String + #tag EndProperty + + #tag Property, Flags = &h0 + BasicAuthUser As String + #tag EndProperty + + #tag Property, Flags = &h0 + CallbackHandler As OpenAPIClient.APIs.UserApiCallbackHandler + #tag EndProperty + + #tag Property, Flags = &h0 + Host As String = "" + #tag EndProperty + + #tag Property, Flags = &h0 + Port As Integer + #tag EndProperty + + #tag Property, Flags = &h0 + UseHTTPS As Boolean = true + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="BasePath" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthUser" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="BasicAuthPassword" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="UseHTTPS" + Visible=false + Group="Behavior" + InitialValue="true" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Port" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Host" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/APIs/UserApiCallbackHandler.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/UserApiCallbackHandler.xojo_code new file mode 100644 index 000000000000..d715ecad7a93 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/APIs/UserApiCallbackHandler.xojo_code @@ -0,0 +1,90 @@ +#tag Interface +Protected Interface UserApiCallbackHandler + #tag Method, Flags = &h0 + Sub CreateUserCallback(status As OpenAPIClient.OpenAPIClientException) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub CreateUsersWithArrayInputCallback(status As OpenAPIClient.OpenAPIClientException) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub CreateUsersWithListInputCallback(status As OpenAPIClient.OpenAPIClientException) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub DeleteUserCallback(status As OpenAPIClient.OpenAPIClientException) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub GetUserByNameCallback(status As OpenAPIClient.OpenAPIClientException, Optional data As OpenAPIClient.Models.User) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub LoginUserCallback(status As OpenAPIClient.OpenAPIClientException, Optional data As String) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub LogoutUserCallback(status As OpenAPIClient.OpenAPIClientException) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub UpdateUserCallback(status As OpenAPIClient.OpenAPIClientException) + + End Sub + #tag EndMethod + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag EndViewBehavior +End Interface +#tag EndInterface diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models.xojo_code new file mode 100644 index 000000000000..5b5dda1f1f7a --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models.xojo_code @@ -0,0 +1,49 @@ +#tag Module +Protected Module Models + + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/ApiResponse.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/ApiResponse.xojo_code new file mode 100644 index 000000000000..38e0bef08187 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/ApiResponse.xojo_code @@ -0,0 +1,83 @@ +#tag Class +Protected Class ApiResponse + + #tag Property, Flags = &h0 + code As Xoson.O.OptionalInteger + #tag EndProperty + + + #tag Property, Flags = &h0 + type As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + message As Xoson.O.OptionalString + #tag EndProperty + + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="code" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="type" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="message" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/ApiResponseOptional.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/ApiResponseOptional.xojo_code new file mode 100644 index 000000000000..3a8acae2fea7 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/ApiResponseOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class ApiResponseOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As OpenAPIClient.Models.ApiResponse + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As OpenAPIClient.Models.ApiResponse) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As OpenAPIClient.Models.ApiResponse) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return OpenAPIClient.Models.ApiResponseToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As OpenAPIClient.Models.ApiResponse + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/Category.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/Category.xojo_code new file mode 100644 index 000000000000..45d782fba259 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/Category.xojo_code @@ -0,0 +1,70 @@ +#tag Class +Protected Class Category + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + name As Xoson.O.OptionalString + #tag EndProperty + + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="name" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/CategoryOptional.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/CategoryOptional.xojo_code new file mode 100644 index 000000000000..6d410900cbe5 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/CategoryOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class CategoryOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As OpenAPIClient.Models.Category + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As OpenAPIClient.Models.Category) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As OpenAPIClient.Models.Category) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return OpenAPIClient.Models.CategoryToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As OpenAPIClient.Models.Category + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/Order.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/Order.xojo_code new file mode 100644 index 000000000000..a26fb8a9aef3 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/Order.xojo_code @@ -0,0 +1,140 @@ +#tag Class +Protected Class Order + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + petId As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + quantity As Xoson.O.OptionalInteger + #tag EndProperty + + + #tag Property, Flags = &h0 + shipDate As Date + #tag EndProperty + + + #tag Property, Flags = &h0 + #tag Note + Order Status + #tag EndNote + status As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + complete As Xoson.O.OptionalBoolean + #tag EndProperty + + + #tag Enum, Name = StatusEnum, Type = Integer, Flags = &h0 + + Placed + Approved + Delivered + + #tag EndEnum + + + #tag Method, Flags = &h0 + Shared Function StatusEnumToString(value As StatusEnum) As String + Select Case value + + Case StatusEnum.Placed + Return "placed" + Case StatusEnum.Approved + Return "approved" + Case StatusEnum.Delivered + Return "delivered" + + End Select + Return "" + End Function + #tag EndMethod + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="petId" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="quantity" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="shipDate" + Visible=false + Group="Behavior" + InitialValue="" + Type="Date" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="complete" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/OrderOptional.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/OrderOptional.xojo_code new file mode 100644 index 000000000000..f04dbd7e697e --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/OrderOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class OrderOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As OpenAPIClient.Models.Order + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As OpenAPIClient.Models.Order) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As OpenAPIClient.Models.Order) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return OpenAPIClient.Models.OrderToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As OpenAPIClient.Models.Order + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/Pet.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/Pet.xojo_code new file mode 100644 index 000000000000..5fa04e3b94cb --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/Pet.xojo_code @@ -0,0 +1,140 @@ +#tag Class +Protected Class Pet + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + category As OpenAPIClient.Models.Category + #tag EndProperty + + + #tag Property, Flags = &h0 + name As String + #tag EndProperty + + + #tag Property, Flags = &h0 + photoUrls() As String + #tag EndProperty + + + #tag Property, Flags = &h0 + tags() As OpenAPIClient.Models.Tag + #tag EndProperty + + + #tag Property, Flags = &h0 + #tag Note + pet status in the store + #tag EndNote + Attributes( Deprecated ) status As Xoson.O.OptionalString + #tag EndProperty + + + #tag Enum, Name = StatusEnum, Type = Integer, Flags = &h0 + + Available + Pending + Sold + + #tag EndEnum + + + #tag Method, Flags = &h0 + Shared Function StatusEnumToString(value As StatusEnum) As String + Select Case value + + Case StatusEnum.Available + Return "available" + Case StatusEnum.Pending + Return "pending" + Case StatusEnum.Sold + Return "sold" + + End Select + Return "" + End Function + #tag EndMethod + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="category" + Visible=false + Group="Behavior" + InitialValue="" + Type="Category" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="name" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="photoUrls" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="tags" + Visible=false + Group="Behavior" + InitialValue="" + Type="Tag" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/PetOptional.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/PetOptional.xojo_code new file mode 100644 index 000000000000..af90170752b8 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/PetOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class PetOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As OpenAPIClient.Models.Pet + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As OpenAPIClient.Models.Pet) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As OpenAPIClient.Models.Pet) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return OpenAPIClient.Models.PetToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As OpenAPIClient.Models.Pet + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/Tag.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/Tag.xojo_code new file mode 100644 index 000000000000..2cb9a08524aa --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/Tag.xojo_code @@ -0,0 +1,70 @@ +#tag Class +Protected Class Tag + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + name As Xoson.O.OptionalString + #tag EndProperty + + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="name" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/TagOptional.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/TagOptional.xojo_code new file mode 100644 index 000000000000..b7071f5231cc --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/TagOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class TagOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As OpenAPIClient.Models.Tag + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As OpenAPIClient.Models.Tag) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As OpenAPIClient.Models.Tag) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return OpenAPIClient.Models.TagToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As OpenAPIClient.Models.Tag + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/User.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/User.xojo_code new file mode 100644 index 000000000000..776ce15170f2 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/User.xojo_code @@ -0,0 +1,151 @@ +#tag Class +Protected Class User + + #tag Property, Flags = &h0 + id As Xoson.O.OptionalInt64 + #tag EndProperty + + + #tag Property, Flags = &h0 + username As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + firstName As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + lastName As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + email As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + password As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + phone As Xoson.O.OptionalString + #tag EndProperty + + + #tag Property, Flags = &h0 + #tag Note + User Status + #tag EndNote + userStatus As Xoson.O.OptionalInteger + #tag EndProperty + + + + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="id" + Visible=false + Group="Behavior" + InitialValue="" + Type="Int64" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="username" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="firstName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="lastName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="email" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="password" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="phone" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="userStatus" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass + + diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/Models/UserOptional.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/Models/UserOptional.xojo_code new file mode 100644 index 000000000000..d5e2563bfce8 --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/Models/UserOptional.xojo_code @@ -0,0 +1,67 @@ +#tag Class +Protected Class UserOptional + #tag Method, Flags = &h0 + Function Operator_Convert() As OpenAPIClient.Models.User + Return Value + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Operator_Convert(rhs As OpenAPIClient.Models.User) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Set(Assigns rhs As OpenAPIClient.Models.User) + Value = rhs + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function ToString() As String + Return OpenAPIClient.Models.UserToString(Value) + End Function + #tag EndMethod + + #tag Property, Flags = &h0 + Value As OpenAPIClient.Models.User + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/OpenAPIClient/OpenAPIClientException.xojo_code b/samples/client/petstore/xojo/client/OpenAPIClient/OpenAPIClientException.xojo_code new file mode 100644 index 000000000000..6aace769eace --- /dev/null +++ b/samples/client/petstore/xojo/client/OpenAPIClient/OpenAPIClientException.xojo_code @@ -0,0 +1,185 @@ +#tag Class +Protected Class OpenAPIClientException +Inherits RuntimeException + #tag Method, Flags = &h0 + Sub Constructor(errorNumber As Integer, message As String) + // Construct an error related to the library. + 'Super.Constructor + Me.Message = message + Me.ErrorNumber = errorNumber + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor(HTTPCode As Integer, message As String, content As String) + // Construct an error related to an HTTP response. + 'Super.Constructor + + Me.HTTPCode = HTTPCode + If message = "" Then + Me.Message = "HTTP Status " + Str(HTTPCode) + Else + Me.Message = message + End If + + If HTTPCode < 200 Or HTTPCode > 299 Then + Me.ErrorNumber = kErrorHTTPFail + Me.OriginalResponseBody = content + End If + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor(socketCode As Integer) + // Construct an error related to a socket. + 'Super.Constructor + Me.SocketCode = socketCode + Me.Message = MessageForSocketErrorCode(socketCode) + + If socketCode <> 0 Then Me.ErrorNumber = kErrorSocketFail + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub Constructor() + // Disallow construction of empty results. + 'Super.Constructor + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function MessageForSocketErrorCode(code As Integer) As String + If code = 0 Then + Return "No error occurred." + ElseIf code = 100 Then + Return "There was an error opening and initializing the drivers." + ElseIf code = 101 Then + Return "This error code is no longer used." + ElseIf code = 102 Then + Return "This code means that you lost your connection." + ElseIf code = 103 Then + Return "The socket was unable to resolve the address that was specified." + ElseIf code = 104 Then + Return "This error code is no longer used." + ElseIf code = 105 Then + Return "The address is currently in use." + ElseIf code = 106 Then + Return "This is an invalid state error, which means that the socket is not in the proper state to be doing a certain operation." + ElseIf code = 107 Then + Return "This error means that the port you specified is invalid." + ElseIf code = 108 Then + Return "This error indicates that your application has run out of memory." + End If + + Return "An unknown socket error " + Str(code) + " occurred." + End Function + #tag EndMethod + + + #tag ComputedProperty, Flags = &h0 + #tag Getter + Get + Return "OpenAPIClientException | ErrorNumber: " + Str(Me.ErrorNumber) + " | HTTP Status: " + Str(Me.HTTPCode) + " | SocketCode: " + Str(Me.SocketCode) + " | Message: " + Me.Message + End Get + #tag EndGetter + Description As String + #tag EndComputedProperty + + #tag Property, Flags = &h0 + HTTPCode As Integer = -1 + #tag EndProperty + + #tag ComputedProperty, Flags = &h0 + #tag Getter + Get + Return ErrorNumber <> 0 + End Get + #tag EndGetter + IsError As Boolean + #tag EndComputedProperty + + #tag Property, Flags = &h0 + OriginalResponseBody As String + #tag EndProperty + + #tag Property, Flags = &h0 + SocketCode As Integer = 0 + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="HTTPCode" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Message" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="SocketCode" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="IsError" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/samples/client/petstore/xojo/client/README.md b/samples/client/petstore/xojo/client/README.md new file mode 100644 index 000000000000..82f0af115800 --- /dev/null +++ b/samples/client/petstore/xojo/client/README.md @@ -0,0 +1,126 @@ +# Xojo API client for OpenAPIClient + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: +- Build package: org.openapitools.codegen.languages.XojoClientCodegen + +## Installation + +This project contains generated code suitable for both Desktop and Console applications on all operating systems. + +The code is generated for Xojo's API v1. + +The generated code is packaged into a single Module (`OpenAPIClient`), which we suggest copying to your project after opening the generated `OpenAPIClient.xojo_project` in [Xojo](https://xojo.com/). Working in the generated Xojo project is not recommended. + +> See also Xojo's [Sharing code among multiple projects](https://documentation.xojo.com/topics/code_management/sharing_code_among_multiple_projects.html). + +This project depends on [Xoson](https://github.com/Topheee/xoson) `v2.2.0` (and above). Download it to your computer: +```shell +git clone 'https://github.com/Topheee/xoson.git' +``` + +Open the `Xoson.xojo_project` from the cloned git repository with Xojo and copy the `Xoson` module to your project. Similarily, open the `OpenAPIClient.xojo_project` file with Xojo and copy `OpenAPIClient` to your project. + +> Since Xojo currently has no package manager, you need to manually copy both the `Xoson` and the `OpenAPIClient` modules to your Xojo project. + +Both modules must not be copied into another module, but must reside at the top level of your project. + +### Customization + +The generator can be configured with the following options. + +Option | Used | Description +--- | --- | --- +`projectName` | `OpenAPIClient` | The name of the generated project and module. +`nonPublicApi` | `false` | Generate `Protected` instead of `Public` methods, if set. +`library` | `httpsocket` | Internal Xojo standard library object to use. Currently only `httpsocket` (`HTTPSocket` class) is supported. +`serializationLibrary` | `{xoson` | Internal library to use for serialization. Currently only `xoson` ([Xoson](https://github.com/Topheee/xoson) library) is supported. +`supportsAsync` | `true` | If `true`, generated APIs will use callbacks instead of blocking the main thread. + +### Usage + +Communication with the OpenAPI server is done by instantiating one of the classes below `OpenAPIClient.APIs`, configuring it - by setting `BasePath`, `UseHTTPS`, and `Port` - and invoking the `Public ` methods. +The methods always return immediately and the network communication is done in the background. To obtain the results and errors of each request, you need to implement the respective `CallbackHandler` interfaces: + +- `OpenAPIClient.APIs.PetApiCallbackHandler` +- `OpenAPIClient.APIs.StoreApiCallbackHandler` +- `OpenAPIClient.APIs.UserApiCallbackHandler` + + +Create an object of your implementing class and assign it to the `CallbackHandler` property of the API object. + +This callback handler has exactly one method definition for each operation. This method is invoked when the operation finishes. It's first parameter `status As OpenAPIClient.OpenAPIClientException` is always set. If `status.IsError` is `False`, the operation succeeded and the return value (either `data` or `file`) - if available - contains valid information. + +> The property `AdditionalHeaders` allows sending further headers with each request. Set it to a new `Dictionary`, with the Keys being the header names and the values either being a single String or an array of Strings. + +__Error handling__, as well as status reporting, is done via class `OpenAPIClient.OpenAPIClientException`. Note that an instance of this class does not always indicate an error - check `IsError` to find out. +- `ErrorNumber` is set to one of the `OpenAPIClient.kError` constants, or `0` in case of no error. +- `HTTPStatus` is set to the HTTP status code as returned by the server. If the error is unrelated to HTTP, this property is `-1`. +- `SocketCode` contains the socket error, if any; otherwise `0`. + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*OpenAPIClient.APIs.PetApi* | [**AddPet**](PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*OpenAPIClient.APIs.PetApi* | [**DeletePet**](PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*OpenAPIClient.APIs.PetApi* | [**FindPetsByStatus**](PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*OpenAPIClient.APIs.PetApi* | [**FindPetsByTags**](PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*OpenAPIClient.APIs.PetApi* | [**GetPetById**](PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*OpenAPIClient.APIs.PetApi* | [**UpdatePet**](PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*OpenAPIClient.APIs.PetApi* | [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*OpenAPIClient.APIs.PetApi* | [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*OpenAPIClient.APIs.StoreApi* | [**DeleteOrder**](StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*OpenAPIClient.APIs.StoreApi* | [**GetInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*OpenAPIClient.APIs.StoreApi* | [**GetOrderById**](StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*OpenAPIClient.APIs.StoreApi* | [**PlaceOrder**](StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*OpenAPIClient.APIs.UserApi* | [**CreateUser**](UserApi.md#createuser) | **POST** /user | Create user +*OpenAPIClient.APIs.UserApi* | [**CreateUsersWithArrayInput**](UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*OpenAPIClient.APIs.UserApi* | [**CreateUsersWithListInput**](UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*OpenAPIClient.APIs.UserApi* | [**DeleteUser**](UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*OpenAPIClient.APIs.UserApi* | [**GetUserByName**](UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*OpenAPIClient.APIs.UserApi* | [**LoginUser**](UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*OpenAPIClient.APIs.UserApi* | [**LogoutUser**](UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*OpenAPIClient.APIs.UserApi* | [**UpdateUser**](UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [OpenAPIClient.Models.ApiResponse](ApiResponse.md) + - [OpenAPIClient.Models.Category](Category.md) + - [OpenAPIClient.Models.Order](Order.md) + - [OpenAPIClient.Models.Pet](Pet.md) + - [OpenAPIClient.Models.Tag](Tag.md) + - [OpenAPIClient.Models.User](User.md) + + +## Documentation For Authorization + + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +## Author + + +