diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 60b08e90b36..56d465c2a9b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,6 +60,7 @@ Code change should conform to the programming style guide of the respective lang - Haskell: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md - Java: https://google.github.io/styleguide/javaguide.html - JavaScript: https://github.com/airbnb/javascript/ +- Julia: https://docs.julialang.org/en/v1/manual/style-guide/ - Kotlin: https://kotlinlang.org/docs/reference/coding-conventions.html - ObjC: https://github.com/NYTimes/objective-c-style-guide - Perl: http://perldoc.perl.org/perlstyle.html diff --git a/README.md b/README.md index fa85587b550..b061adcc474 100644 --- a/README.md +++ b/README.md @@ -79,8 +79,8 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se | | 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, 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), **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 - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) | -| **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/)), **Kotlin** (Spring Boot, Ktor, Vertx), **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 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, 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), **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 - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) | +| **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, Vertx), **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** | diff --git a/bin/configs/julia-client-petstore-new.yaml b/bin/configs/julia-client-petstore-new.yaml new file mode 100644 index 00000000000..c117487efd9 --- /dev/null +++ b/bin/configs/julia-client-petstore-new.yaml @@ -0,0 +1,7 @@ +generatorName: julia-client +outputDir: samples/client/petstore/julia +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/julia-client +additionalProperties: + hideGenerationTimestamp: "true" + packageName: PetStoreClient diff --git a/bin/configs/julia-server-petstore-new.yaml b/bin/configs/julia-server-petstore-new.yaml new file mode 100644 index 00000000000..9b709b71db1 --- /dev/null +++ b/bin/configs/julia-server-petstore-new.yaml @@ -0,0 +1,7 @@ +generatorName: julia-server +outputDir: samples/server/petstore/julia +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/julia-server +additionalProperties: + hideGenerationTimestamp: "true" + packageName: PetStoreServer diff --git a/docs/contributing.md b/docs/contributing.md index de8dcade6bb..7075b7792bd 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -64,6 +64,7 @@ Code change should conform to the programming style guide of the respective lang - Haskell: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md - Java: https://google.github.io/styleguide/javaguide.html - JavaScript: https://github.com/airbnb/javascript/ +- Julia: https://docs.julialang.org/en/v1/manual/style-guide/ - Kotlin: https://kotlinlang.org/docs/reference/coding-conventions.html - ObjC: https://github.com/NYTimes/objective-c-style-guide - Perl: http://perldoc.perl.org/perlstyle.html diff --git a/docs/generators.md b/docs/generators.md index f05f73224e4..538a347f19b 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -40,6 +40,7 @@ The following generators are available: * [javascript-flowtyped](generators/javascript-flowtyped.md) * [jaxrs-cxf-client](generators/jaxrs-cxf-client.md) * [jmeter](generators/jmeter.md) +* [julia-client](generators/julia-client.md) * [k6 (beta)](generators/k6.md) * [kotlin](generators/kotlin.md) * [lua (beta)](generators/lua.md) @@ -110,6 +111,7 @@ The following generators are available: * [jaxrs-resteasy](generators/jaxrs-resteasy.md) * [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md) * [jaxrs-spec](generators/jaxrs-spec.md) +* [julia-server](generators/julia-server.md) * [kotlin-server](generators/kotlin-server.md) * [kotlin-spring](generators/kotlin-spring.md) * [kotlin-vertx (beta)](generators/kotlin-vertx.md) diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md index ee6f46499da..5f7d804345f 100644 --- a/docs/generators/jaxrs-cxf-client.md +++ b/docs/generators/jaxrs-cxf-client.md @@ -65,7 +65,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/gen/java| |testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| -|useAbstractionForFiles|Use alternative types instead of java.io.File to allow passing bytes without a file on disk.| |false| |useBeanValidation|Use BeanValidation API annotations| |false| |useGenericResponse|Use generic response| |false| |useGzipFeatureForTests|Use Gzip Feature for tests| |false| diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md index 88bad1716bc..1e6553ff5c1 100644 --- a/docs/generators/jaxrs-cxf-extended.md +++ b/docs/generators/jaxrs-cxf-extended.md @@ -78,7 +78,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |testDataFile|JSON file to contain generated test data| |null| |testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| -|useAbstractionForFiles|Use alternative types instead of java.io.File to allow passing bytes without a file on disk.| |false| |useAnnotatedBasePath|Use @Path annotations for basePath| |false| |useBeanValidation|Use BeanValidation API annotations| |true| |useBeanValidationFeature|Use BeanValidation Feature| |false| diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md index 414843f9b37..47d0ec6e8db 100644 --- a/docs/generators/jaxrs-cxf.md +++ b/docs/generators/jaxrs-cxf.md @@ -73,7 +73,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sourceFolder|source folder for generated code| |src/gen/java| |testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| -|useAbstractionForFiles|Use alternative types instead of java.io.File to allow passing bytes without a file on disk.| |false| |useAnnotatedBasePath|Use @Path annotations for basePath| |false| |useBeanValidation|Use BeanValidation API annotations| |true| |useBeanValidationFeature|Use BeanValidation Feature| |false| diff --git a/docs/generators/julia-client.md b/docs/generators/julia-client.md new file mode 100644 index 00000000000..eab368d5e3b --- /dev/null +++ b/docs/generators/julia-client.md @@ -0,0 +1,219 @@ +--- +title: Documentation for the julia-client Generator +--- + +## METADATA + +| Property | Value | Notes | +| -------- | ----- | ----- | +| generator name | julia-client | pass this to the generate command after -g | +| generator stability | STABLE | | +| generator type | CLIENT | | +| generator language | Julia | | +| generator default templating engine | mustache | | +| helpTxt | Generates a julia client. | | + +## 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 | +| ------ | ----------- | ------ | ------- | +|exportModels|Whether to generate code to export model names.| |false| +|exportOperations|Whether to generate code to export operation names.| |false| +|packageName|Julia client package name.| |APIClient| + +## 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/docs/generators/julia-server.md b/docs/generators/julia-server.md new file mode 100644 index 00000000000..b9268cb0646 --- /dev/null +++ b/docs/generators/julia-server.md @@ -0,0 +1,218 @@ +--- +title: Documentation for the julia-server Generator +--- + +## METADATA + +| Property | Value | Notes | +| -------- | ----- | ----- | +| generator name | julia-server | pass this to the generate command after -g | +| generator stability | STABLE | | +| generator type | SERVER | | +| generator language | Julia | | +| generator default templating engine | mustache | | +| helpTxt | Generates a julia server. | | + +## 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 | +| ------ | ----------- | ------ | ------- | +|exportModels|Whether to generate code to export model names.| |false| +|packageName|Julia server package name.| |APIServer| + +## 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/docs/generators/julia.md b/docs/generators/julia.md new file mode 100644 index 00000000000..1be9f2db43e --- /dev/null +++ b/docs/generators/julia.md @@ -0,0 +1,212 @@ +--- +title: Documentation for the julia Generator +--- + +## METADATA + +| Property | Value | Notes | +| -------- | ----- | ----- | +| generator name | julia | pass this to the generate command after -g | +| generator stability | STABLE | | +| generator type | CLIENT | | +| generator language | Java | | +| generator default templating engine | mustache | | +| helpTxt | Generates a julia client. | | + +## 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 | +| ------ | ----------- | ------ | ------- | +|packageName|Julia package name.| |APIClient| + +## 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 b7248350253..abdd0ce4641 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)"); + WSDL("Web Services Description Language (WSDL)"), JULIA("Julia"); private final String label; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java new file mode 100644 index 00000000000..4b112347681 --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java @@ -0,0 +1,507 @@ +package org.openapitools.codegen.languages; + +import org.openapitools.codegen.*; +import org.openapitools.codegen.meta.features.ClientModificationFeature; +import org.openapitools.codegen.meta.features.ClientModificationFeature; +import org.openapitools.codegen.meta.features.DocumentationFeature; +import org.openapitools.codegen.meta.features.GlobalFeature; +import org.openapitools.codegen.meta.features.ParameterFeature; +import org.openapitools.codegen.meta.features.SchemaSupportFeature; +import org.openapitools.codegen.meta.features.SecurityFeature; +import org.openapitools.codegen.meta.features.WireFormatFeature; + +import java.io.File; +import java.util.*; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.ArraySchema; +import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.Operation; +import io.swagger.v3.oas.models.servers.Server; + +import org.apache.commons.lang3.StringUtils; +import static org.openapitools.codegen.utils.StringUtils.camelize; + +import org.openapitools.codegen.utils.CamelizeOption; +import org.openapitools.codegen.utils.ModelUtils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.CaseFormat; +import com.google.common.collect.ImmutableMap; +import com.samskivert.mustache.Mustache.Lambda; +import org.openapitools.codegen.templating.mustache.EscapeChar; + +public abstract class AbstractJuliaCodegen extends DefaultCodegen { + protected final Logger LOGGER = LoggerFactory.getLogger(AbstractJuliaCodegen.class); + + protected String srcPath = "src"; + protected String apiSrcPath = srcPath + "/apis/"; + protected String modelSrcPath = srcPath + "/models/"; + + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; + + protected String packageName; + protected Boolean exportModels; + protected Boolean exportOperations; + + public AbstractJuliaCodegen() { + super(); + + modifyFeatureSet(features -> features + .includeDocumentationFeatures(DocumentationFeature.Readme) + .includeSchemaSupportFeatures( + SchemaSupportFeature.Union, SchemaSupportFeature.allOf, + SchemaSupportFeature.anyOf, SchemaSupportFeature.oneOf + ) + .excludeWireFormatFeatures( + WireFormatFeature.XML + ) + .excludeSecurityFeatures( + SecurityFeature.OAuth2_Implicit, SecurityFeature.OAuth2_Password, + SecurityFeature.OAuth2_ClientCredentials, SecurityFeature.OAuth2_AuthorizationCode + ) + .excludeParameterFeatures( + ParameterFeature.Cookie + ) + .excludeGlobalFeatures( + GlobalFeature.Callbacks, GlobalFeature.Examples, + GlobalFeature.Produces, GlobalFeature.Consumes + ) + .includeClientModificationFeatures( + ClientModificationFeature.BasePath, ClientModificationFeature.UserAgent + ) + ); + + reservedWords = new HashSet ( + Arrays.asList( + "if", "else", "elseif", "while", "for", "begin", "end", "quote", + "try", "catch", "return", "local", "function", "macro", "ccall", "finally", "break", "continue", + "global", "module", "using", "import", "export", "const", "let", "do", "baremodule", + "Type", "Enum", "Any", "DataType", "Base" + ) + ); + + // Language Specific Primitives. These types will not trigger imports by the client generator + languageSpecificPrimitives = new HashSet( + Arrays.asList("Integer", "Int128", "Int64", "Int32", "Int16", "Int8", "UInt128", "UInt64", "UInt32", "UInt16", "UInt8", "Float64", "Float32", "Float16", "Char", "Vector", "Dict", "Vector{UInt8}", "Bool", "String", "Date", "DateTime", "ZonedDateTime", "Nothing", "Any") + ); + + typeMapping.clear(); + typeMapping.put("int", "Int64"); + typeMapping.put("integer", "Int64"); + typeMapping.put("long", "Int64"); + typeMapping.put("short", "Int32"); + typeMapping.put("byte", "UInt8"); + typeMapping.put("float", "Float32"); + typeMapping.put("double", "Float64"); + typeMapping.put("string", "String"); + typeMapping.put("char", "String"); + typeMapping.put("binary", "Vector{UInt8}"); + typeMapping.put("boolean", "Bool"); + typeMapping.put("number", "Float64"); + typeMapping.put("decimal", "Float64"); + typeMapping.put("array", "Vector"); + typeMapping.put("set", "Vector"); + typeMapping.put("map", "Dict"); + typeMapping.put("date", "Date"); + typeMapping.put("DateTime", "ZonedDateTime"); + typeMapping.put("File", "String"); + typeMapping.put("file", "String"); + typeMapping.put("UUID", "String"); + typeMapping.put("URI", "String"); + typeMapping.put("ByteArray", "Vector{UInt8}"); + typeMapping.put("object", "Any"); + typeMapping.put("Object", "Any"); + typeMapping.put("AnyType", "Any"); + } + + @Override + public GeneratorLanguage generatorLanguage() { + return GeneratorLanguage.JULIA; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public void setExportModels(Boolean exportModels) { + this.exportModels = exportModels; + } + + public void setExportOperations(Boolean exportOperations) { + this.exportOperations = exportOperations; + } + + protected static String dropDots(String str) { + return str.replaceAll("\\.", "_"); + } + + /** + * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping + * those terms here. This logic is only called if a variable matches the reseved words + * + * @return the escaped term + */ + @Override + public String escapeReservedWord(String name) { + if (reservedWords.contains(name)) { + return "__" + name + "__"; // add underscores to reserved words, and also to obscure it to lessen chances of clashing with any other names + } else { + return name; + } + } + + /** + * Location to write model files. + */ + @Override + public String modelFileFolder() { + return (outputFolder + "/" + modelSrcPath).replace('/', File.separatorChar); + } + + /** + * Location to write api files. + */ + @Override + public String apiFileFolder() { + return (outputFolder + "/" + apiSrcPath).replace('/', File.separatorChar); + } + + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + } + + @Override + public String toModelFilename(String name) { + return "model_" + toModelName(name); + } + + @Override + public String toApiFilename(String name) { + name = name.replaceAll("-", "_"); + return "api_" + camelize(name) + "Api"; + } + + @Override + public String toApiName(String name) { + if (name.length() == 0) { + return "DefaultApi"; + } + // e.g. phone_number_api => PhoneNumberApi + return camelize(name) + "Api"; + } + + @Override + public String toParamName(String name) { + CamelizeOption camelizeOption = CamelizeOption.UPPERCASE_FIRST_CHAR; + name = camelize(sanitizeName(name), camelizeOption); + name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name); + return escapeReservedWord(name); + } + + @Override + public String toApiVarName(String name) { + CamelizeOption camelizeOption = CamelizeOption.UPPERCASE_FIRST_CHAR; + name = camelize(sanitizeName(name), camelizeOption); + name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name); + return escapeReservedWord(name); + } + + @Override + public String toVarName(String name) { + return name; + } + + /** + * Sanitize name (parameter, property, method, etc) + * + * @param name string to be sanitize + * @return sanitized string + */ + @Override + @SuppressWarnings("static-method") + public String sanitizeName(String name) { + if (name == null) { + LOGGER.error("String to be sanitized is null. Default to ERROR_UNKNOWN"); + return "ERROR_UNKNOWN"; + } + + // if the name is just '$', map it to 'value', as that's sometimes used in the spec + if ("$".equals(name)) { + return "value"; + } + + name = name.replaceAll("\\[\\]", ""); + name = name.replaceAll("\\[", "_"); + name = name.replaceAll("\\]", ""); + name = name.replaceAll("\\(", "_"); + name = name.replaceAll("\\)", ""); + name = name.replaceAll("\\.", "_"); + name = name.replaceAll("-", "_"); + name = name.replaceAll(" ", "_"); + name = name.replaceAll("/", "_"); + return name.replaceAll("[^a-zA-Z0-9_{}]", ""); + } + + protected boolean needsVarEscape(String name) { + return (!name.matches("[a-zA-Z0-9_]*") && !name.matches("var\".*\"")) || reservedWords.contains(name); + } + + /** + * Output the proper Julia model name. + * + * @param name the name of the model + * @return Julia model name + */ + @Override + public String toModelName(final String name) { + String result = sanitizeName(name); + + // remove dollar sign + result = result.replaceAll("$", ""); + + // model name cannot use reserved keyword, e.g. return + if (isReservedWord(result)) { + LOGGER.warn(result + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + result)); + result = "model_" + result; // e.g. return => ModelReturn (after camelize) + } + + // model name starts with number + if (result.matches("^\\d.*")) { + LOGGER.warn(result + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + result)); + result = "model_" + result; // e.g. 200Response => Model200Response (after camelize) + } + + if (!StringUtils.isEmpty(modelNamePrefix)) { + result = modelNamePrefix + "_" + result; + } + + if (!StringUtils.isEmpty(modelNameSuffix)) { + result = result + "_" + modelNameSuffix; + } + + result = dropDots(result); + // camelize the model name + // phone_number => PhoneNumber + result = camelize(result); + + return result; + } + + @Override + public String getTypeDeclaration(Schema schema) { + if (ModelUtils.isArraySchema(schema)) { + ArraySchema ap = (ArraySchema) schema; + Schema inner = ap.getItems(); + return getSchemaType(schema) + "{" + getTypeDeclaration(inner) + "}"; + } else if (ModelUtils.isSet(schema)) { + Schema inner = getAdditionalProperties(schema); + return getSchemaType(schema) + "{" + getTypeDeclaration(inner) + "}"; + } else if (ModelUtils.isMapSchema(schema)) { + Schema inner = getAdditionalProperties(schema); + return getSchemaType(schema) + "{String, " + getTypeDeclaration(inner) + "}"; + } + return super.getTypeDeclaration(schema); + } + + + /** + * Return the type declaration for a given schema + * + * @param schema the schema + * @return the type declaration + */ + @Override + public String getSchemaType(Schema schema) { + String openAPIType = super.getSchemaType(schema); + String type = null; + + if (openAPIType == null) { + LOGGER.error("OpenAPI Type for {} is null. Default to Object instead.", schema.getName()); + openAPIType = "Object"; + } + + if (typeMapping.containsKey(openAPIType)) { + type = typeMapping.get(openAPIType); + if(languageSpecificPrimitives.contains(type)) { + return type; + } + } else { + type = openAPIType; + } + + return toModelName(type); + } + + /** + * Return the default value of the property + * @param schema OpenAPI property object + * @return string presentation of the default value of the property + */ + @Override + public String toDefaultValue(Schema schema) { + if (ModelUtils.isBooleanSchema(schema)) { + if (schema.getDefault() != null) { + return schema.getDefault().toString(); + } + } else if (ModelUtils.isDateSchema(schema)) { + // TODO + } else if (ModelUtils.isDateTimeSchema(schema)) { + // TODO + } else if (ModelUtils.isIntegerSchema(schema) || ModelUtils.isLongSchema(schema) || ModelUtils.isNumberSchema(schema)) { + if (schema.getDefault() != null) { + return schema.getDefault().toString(); + } + } else if (ModelUtils.isStringSchema(schema)) { + if (schema.getDefault() != null) { + String _default = (String) schema.getDefault(); + if (schema.getEnum() == null) { + return "\"" + _default + "\""; + } else { + // convert to enum var name later in postProcessModels + return _default; + } + } + } + + return "nothing"; + } + + @Override + public String escapeUnsafeCharacters(String input) { + return input.replace("#=", "#_=").replace("=#", "=_#"); + } + + /** + * Escape single and/or double quote to avoid code injection + * @param input String to be cleaned up + * @return string with quotation mark removed or escaped + */ + public String escapeQuotationMark(String input) { + return input.replace("\"", "\\\""); + } + + protected String escapeRegex(String pattern) { + pattern = pattern.replaceAll("\\\\\\\\", "\\\\"); + pattern = pattern.replaceAll("^/", ""); + pattern = pattern.replaceAll("/$", ""); + return pattern; + } + + /** + * Convert OpenAPI Parameter object to Codegen Parameter object + * + * @param imports set of imports for library/package/module + * @param param OpenAPI parameter object + * @return Codegen Parameter object + */ + @Override + public CodegenParameter fromParameter(Parameter param, Set imports) { + CodegenParameter parameter = super.fromParameter(param, imports); + if (parameter.pattern != null) { + parameter.pattern = escapeRegex(parameter.pattern); + } + return parameter; + } + + /** + * Convert OAS Property schema to Codegen Property object. + *

+ * The return value is cached. An internal cache is looked up to determine + * if the CodegenProperty return value has already been instantiated for + * the (String name, Schema schema) arguments. + * Any subsequent processing of the CodegenModel return value must be idempotent + * for a given (String name, Schema schema). + * + * @param name name of the property + * @param schema OAS property schema + * @param required true if the property is required in the next higher object schema, false otherwise + * @return Codegen Property object + */ + @Override + public CodegenProperty fromProperty(String name, Schema schema, boolean required) { + CodegenProperty property = super.fromProperty(name, schema, required); + // if the name needs any escaping, we set it to var"name" + if (needsVarEscape(property.name)) { + property.name = "var\"" + property.name + "\""; + } + if (property.pattern != null) { + property.pattern = escapeRegex(property.pattern); + } + return property; + } + + /** + * Return the operation ID (method name) + * + * @param operationId operation ID + * @return the sanitized method name + */ + @SuppressWarnings("static-method") + public String toOperationId(String operationId) { + CamelizeOption camelizeOption = CamelizeOption.UPPERCASE_FIRST_CHAR; + operationId = camelize(super.toOperationId(operationId), camelizeOption); + operationId = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, operationId); + return sanitizeName(operationId); + } + + private void changeParamNames(List paramsList, HashSet reservedNames) { + // check if any param name clashes with type name and rename it + for (CodegenParameter param : paramsList) { + if (reservedNames.contains(param.paramName)) { + do { + param.paramName = param.paramName + "_"; + } while (reservedNames.contains(param.paramName + "param")); + param.paramName = param.paramName + "param"; + } + } + } + + /** + * Convert OAS Operation object to Codegen Operation object + * + * @param httpMethod HTTP method + * @param operation OAS operation object + * @param path the path of the operation + * @param servers list of servers + * @return Codegen Operation object + */ + @Override + public CodegenOperation fromOperation(String path, + String httpMethod, + Operation operation, + List servers) { + CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers); + + // collect all reserved names + HashSet reservedNames = new HashSet(); + reservedNames.add(op.returnType); + reservedNames.add(op.operationId); + for (CodegenParameter param : op.allParams) { + reservedNames.add(param.dataType); + } + + changeParamNames(op.allParams, reservedNames); + changeParamNames(op.bodyParams, reservedNames); + changeParamNames(op.headerParams, reservedNames); + changeParamNames(op.pathParams, reservedNames); + changeParamNames(op.queryParams, reservedNames); + changeParamNames(op.formParams, reservedNames); + + return op; + } + + @Override + protected ImmutableMap.Builder addMustacheLambdas() { + return super.addMustacheLambdas() + .put("escapeDollar", new EscapeChar("(? \$}. + * + * Register: + * {@code additionalProperties.put("escapeDollar", new EscapeChar("(?**{{httpMethod}}** {{path}}
{{summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + +## Authorization +{{^authMethods}} Endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}} +## {{{name}}} +{{#isApiKey}}- **Type**: API key + +Example +``` + using OpenAPI + using OpenAPI.Clients + import OpenAPI.Clients: Client + client = Client(server_uri) + api = MyApi(client) + result = callApi(api, args...; api_key) +``` +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication + +Example +``` + using OpenAPI + using OpenAPI.Clients + import OpenAPI.Clients: Client, set_header + client = Client(server_uri) + set_header(client, "Authorization", "Basic $basic_auth") + api = MyApi(client) + result = callApi(api, args...; api_key) +``` +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} + +Example +``` + using OpenAPI + using OpenAPI.Clients + import OpenAPI.Clients: Client, set_header + client = Client(server_uri) + set_header(client, "Authorization", "Bearer $bearer_auth") + api = MyApi(client) + result = callApi(api, args...; api_key) +``` +{{/isOAuth}} +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} +{{/-last}}{{/apis}}{{/apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/julia-client/api.mustache b/modules/openapi-generator/src/main/resources/julia-client/api.mustache new file mode 100644 index 00000000000..afc62bbb223 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/api.mustache @@ -0,0 +1,96 @@ +{{>partial_header}} +{{#operations}} +struct {{classname}} <: OpenAPI.APIClientImpl + client::OpenAPI.Clients.Client +end + +""" +The default API base path for APIs in `{{classname}}`. +This can be used to construct the `OpenAPI.Clients.Client` instance. +""" +basepath(::Type{ {{classname}} }) = "{{basePath}}" + +{{#operation}} +const _returntypes_{{operationId}}_{{classname}} = Dict{Regex,Type}( + {{#responses}} + {{#dataType}} + Regex("^" * replace("{{{code}}}", "x"=>".") * "\$") => {{{dataType}}}, + {{/dataType}} + {{^dataType}} + Regex("^" * replace("{{{code}}}", "x"=>".") * "\$") => Nothing, + {{/dataType}} + {{/responses}} +) + +function _oacinternal_{{operationId}}(_api::{{classname}}{{#allParams}}{{#required}}, {{paramName}}::{{dataType}}{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}=nothing,{{/required}}{{/allParams}} _mediaType=nothing) +{{#allParams}} +{{#hasValidation}} +{{#maxLength}} + OpenAPI.validate_param("{{paramName}}", "{{operationId}}", :maxLength, {{paramName}}, {{maxLength}}) +{{/maxLength}} +{{#minLength}} + OpenAPI.validate_param("{{paramName}}", "{{operationId}}", :minLength, {{paramName}}, {{minLength}}) +{{/minLength}} +{{#maximum}} + OpenAPI.validate_param("{{paramName}}", "{{operationId}}", :maximum, {{paramName}}, {{maximum}}, {{#exclusiveMaximum}}true{{/exclusiveMaximum}}{{^exclusiveMaximum}}false{{/exclusiveMaximum}}) +{{/maximum}} +{{#minimum}} + OpenAPI.validate_param("{{paramName}}", "{{operationId}}", :minimum, {{paramName}}, {{minimum}}, {{#exclusiveMinimum}}true{{/exclusiveMinimum}}{{^exclusiveMinimum}}false{{/exclusiveMinimum}}) +{{/minimum}} +{{#maxItems}} + OpenAPI.validate_param("{{paramName}}", "{{operationId}}", :maxItems, {{paramName}}, {{maxItems}}) +{{/maxItems}} +{{#minItems}} + OpenAPI.validate_param("{{paramName}}", "{{operationId}}", :minItems, {{paramName}}, {{minItems}}) +{{/minItems}} + +{{/hasValidation}} +{{/allParams}} + _ctx = OpenAPI.Clients.Ctx(_api.client, "{{httpMethod}}", _returntypes_{{operationId}}_{{classname}}, "{{path}}", [{{#authMethods}}"{{name}}", {{/authMethods}}]{{#bodyParam}}, {{paramName}}{{/bodyParam}}) +{{#pathParams}} + OpenAPI.Clients.set_param(_ctx.path, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{paramName}}{{#isListContainer}}; collection_format="{{collectionFormat}}"{{/isListContainer}}) # type {{dataType}} +{{/pathParams}} +{{#queryParams}} + OpenAPI.Clients.set_param(_ctx.query, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{paramName}}{{#isListContainer}}; collection_format="{{collectionFormat}}"{{/isListContainer}}) # type {{dataType}} +{{/queryParams}} +{{#headerParams}} + OpenAPI.Clients.set_param(_ctx.header, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{paramName}}{{#isListContainer}}; collection_format="{{collectionFormat}}"{{/isListContainer}}) # type {{dataType}} +{{/headerParams}} +{{#formParams}} +{{^isFile}} + OpenAPI.Clients.set_param(_ctx.form, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{paramName}}{{#isListContainer}}; collection_format="{{collectionFormat}}"{{/isListContainer}}) # type {{dataType}} +{{/isFile}} +{{#isFile}} + OpenAPI.Clients.set_param(_ctx.file, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{paramName}}) # type {{dataType}} +{{/isFile}} +{{/formParams}} + OpenAPI.Clients.set_header_accept(_ctx, [{{#produces}}"{{{mediaType}}}", {{/produces}}]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [{{#consumes}}"{{{mediaType}}}", {{/consumes}}] : [_mediaType]) + return _ctx +end + +@doc raw"""{{#summary.length}}{{{summary}}} + +{{/summary.length}}{{#notes.length}}{{{notes}}} + +{{/notes.length}}Params: +{{#allParams}}- {{paramName}}::{{dataType}}{{#required}} (required){{/required}} +{{/allParams}} + +Return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Nothing{{/returnType}}, OpenAPI.Clients.ApiResponse +""" +function {{operationId}}(_api::{{classname}}{{#allParams}}{{#required}}, {{paramName}}::{{dataType}}{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}=nothing,{{/required}}{{/allParams}} _mediaType=nothing) + _ctx = _oacinternal_{{operationId}}(_api{{#allParams}}{{#required}}, {{paramName}}{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}={{paramName}},{{/required}}{{/allParams}} _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function {{operationId}}(_api::{{classname}}, response_stream::Channel{{#allParams}}{{#required}}, {{paramName}}::{{dataType}}{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}=nothing,{{/required}}{{/allParams}} _mediaType=nothing) + _ctx = _oacinternal_{{operationId}}(_api{{#allParams}}{{#required}}, {{paramName}}{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}={{paramName}},{{/required}}{{/allParams}} _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +{{/operation}} +{{#operation}} +export {{operationId}} +{{/operation}} +{{/operations}} diff --git a/modules/openapi-generator/src/main/resources/julia-client/api_doc.mustache b/modules/openapi-generator/src/main/resources/julia-client/api_doc.mustache new file mode 100644 index 00000000000..3328e7e6420 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/api_doc.mustache @@ -0,0 +1,50 @@ +# {{classname}}{{#description}} +{{.}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{operationId}}(_api::{{classname}}{{#allParams}}{{#required}}, {{paramName}}::{{dataType}}{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}=nothing,{{/required}}{{/allParams}} _mediaType=nothing) -> {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}Nothing{{/returnType}}, OpenAPI.Clients.ApiResponse
+> {{operationId}}(_api::{{classname}}, response_stream::Channel{{#allParams}}{{#required}}, {{paramName}}::{{dataType}}{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}=nothing,{{/required}}{{/allParams}} _mediaType=nothing) -> Channel{ {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}Nothing{{/returnType}} }, OpenAPI.Clients.ApiResponse + +{{{summary}}}{{#notes}} + +{{{.}}}{{/notes}} + +### Required Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **{{classname}}** | API context | {{/-last}}{{/allParams}}{{#allParams}}{{#required}} +**{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{.}}]{{/defaultValue}}{{/required}}{{/allParams}}{{#hasOptionalParams}} + +### Optional Parameters +{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}{{^required}} + **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{.}}]{{/defaultValue}}{{/required}}{{/allParams}}{{/hasOptionalParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}Nothing{{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/modules/openapi-generator/src/main/resources/julia-client/client.mustache b/modules/openapi-generator/src/main/resources/julia-client/client.mustache new file mode 100644 index 00000000000..100fe6e5a3d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/client.mustache @@ -0,0 +1,24 @@ +{{>partial_header}} +module {{packageName}} + +using Dates, TimeZones +using OpenAPI +using OpenAPI.Clients + +const API_VERSION = "{{appVersion}}" + +include("modelincludes.jl") +{{#apiInfo}}{{#apis}} +include("apis/api_{{classname}}.jl"){{/apis}}{{/apiInfo}} + +{{#exportModels}} +# export models +{{#models}}{{#model}}export {{classname}} +{{/model}}{{/models}} +{{/exportModels}} +{{#exportOperations}} +# export operations +{{#apiInfo}}{{#apis}}export {{classname}} +{{/apis}}{{/apiInfo}} +{{/exportOperations}} +end # module {{packageName}} diff --git a/modules/openapi-generator/src/main/resources/julia-client/model.mustache b/modules/openapi-generator/src/main/resources/julia-client/model.mustache new file mode 100644 index 00000000000..a6165354e58 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/model.mustache @@ -0,0 +1,15 @@ +{{>partial_header}} +{{#models}} +{{#model}} +{{#isAlias}} +{{>partial_model_alias}} +{{/isAlias}}{{^isAlias}}{{#oneOf}}{{#-first}} +{{>partial_model_oneof}} +{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}} +{{>partial_model_anyof}} +{{/-first}}{{/anyOf}}{{^anyOf}}{{#hasVars}} +{{>partial_model_single}} +{{/hasVars}}{{^hasVars}} +{{>partial_model_alias}} +{{/hasVars}} +{{/anyOf}}{{/oneOf}}{{/isAlias}}{{/model}}{{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-client/model_doc.mustache b/modules/openapi-generator/src/main/resources/julia-client/model_doc.mustache new file mode 100644 index 00000000000..c5e99b3c513 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/model_doc.mustache @@ -0,0 +1,17 @@ +{{#models}}{{#model}}# {{classname}} + +{{#oneOf}}{{#-first}} +{{>partial_model_doc_oneof}} +{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}} +{{>partial_model_doc_anyof}} +{{/-first}}{{/anyOf}}{{^anyOf}} +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isDateTime}}**{{{dataType}}}**{{/isDateTime}}{{^isDateTime}}[**{{^isContainer}}*{{/isContainer}}{{{dataType}}}**]({{complexType}}.md){{/isDateTime}}{{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{/vars}} +{{/anyOf}}{{/oneOf}} + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} diff --git a/modules/openapi-generator/src/main/resources/julia-client/modelincludes.mustache b/modules/openapi-generator/src/main/resources/julia-client/modelincludes.mustache new file mode 100644 index 00000000000..5e4d8e05e19 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/modelincludes.mustache @@ -0,0 +1,4 @@ +{{>partial_header}} +{{#models}} +{{#model}}include("models/model_{{classname}}.jl"){{/model}} +{{/models}} diff --git a/modules/openapi-generator/src/main/resources/julia-client/partial_header.mustache b/modules/openapi-generator/src/main/resources/julia-client/partial_header.mustache new file mode 100644 index 00000000000..e94d7be6fa1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/partial_header.mustache @@ -0,0 +1,2 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. diff --git a/modules/openapi-generator/src/main/resources/julia-client/partial_model_alias.mustache b/modules/openapi-generator/src/main/resources/julia-client/partial_model_alias.mustache new file mode 100644 index 00000000000..88601ce07e3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/partial_model_alias.mustache @@ -0,0 +1,5 @@ +if !isdefined(@__MODULE__, :{{classname}}) + const {{classname}} = {{dataType}} +else + @warn("Skipping redefinition of {{classname}} to {{dataType}}") +end \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-client/partial_model_anyof.mustache b/modules/openapi-generator/src/main/resources/julia-client/partial_model_anyof.mustache new file mode 100644 index 00000000000..dc7846c43e1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/partial_model_anyof.mustache @@ -0,0 +1,23 @@ +{{#anyOf}}{{#-first}} +@doc raw"""{{name}}{{#description}} +{{description}}{{/description}} + + {{classname}}(; value=nothing) +""" +mutable struct {{classname}} <: OpenAPI.AnyOfAPIModel + value::Any # Union{ {{/-first}}{{/anyOf}}{{#anyOf}}{{^-first}}, {{/-first}}{{{.}}}{{/anyOf}}{{#anyOf}}{{#-last}} } + {{classname}}() = new() + {{classname}}(value) = new(value) +end # type {{classname}}{{/-last}}{{/anyOf}} + +function OpenAPI.property_type(::Type{ {{classname}} }, name::Symbol, json::Dict{String,Any}) + {{#discriminator}}discriminator = json["{{propertyName}}"] + {{#hasDiscriminatorWithNonEmptyMapping}}{{#mappedModels}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{mappingName}}" + return eval(Base.Meta.parse("{{modelName}}")) + {{#-last}}end{{/-last}}{{/mappedModels}}{{/hasDiscriminatorWithNonEmptyMapping}}{{^hasDiscriminatorWithNonEmptyMapping}}{{#anyOf}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{.}}" + return eval(Base.Meta.parse("{{.}}")) + {{#-last}}end{{/-last}}{{/anyOf}}{{/hasDiscriminatorWithNonEmptyMapping}} + throw(OpenAPI.ValidationException("Invalid discriminator value: $discriminator for {{classname}}")){{/discriminator}}{{^discriminator}} + # no discriminator specified, can't determine the exact type + return fieldtype({{classname}}, name){{/discriminator}} +end \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-client/partial_model_doc_anyof.mustache b/modules/openapi-generator/src/main/resources/julia-client/partial_model_doc_anyof.mustache new file mode 100644 index 00000000000..b5b5fabc052 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/partial_model_doc_anyof.mustache @@ -0,0 +1,11 @@ +{{#anyOf}}{{#-first}} +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | This is a anyOf model. The value must be any of the following types: {{/-first}}{{/anyOf}}{{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}} | {{description}} | {{^required}}[optional] {{/required}} + +{{#discriminator}}The discriminator field is `{{propertyName}}`{{#hasDiscriminatorWithNonEmptyMapping}} with the following mapping: +{{#mappedModels}} + - `{{mappingName}}`: `{{modelName}}` +{{/mappedModels}} +{{/hasDiscriminatorWithNonEmptyMapping}}{{/discriminator}} diff --git a/modules/openapi-generator/src/main/resources/julia-client/partial_model_doc_oneof.mustache b/modules/openapi-generator/src/main/resources/julia-client/partial_model_doc_oneof.mustache new file mode 100644 index 00000000000..4d6d3fa6dbe --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/partial_model_doc_oneof.mustache @@ -0,0 +1,11 @@ +{{#oneOf}}{{#-first}} +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | This is a oneOf model. The value must be exactly one of the following types: {{/-first}}{{/oneOf}}{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}} | {{description}} | {{^required}}[optional] {{/required}} + +{{#discriminator}}The discriminator field is `{{propertyName}}`{{#hasDiscriminatorWithNonEmptyMapping}} with the following mapping: +{{#mappedModels}} + - `{{mappingName}}`: `{{modelName}}` +{{/mappedModels}} +{{/hasDiscriminatorWithNonEmptyMapping}}{{/discriminator}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-client/partial_model_oneof.mustache b/modules/openapi-generator/src/main/resources/julia-client/partial_model_oneof.mustache new file mode 100644 index 00000000000..b75e456530b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/partial_model_oneof.mustache @@ -0,0 +1,23 @@ +{{#oneOf}}{{#-first}} +@doc raw"""{{name}}{{#description}} +{{description}}{{/description}} + + {{classname}}(; value=nothing) +""" +mutable struct {{classname}} <: OpenAPI.OneOfAPIModel + value::Any # Union{ {{/-first}}{{/oneOf}}{{#oneOf}}{{^-first}}, {{/-first}}{{{.}}}{{/oneOf}}{{#oneOf}}{{#-last}} } + {{classname}}() = new() + {{classname}}(value) = new(value) +end # type {{classname}}{{/-last}}{{/oneOf}} + +function OpenAPI.property_type(::Type{ {{classname}} }, name::Symbol, json::Dict{String,Any}) + {{#discriminator}}discriminator = json["{{propertyName}}"] + {{#hasDiscriminatorWithNonEmptyMapping}}{{#mappedModels}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{mappingName}}" + return eval(Base.Meta.parse("{{modelName}}")) + {{#-last}}end{{/-last}}{{/mappedModels}}{{/hasDiscriminatorWithNonEmptyMapping}}{{^hasDiscriminatorWithNonEmptyMapping}}{{#oneOf}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{.}}" + return eval(Base.Meta.parse("{{.}}")) + {{#-last}}end{{/-last}}{{/oneOf}}{{/hasDiscriminatorWithNonEmptyMapping}} + throw(OpenAPI.ValidationException("Invalid discriminator value: $discriminator for {{classname}}")){{/discriminator}}{{^discriminator}} + # no discriminator specified, can't determine the exact type + return fieldtype({{classname}}, name){{/discriminator}} +end \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-client/partial_model_single.mustache b/modules/openapi-generator/src/main/resources/julia-client/partial_model_single.mustache new file mode 100644 index 00000000000..806029ccf96 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-client/partial_model_single.mustache @@ -0,0 +1,91 @@ +@doc raw"""{{name}}{{#description}} +{{description}}{{/description}} + + {{classname}}(; +{{#allVars}} + {{{name}}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}nothing{{/defaultValue}}, +{{/allVars}} + ) + +{{#allVars}} + - {{{name}}}::{{datatype}}{{#description}} : {{description}}{{/description}} +{{/allVars}} +""" +Base.@kwdef mutable struct {{classname}} <: OpenAPI.APIModel +{{#allVars}} + {{{name}}}{{#isPrimitiveType}}::Union{Nothing, {{{datatype}}}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isContainer}}::Union{Nothing, {{#isMap}}Dict{{/isMap}}{{^isMap}}Vector{{/isMap}}}{{/isContainer}}{{/isPrimitiveType}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}nothing{{/defaultValue}}{{^isPrimitiveType}} # spec type: Union{ Nothing, {{datatype}} }{{/isPrimitiveType}} +{{/allVars}} + + function {{classname}}({{#allVars}}{{{name}}}, {{/allVars}}) + {{#allVars}} + OpenAPI.validate_property({{classname}}, Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"), {{{name}}}) + {{/allVars}} + return new({{#allVars}}{{{name}}}, {{/allVars}}) + end +end # type {{classname}} + +const _property_types_{{classname}} = Dict{Symbol,String}({{#allVars}}Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}")=>"{{datatype}}", {{/allVars}}) +OpenAPI.property_type(::Type{ {{classname}} }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_{{classname}}[name]))} + +function check_required(o::{{classname}}) +{{#allVars}} +{{#required}} + o.{{{name}}} === nothing && (return false) +{{/required}} +{{/allVars}} + true +end + +function OpenAPI.validate_property(::Type{ {{classname}} }, name::Symbol, val) +{{#allVars}} +{{#isEnum}} + if name === Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}") + OpenAPI.validate_param(name, "{{classname}}", :enum, val, [{{#_enum}}"{{.}}"{{^-last}}, {{/-last}}{{/_enum}}]) + end +{{/isEnum}} +{{^isEnum}} +{{#format}} + if name === Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}") + OpenAPI.validate_param(name, "{{classname}}", :format, val, "{{format}}") + end +{{/format}} +{{#hasValidation}} + if name === Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}") +{{#maxLength}} + OpenAPI.validate_param(name, "{{classname}}", :maxLength, val, {{maxLength}}) +{{/maxLength}} +{{#minLength}} + OpenAPI.validate_param(name, "{{classname}}", :minLength, val, {{minLength}}) +{{/minLength}} +{{#maximum}} + OpenAPI.validate_param(name, "{{classname}}", :maximum, val, {{maximum}}, {{#exclusiveMaximum}}true{{/exclusiveMaximum}}{{^exclusiveMaximum}}false{{/exclusiveMaximum}}) +{{/maximum}} +{{#minimum}} + OpenAPI.validate_param(name, "{{classname}}", :minimum, val, {{minimum}}, {{#exclusiveMinimum}}true{{/exclusiveMinimum}}{{^exclusiveMinimum}}false{{/exclusiveMinimum}}) +{{/minimum}} +{{#maxItems}} + OpenAPI.validate_param(name, "{{classname}}", :maxItems, val, {{maxItems}}) +{{/maxItems}} +{{#minItems}} + OpenAPI.validate_param(name, "{{classname}}", :minItems, val, {{minItems}}) +{{/minItems}} +{{#uniqueItems}} + OpenAPI.validate_param(name, "{{classname}}", :uniqueItems, val, {{uniqueItems}}) +{{/uniqueItems}} +{{#maxProperties}} + OpenAPI.validate_param(name, "{{classname}}", :maxProperties, val, {{maxProperties}}) +{{/maxProperties}} +{{#minProperties}} + OpenAPI.validate_param(name, "{{classname}}", :minProperties, val, {{minProperties}}) +{{/minProperties}} +{{#pattern}} + OpenAPI.validate_param(name, "{{classname}}", :pattern, val, r"{{{pattern}}}") +{{/pattern}} +{{#multipleOf}} + OpenAPI.validate_param(name, "{{classname}}", :multipleOf, val, {{multipleOf}}) +{{/multipleOf}} + end +{{/hasValidation}} +{{/isEnum}} +{{/allVars}} +end \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-server/README.mustache b/modules/openapi-generator/src/main/resources/julia-server/README.mustache new file mode 100644 index 00000000000..468d1b909ae --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/README.mustache @@ -0,0 +1,65 @@ +# Julia API server for {{packageName}} + +{{#appDescriptionWithNewLines}} +{{{.}}} +{{/appDescriptionWithNewLines}} + +## Overview +This API server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: {{appVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + + +## Installation +Place the Julia files generated under the `src` folder in your Julia project. Include {{packageName}}.jl in the project code. +It would include the module named {{packageName}}. + +Implement the server methods as listed below. They are also documented with the {{packageName}} module. +Launch a HTTP server with a router that has all handlers registered. A `register` method is provided in {{packageName}} module for convenience. + +```julia +register( + router::HTTP.Router, # Router to register handlers in + impl; # Module that implements the server methods + path_prefix::String="", # Prefix to be applied to all paths + optional_middlewares... # Optional middlewares to be applied to all handlers +) +``` + +Optional middlewares can be one or more of: +- `init`: called before the request is processed +- `pre_validation`: called after the request is parsed but before validation +- `pre_invoke`: called after validation but before the handler is invoked +- `post_invoke`: called after the handler is invoked but before the response is sent + +The order in which middlewares are invoked are: +`init |> read |> pre_validation |> validate |> pre_invoke |> invoke |> post_invoke` + + +## API Endpoints + +The following server methods must be implemented: + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + + +## Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + + +## Author + +{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} +{{/-last}}{{/apis}}{{/apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/julia-server/api.mustache b/modules/openapi-generator/src/main/resources/julia-server/api.mustache new file mode 100644 index 00000000000..5cabab5b0fc --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/api.mustache @@ -0,0 +1,67 @@ +{{>partial_header}} +{{#operations}} + +{{#operation}} +function {{operationId}}_read(handler) + function {{operationId}}_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}(){{#hasPathParams}} + path_params = HTTP.getparams(req){{#pathParams}} + openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param({{dataType}}, path_params, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{#required}}required=true, {{/required}}{{#isListContainer}}collection_format="{{collectionFormat}}", {{/isListContainer}}){{/pathParams}}{{/hasPathParams}}{{#hasQueryParams}} + query_params = HTTP.queryparams(URIs.URI(req.target)){{#queryParams}} + openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param({{dataType}}, query_params, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{#required}}required=true, {{/required}}{{#isListContainer}}collection_format="{{collectionFormat}}", {{/isListContainer}}){{/queryParams}}{{/hasQueryParams}}{{#hasHeaderParams}} + headers = Dict{String,String}(HTTP.headers(req)){{#headerParams}} + openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param({{dataType}}, headers, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{#required}}required=true, {{/required}}{{#isListContainer}}collection_format="{{collectionFormat}}", {{/isListContainer}}){{/headerParams}}{{/hasHeaderParams}}{{#hasBodyParam}}{{#bodyParams}} + openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param_type({{dataType}}, String(req.body)){{/bodyParams}}{{/hasBodyParam}}{{#hasFormParams}} + form_data = HTTP.parse_multipart_form(req){{#formParams}} + openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param({{dataType}}, form_data, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"; multipart=true, isfile={{#isFile}}true{{/isFile}}{{^isFile}}false{{/isFile}}, {{#required}}required=true, {{/required}}{{#isListContainer}}collection_format="{{collectionFormat}}", {{/isListContainer}}){{/formParams}}{{/hasFormParams}} + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function {{operationId}}_validate(handler) + function {{operationId}}_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + {{#allParams}}{{#hasValidation}} + {{#maxLength}} + OpenAPI.validate_param("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", "{{operationId}}", :maxLength, openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"], {{maxLength}}) + {{/maxLength}} + {{#minLength}} + OpenAPI.validate_param("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", "{{operationId}}", :minLength, openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"], {{minLength}}) + {{/minLength}} + {{#maximum}} + OpenAPI.validate_param("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", "{{operationId}}", :maximum, openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"], {{maximum}}, {{#exclusiveMaximum}}true{{/exclusiveMaximum}}{{^exclusiveMaximum}}false{{/exclusiveMaximum}}) + {{/maximum}} + {{#minimum}} + OpenAPI.validate_param("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", "{{operationId}}", :minimum, openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"], {{minimum}}, {{#exclusiveMinimum}}true{{/exclusiveMinimum}}{{^exclusiveMinimum}}false{{/exclusiveMinimum}}) + {{/minimum}} + {{#maxItems}} + OpenAPI.validate_param("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", "{{operationId}}", :maxItems, openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"], {{maxItems}}) + {{/maxItems}} + {{#minItems}} + OpenAPI.validate_param("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", "{{operationId}}", :minItems, openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"], {{minItems}}) + {{/minItems}} + {{/hasValidation}}{{/allParams}} + return handler(req) + end +end + +function {{operationId}}_invoke(impl; post_invoke=nothing) + function {{operationId}}_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.{{operationId}}(req::HTTP.Request{{#allParams}}{{#required}}, openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"]{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}=get(openapi_params, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", nothing),{{/required}}{{/allParams}}) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +{{/operation}} + +function register{{classname}}(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...) + {{#operation}} + HTTP.register!(router, "{{httpMethod}}", path_prefix * "{{path}}", OpenAPI.Servers.middleware(impl, {{operationId}}_read, {{operationId}}_validate, {{operationId}}_invoke; optional_middlewares...)) + {{/operation}} + return router +end +{{/operations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-server/api_doc.mustache b/modules/openapi-generator/src/main/resources/julia-server/api_doc.mustache new file mode 100644 index 00000000000..1595704fa31 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/api_doc.mustache @@ -0,0 +1,49 @@ +# {{classname}}{{#description}} +{{.}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{operationId}}(req::HTTP.Request{{#allParams}}{{#required}}, {{paramName}}::{{dataType}}{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}=nothing,{{/required}}{{/allParams}}) -> {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Nothing{{/returnType}} + +{{{summary}}}{{#notes}} + +{{{.}}}{{/notes}} + +### Required Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | {{/-last}}{{/allParams}}{{#allParams}}{{#required}} +**{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{.}}]{{/defaultValue}}{{/required}}{{/allParams}}{{#hasOptionalParams}} + +### Optional Parameters +{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}{{^required}} + **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{.}}]{{/defaultValue}}{{/required}}{{/allParams}}{{/hasOptionalParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}Nothing{{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/modules/openapi-generator/src/main/resources/julia-server/model.mustache b/modules/openapi-generator/src/main/resources/julia-server/model.mustache new file mode 100644 index 00000000000..35b6dc64d2d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/model.mustache @@ -0,0 +1,16 @@ +{{>partial_header}} +{{#models}} +{{#model}} +{{#isAlias}} +if !isdefined(@__MODULE__, :{{classname}}) + const {{classname}} = {{dataType}} +else + @warn("Skipping redefinition of {{classname}} to {{dataType}}") +end +{{/isAlias}}{{^isAlias}}{{#oneOf}}{{#-first}} +{{>partial_model_oneof}} +{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}} +{{>partial_model_anyof}} +{{/-first}}{{/anyOf}}{{^anyOf}} +{{>partial_model_single}} +{{/anyOf}}{{/oneOf}}{{/isAlias}}{{/model}}{{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-server/model_doc.mustache b/modules/openapi-generator/src/main/resources/julia-server/model_doc.mustache new file mode 100644 index 00000000000..c5e99b3c513 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/model_doc.mustache @@ -0,0 +1,17 @@ +{{#models}}{{#model}}# {{classname}} + +{{#oneOf}}{{#-first}} +{{>partial_model_doc_oneof}} +{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}} +{{>partial_model_doc_anyof}} +{{/-first}}{{/anyOf}}{{^anyOf}} +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isDateTime}}**{{{dataType}}}**{{/isDateTime}}{{^isDateTime}}[**{{^isContainer}}*{{/isContainer}}{{{dataType}}}**]({{complexType}}.md){{/isDateTime}}{{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{/vars}} +{{/anyOf}}{{/oneOf}} + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} diff --git a/modules/openapi-generator/src/main/resources/julia-server/modelincludes.mustache b/modules/openapi-generator/src/main/resources/julia-server/modelincludes.mustache new file mode 100644 index 00000000000..5e4d8e05e19 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/modelincludes.mustache @@ -0,0 +1,4 @@ +{{>partial_header}} +{{#models}} +{{#model}}include("models/model_{{classname}}.jl"){{/model}} +{{/models}} diff --git a/modules/openapi-generator/src/main/resources/julia-server/partial_header.mustache b/modules/openapi-generator/src/main/resources/julia-server/partial_header.mustache new file mode 100644 index 00000000000..e94d7be6fa1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/partial_header.mustache @@ -0,0 +1,2 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. diff --git a/modules/openapi-generator/src/main/resources/julia-server/partial_model_anyof.mustache b/modules/openapi-generator/src/main/resources/julia-server/partial_model_anyof.mustache new file mode 100644 index 00000000000..fdfb841f7e4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/partial_model_anyof.mustache @@ -0,0 +1,23 @@ +{{#anyOf}}{{#-first}} +@doc raw"""{{#description}}{{description}} +{{/description}} + + {{classname}}(; value=nothing) +""" +mutable struct {{classname}} <: OpenAPI.AnyOfAPIModel + value::Any # Union{ {{/-first}}{{/anyOf}}{{#anyOf}}{{^-first}}, {{/-first}}{{{.}}}{{/anyOf}}{{#anyOf}}{{#-last}} } + {{classname}}() = new() + {{classname}}(value) = new(value) +end # type {{classname}}{{/-last}}{{/anyOf}} + +function OpenAPI.property_type(::Type{ {{classname}} }, name::Symbol, json::Dict{String,Any}) + {{#discriminator}}discriminator = json["{{propertyName}}"] + {{#hasDiscriminatorWithNonEmptyMapping}}{{#mappedModels}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{mappingName}}" + return eval(Base.Meta.parse("{{modelName}}")) + {{#-last}}end{{/-last}}{{/mappedModels}}{{/hasDiscriminatorWithNonEmptyMapping}}{{^hasDiscriminatorWithNonEmptyMapping}}{{#anyOf}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{.}}" + return eval(Base.Meta.parse("{{.}}")) + {{#-last}}end{{/-last}}{{/anyOf}}{{/hasDiscriminatorWithNonEmptyMapping}} + throw(OpenAPI.ValidationException("Invalid discriminator value: $discriminator for {{classname}}")){{/discriminator}}{{^discriminator}} + # no discriminator specified, can't determine the exact type + return fieldtype({{classname}}, name){{/discriminator}} +end \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-server/partial_model_doc_anyof.mustache b/modules/openapi-generator/src/main/resources/julia-server/partial_model_doc_anyof.mustache new file mode 100644 index 00000000000..b5b5fabc052 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/partial_model_doc_anyof.mustache @@ -0,0 +1,11 @@ +{{#anyOf}}{{#-first}} +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | This is a anyOf model. The value must be any of the following types: {{/-first}}{{/anyOf}}{{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}} | {{description}} | {{^required}}[optional] {{/required}} + +{{#discriminator}}The discriminator field is `{{propertyName}}`{{#hasDiscriminatorWithNonEmptyMapping}} with the following mapping: +{{#mappedModels}} + - `{{mappingName}}`: `{{modelName}}` +{{/mappedModels}} +{{/hasDiscriminatorWithNonEmptyMapping}}{{/discriminator}} diff --git a/modules/openapi-generator/src/main/resources/julia-server/partial_model_doc_oneof.mustache b/modules/openapi-generator/src/main/resources/julia-server/partial_model_doc_oneof.mustache new file mode 100644 index 00000000000..4d6d3fa6dbe --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/partial_model_doc_oneof.mustache @@ -0,0 +1,11 @@ +{{#oneOf}}{{#-first}} +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | This is a oneOf model. The value must be exactly one of the following types: {{/-first}}{{/oneOf}}{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}} | {{description}} | {{^required}}[optional] {{/required}} + +{{#discriminator}}The discriminator field is `{{propertyName}}`{{#hasDiscriminatorWithNonEmptyMapping}} with the following mapping: +{{#mappedModels}} + - `{{mappingName}}`: `{{modelName}}` +{{/mappedModels}} +{{/hasDiscriminatorWithNonEmptyMapping}}{{/discriminator}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-server/partial_model_oneof.mustache b/modules/openapi-generator/src/main/resources/julia-server/partial_model_oneof.mustache new file mode 100644 index 00000000000..9593beaa5c3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/partial_model_oneof.mustache @@ -0,0 +1,23 @@ +{{#oneOf}}{{#-first}} +@doc raw"""{{#description}}{{description}} +{{/description}} + + {{classname}}(; value=nothing) +""" +mutable struct {{classname}} <: OpenAPI.OneOfAPIModel + value::Any # Union{ {{/-first}}{{/oneOf}}{{#oneOf}}{{^-first}}, {{/-first}}{{{.}}}{{/oneOf}}{{#oneOf}}{{#-last}} } + {{classname}}() = new() + {{classname}}(value) = new(value) +end # type {{classname}}{{/-last}}{{/oneOf}} + +function OpenAPI.property_type(::Type{ {{classname}} }, name::Symbol, json::Dict{String,Any}) + {{#discriminator}}discriminator = json["{{propertyName}}"] + {{#hasDiscriminatorWithNonEmptyMapping}}{{#mappedModels}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{mappingName}}" + return eval(Base.Meta.parse("{{modelName}}")) + {{#-last}}end{{/-last}}{{/mappedModels}}{{/hasDiscriminatorWithNonEmptyMapping}}{{^hasDiscriminatorWithNonEmptyMapping}}{{#oneOf}}{{#-first}}if{{/-first}}{{^-first}}elseif{{/-first}} discriminator == "{{.}}" + return eval(Base.Meta.parse("{{.}}")) + {{#-last}}end{{/-last}}{{/oneOf}}{{/hasDiscriminatorWithNonEmptyMapping}} + throw(OpenAPI.ValidationException("Invalid discriminator value: $discriminator for {{classname}}")){{/discriminator}}{{^discriminator}} + # no discriminator specified, can't determine the exact type + return fieldtype({{classname}}, name){{/discriminator}} +end \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-server/partial_model_single.mustache b/modules/openapi-generator/src/main/resources/julia-server/partial_model_single.mustache new file mode 100644 index 00000000000..6c47c3f3ff3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/partial_model_single.mustache @@ -0,0 +1,91 @@ +@doc raw"""{{#description}}{{description}} +{{/description}} + + {{classname}}(; +{{#allVars}} + {{{name}}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}nothing{{/defaultValue}}, +{{/allVars}} + ) + +{{#allVars}} + - {{{name}}}::{{datatype}}{{#description}} : {{description}}{{/description}} +{{/allVars}} +""" +Base.@kwdef mutable struct {{classname}} <: OpenAPI.APIModel +{{#allVars}} + {{{name}}}{{#isPrimitiveType}}::Union{Nothing, {{{datatype}}}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isContainer}}::Union{Nothing, {{#isMap}}Dict{{/isMap}}{{^isMap}}Vector{{/isMap}}}{{/isContainer}}{{/isPrimitiveType}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}nothing{{/defaultValue}}{{^isPrimitiveType}} # spec type: Union{ Nothing, {{datatype}} }{{/isPrimitiveType}} +{{/allVars}} + + function {{classname}}({{#allVars}}{{{name}}}, {{/allVars}}) + {{#allVars}} + OpenAPI.validate_property({{classname}}, Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"), {{{name}}}) + {{/allVars}} + return new({{#allVars}}{{{name}}}, {{/allVars}}) + end +end # type {{classname}} + +const _property_types_{{classname}} = Dict{Symbol,String}({{#allVars}}Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}")=>"{{datatype}}", {{/allVars}}) +OpenAPI.property_type(::Type{ {{classname}} }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_{{classname}}[name]))} + +function check_required(o::{{classname}}) +{{#allVars}} +{{#required}} + o.{{{name}}} === nothing && (return false) +{{/required}} +{{/allVars}} + true +end + +function OpenAPI.validate_property(::Type{ {{classname}} }, name::Symbol, val) +{{#allVars}} +{{#isEnum}} + if name === Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}") + OpenAPI.validate_param(name, "{{classname}}", :enum, val, [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]) + end +{{/isEnum}} +{{^isEnum}} +{{#format}} + if name === Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}") + OpenAPI.validate_param(name, "{{classname}}", :format, val, "{{format}}") + end +{{/format}} +{{#hasValidation}} + if name === Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}") +{{#maxLength}} + OpenAPI.validate_param(name, "{{classname}}", :maxLength, val, {{maxLength}}) +{{/maxLength}} +{{#minLength}} + OpenAPI.validate_param(name, "{{classname}}", :minLength, val, {{minLength}}) +{{/minLength}} +{{#maximum}} + OpenAPI.validate_param(name, "{{classname}}", :maximum, val, {{maximum}}, {{#exclusiveMaximum}}true{{/exclusiveMaximum}}{{^exclusiveMaximum}}false{{/exclusiveMaximum}}) +{{/maximum}} +{{#minimum}} + OpenAPI.validate_param(name, "{{classname}}", :minimum, val, {{minimum}}, {{#exclusiveMinimum}}true{{/exclusiveMinimum}}{{^exclusiveMinimum}}false{{/exclusiveMinimum}}) +{{/minimum}} +{{#maxItems}} + OpenAPI.validate_param(name, "{{classname}}", :maxItems, val, {{maxItems}}) +{{/maxItems}} +{{#minItems}} + OpenAPI.validate_param(name, "{{classname}}", :minItems, val, {{minItems}}) +{{/minItems}} +{{#uniqueItems}} + OpenAPI.validate_param(name, "{{classname}}", :uniqueItems, val, {{uniqueItems}}) +{{/uniqueItems}} +{{#maxProperties}} + OpenAPI.validate_param(name, "{{classname}}", :maxProperties, val, {{maxProperties}}) +{{/maxProperties}} +{{#minProperties}} + OpenAPI.validate_param(name, "{{classname}}", :minProperties, val, {{minProperties}}) +{{/minProperties}} +{{#pattern}} + OpenAPI.validate_param(name, "{{classname}}", :pattern, val, r"{{{pattern}}}") +{{/pattern}} +{{#multipleOf}} + OpenAPI.validate_param(name, "{{classname}}", :multipleOf, val, {{multipleOf}}) +{{/multipleOf}} + end +{{/hasValidation}} +{{/isEnum}} +{{/allVars}} +end \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/julia-server/server.mustache b/modules/openapi-generator/src/main/resources/julia-server/server.mustache new file mode 100644 index 00000000000..772539af9f3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/julia-server/server.mustache @@ -0,0 +1,69 @@ +{{>partial_header}} + +@doc raw""" +Encapsulates generated server code for {{packageName}} + +The following server methods must be implemented: + +{{#apiInfo}} +{{#apis}} +{{#operations}} +{{#operation}} +- **{{operationId}}** + - *invocation:* {{httpMethod}} {{path}} + - *signature:* {{operationId}}(req::HTTP.Request{{#allParams}}{{#required}}, {{paramName}}::{{dataType}}{{/required}}{{/allParams}};{{#allParams}}{{^required}} {{paramName}}=nothing,{{/required}}{{/allParams}}) -> {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Nothing{{/returnType}} +{{/operation}} +{{/operations}} +{{/apis}} +{{/apiInfo}} +""" +module {{packageName}} + +using HTTP +using URIs +using Dates +using TimeZones +using OpenAPI +using OpenAPI.Servers + +const API_VERSION = "{{appVersion}}" + +include("modelincludes.jl") +{{#apiInfo}}{{#apis}} +include("apis/api_{{classname}}.jl"){{/apis}}{{/apiInfo}} + +""" +Register handlers for all APIs in this module in the supplied `Router` instance. + +Paramerets: +- `router`: Router to register handlers in +- `impl`: module that implements the server methods + +Optional parameters: +- `path_prefix`: prefix to be applied to all paths +- `optional_middlewares`: Register one or more optional middlewares to be applied to all requests. + +Optional middlewares can be one or more of: + - `init`: called before the request is processed + - `pre_validation`: called after the request is parsed but before validation + - `pre_invoke`: called after validation but before the handler is invoked + - `post_invoke`: called after the handler is invoked but before the response is sent + +The order in which middlewares are invoked are: +`init |> read |> pre_validation |> validate |> pre_invoke |> invoke |> post_invoke` +""" +function register(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...) + {{#apiInfo}} + {{#apis}} + register{{classname}}(router, impl; path_prefix=path_prefix, optional_middlewares...) + {{/apis}} + {{/apiInfo}} + return router +end + +{{#exportModels}} +# export models +{{#models}}{{#model}}export {{classname}} +{{/model}}{{/models}} +{{/exportModels}} +end # module {{packageName}} diff --git a/samples/client/petstore/julia/.openapi-generator-ignore b/samples/client/petstore/julia/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/julia/.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/julia/.openapi-generator/FILES b/samples/client/petstore/julia/.openapi-generator/FILES new file mode 100644 index 00000000000..b9cea9e6f64 --- /dev/null +++ b/samples/client/petstore/julia/.openapi-generator/FILES @@ -0,0 +1,21 @@ +README.md +docs/ApiResponse.md +docs/Category.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/StoreApi.md +docs/Tag.md +docs/User.md +docs/UserApi.md +src/PetStoreClient.jl +src/apis/api_PetApi.jl +src/apis/api_StoreApi.jl +src/apis/api_UserApi.jl +src/modelincludes.jl +src/models/model_ApiResponse.jl +src/models/model_Category.jl +src/models/model_Order.jl +src/models/model_Pet.jl +src/models/model_Tag.jl +src/models/model_User.jl diff --git a/samples/client/petstore/julia/.openapi-generator/VERSION b/samples/client/petstore/julia/.openapi-generator/VERSION new file mode 100644 index 00000000000..d6b4ec4aa78 --- /dev/null +++ b/samples/client/petstore/julia/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/julia/README.md b/samples/client/petstore/julia/README.md new file mode 100644 index 00000000000..3509f49b937 --- /dev/null +++ b/samples/client/petstore/julia/README.md @@ -0,0 +1,91 @@ +# Julia API client for PetStoreClient + +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://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Build package: org.openapitools.codegen.languages.JuliaClientCodegen + + +## Installation +Place the Julia files generated under the `src` folder in your Julia project. Include PetStoreClient.jl in the project code. +It would include the module named PetStoreClient. + +Documentation is generated as markdown files under the `docs` folder. You can include them in your project documentation. +Documentation is also embedded in Julia which can be used with a Julia specific documentation generator. + +## API Endpoints + +Class | Method +------------ | ------------- +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet)
**POST** /pet
Add a new pet to the store +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet)
**DELETE** /pet/{petId}
Deletes a pet +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status)
**GET** /pet/findByStatus
Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags)
**GET** /pet/findByTags
Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id)
**GET** /pet/{petId}
Find pet by ID +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet)
**PUT** /pet
Update an existing pet +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form)
**POST** /pet/{petId}
Updates a pet in the store with form data +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file)
**POST** /pet/{petId}/uploadImage
uploads an image +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order)
**DELETE** /store/order/{orderId}
Delete purchase order by ID +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory)
**GET** /store/inventory
Returns pet inventories by status +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id)
**GET** /store/order/{orderId}
Find purchase order by ID +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order)
**POST** /store/order
Place an order for a pet +*UserApi* | [**create_user**](docs/UserApi.md#create_user)
**POST** /user
Create user +*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input)
**POST** /user/createWithArray
Creates list of users with given input array +*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input)
**POST** /user/createWithList
Creates list of users with given input array +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user)
**DELETE** /user/{username}
Delete user +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name)
**GET** /user/{username}
Get user by user name +*UserApi* | [**login_user**](docs/UserApi.md#login_user)
**GET** /user/login
Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user)
**GET** /user/logout
Logs out current logged in user session +*UserApi* | [**update_user**](docs/UserApi.md#update_user)
**PUT** /user/{username}
Updated user + + +## Models + + - [ApiResponse](docs/ApiResponse.md) + - [Category](docs/Category.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + +## Authorization + +## api_key +- **Type**: API key + +Example +``` + using OpenAPI + using OpenAPI.Clients + import OpenAPI.Clients: Client + client = Client(server_uri) + api = MyApi(client) + result = callApi(api, args...; api_key) +``` +## 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 + +Example +``` + using OpenAPI + using OpenAPI.Clients + import OpenAPI.Clients: Client, set_header + client = Client(server_uri) + set_header(client, "Authorization", "Bearer $bearer_auth") + api = MyApi(client) + result = callApi(api, args...; api_key) +``` + +## Author + + + diff --git a/samples/client/petstore/julia/docs/ApiResponse.md b/samples/client/petstore/julia/docs/ApiResponse.md new file mode 100644 index 00000000000..664dd2452f3 --- /dev/null +++ b/samples/client/petstore/julia/docs/ApiResponse.md @@ -0,0 +1,14 @@ +# ApiResponse + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Int64** | | [optional] [default to nothing] +**type** | **String** | | [optional] [default to nothing] +**message** | **String** | | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/julia/docs/Category.md b/samples/client/petstore/julia/docs/Category.md new file mode 100644 index 00000000000..4e932906e78 --- /dev/null +++ b/samples/client/petstore/julia/docs/Category.md @@ -0,0 +1,13 @@ +# Category + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**name** | **String** | | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/julia/docs/Order.md b/samples/client/petstore/julia/docs/Order.md new file mode 100644 index 00000000000..b815c052612 --- /dev/null +++ b/samples/client/petstore/julia/docs/Order.md @@ -0,0 +1,17 @@ +# Order + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**petId** | **Int64** | | [optional] [default to nothing] +**quantity** | **Int64** | | [optional] [default to nothing] +**shipDate** | **ZonedDateTime** | | [optional] [default to nothing] +**status** | **String** | Order Status | [optional] [default to nothing] +**complete** | **Bool** | | [optional] [default to false] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/julia/docs/Pet.md b/samples/client/petstore/julia/docs/Pet.md new file mode 100644 index 00000000000..a8bba4c8932 --- /dev/null +++ b/samples/client/petstore/julia/docs/Pet.md @@ -0,0 +1,17 @@ +# Pet + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**category** | [***Category**](Category.md) | | [optional] [default to nothing] +**name** | **String** | | [default to nothing] +**photoUrls** | **Vector{String}** | | [default to nothing] +**tags** | [**Vector{Tag}**](Tag.md) | | [optional] [default to nothing] +**status** | **String** | pet status in the store | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/julia/docs/PetApi.md b/samples/client/petstore/julia/docs/PetApi.md new file mode 100644 index 00000000000..c69569218bb --- /dev/null +++ b/samples/client/petstore/julia/docs/PetApi.md @@ -0,0 +1,276 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **add_pet** +> add_pet(_api::PetApi, pet::Pet; _mediaType=nothing) -> Pet, OpenAPI.Clients.ApiResponse
+> add_pet(_api::PetApi, response_stream::Channel, pet::Pet; _mediaType=nothing) -> Channel{ Pet }, OpenAPI.Clients.ApiResponse + +Add a new pet to the store + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **PetApi** | API context | +**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **delete_pet** +> delete_pet(_api::PetApi, pet_id::Int64; api_key=nothing, _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> delete_pet(_api::PetApi, response_stream::Channel, pet_id::Int64; api_key=nothing, _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse + +Deletes a pet + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **PetApi** | API context | +**pet_id** | **Int64**| Pet id to delete | [default to nothing] + +### Optional Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **api_key** | **String**| | [default to nothing] + +### Return type + +Nothing + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **find_pets_by_status** +> find_pets_by_status(_api::PetApi, status::Vector{String}; _mediaType=nothing) -> Vector{Pet}, OpenAPI.Clients.ApiResponse
+> find_pets_by_status(_api::PetApi, response_stream::Channel, status::Vector{String}; _mediaType=nothing) -> Channel{ Vector{Pet} }, OpenAPI.Clients.ApiResponse + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **PetApi** | API context | +**status** | [**Vector{String}**](String.md)| Status values that need to be considered for filter | [default to nothing] + +### Return type + +[**Vector{Pet}**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **find_pets_by_tags** +> find_pets_by_tags(_api::PetApi, tags::Vector{String}; _mediaType=nothing) -> Vector{Pet}, OpenAPI.Clients.ApiResponse
+> find_pets_by_tags(_api::PetApi, response_stream::Channel, tags::Vector{String}; _mediaType=nothing) -> Channel{ Vector{Pet} }, OpenAPI.Clients.ApiResponse + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **PetApi** | API context | +**tags** | [**Vector{String}**](String.md)| Tags to filter by | [default to nothing] + +### Return type + +[**Vector{Pet}**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **get_pet_by_id** +> get_pet_by_id(_api::PetApi, pet_id::Int64; _mediaType=nothing) -> Pet, OpenAPI.Clients.ApiResponse
+> get_pet_by_id(_api::PetApi, response_stream::Channel, pet_id::Int64; _mediaType=nothing) -> Channel{ Pet }, OpenAPI.Clients.ApiResponse + +Find pet by ID + +Returns a single pet + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **PetApi** | API context | +**pet_id** | **Int64**| ID of pet to return | [default to nothing] + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **update_pet** +> update_pet(_api::PetApi, pet::Pet; _mediaType=nothing) -> Pet, OpenAPI.Clients.ApiResponse
+> update_pet(_api::PetApi, response_stream::Channel, pet::Pet; _mediaType=nothing) -> Channel{ Pet }, OpenAPI.Clients.ApiResponse + +Update an existing pet + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **PetApi** | API context | +**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **update_pet_with_form** +> update_pet_with_form(_api::PetApi, pet_id::Int64; name=nothing, status=nothing, _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> update_pet_with_form(_api::PetApi, response_stream::Channel, pet_id::Int64; name=nothing, status=nothing, _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse + +Updates a pet in the store with form data + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **PetApi** | API context | +**pet_id** | **Int64**| ID of pet that needs to be updated | [default to nothing] + +### Optional Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **name** | **String**| Updated name of the pet | [default to nothing] + **status** | **String**| Updated status of the pet | [default to nothing] + +### Return type + +Nothing + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **upload_file** +> upload_file(_api::PetApi, pet_id::Int64; additional_metadata=nothing, file=nothing, _mediaType=nothing) -> ApiResponse, OpenAPI.Clients.ApiResponse
+> upload_file(_api::PetApi, response_stream::Channel, pet_id::Int64; additional_metadata=nothing, file=nothing, _mediaType=nothing) -> Channel{ ApiResponse }, OpenAPI.Clients.ApiResponse + +uploads an image + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **PetApi** | API context | +**pet_id** | **Int64**| ID of pet to update | [default to nothing] + +### Optional Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **additional_metadata** | **String**| Additional data to pass to server | [default to nothing] + **file** | **String****String**| file to upload | [default to nothing] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/julia/docs/StoreApi.md b/samples/client/petstore/julia/docs/StoreApi.md new file mode 100644 index 00000000000..236fd2c8b8c --- /dev/null +++ b/samples/client/petstore/julia/docs/StoreApi.md @@ -0,0 +1,128 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order(_api::StoreApi, order_id::String; _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> delete_order(_api::StoreApi, response_stream::Channel, order_id::String; _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **StoreApi** | API context | +**order_id** | **String**| ID of the order that needs to be deleted | [default to nothing] + +### Return type + +Nothing + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **get_inventory** +> get_inventory(_api::StoreApi; _mediaType=nothing) -> Dict{String, Int64}, OpenAPI.Clients.ApiResponse
+> get_inventory(_api::StoreApi, response_stream::Channel; _mediaType=nothing) -> Channel{ Dict{String, Int64} }, OpenAPI.Clients.ApiResponse + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +**Dict{String, Int64}** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **get_order_by_id** +> get_order_by_id(_api::StoreApi, order_id::Int64; _mediaType=nothing) -> Order, OpenAPI.Clients.ApiResponse
+> get_order_by_id(_api::StoreApi, response_stream::Channel, order_id::Int64; _mediaType=nothing) -> Channel{ Order }, OpenAPI.Clients.ApiResponse + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **StoreApi** | API context | +**order_id** | **Int64**| ID of pet that needs to be fetched | [default to nothing] + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **place_order** +> place_order(_api::StoreApi, order::Order; _mediaType=nothing) -> Order, OpenAPI.Clients.ApiResponse
+> place_order(_api::StoreApi, response_stream::Channel, order::Order; _mediaType=nothing) -> Channel{ Order }, OpenAPI.Clients.ApiResponse + +Place an order for a pet + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **StoreApi** | API context | +**order** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/julia/docs/Tag.md b/samples/client/petstore/julia/docs/Tag.md new file mode 100644 index 00000000000..c904872204a --- /dev/null +++ b/samples/client/petstore/julia/docs/Tag.md @@ -0,0 +1,13 @@ +# Tag + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**name** | **String** | | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/julia/docs/User.md b/samples/client/petstore/julia/docs/User.md new file mode 100644 index 00000000000..5318b5a2f86 --- /dev/null +++ b/samples/client/petstore/julia/docs/User.md @@ -0,0 +1,19 @@ +# User + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**username** | **String** | | [optional] [default to nothing] +**firstName** | **String** | | [optional] [default to nothing] +**lastName** | **String** | | [optional] [default to nothing] +**email** | **String** | | [optional] [default to nothing] +**password** | **String** | | [optional] [default to nothing] +**phone** | **String** | | [optional] [default to nothing] +**userStatus** | **Int64** | User Status | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/julia/docs/UserApi.md b/samples/client/petstore/julia/docs/UserApi.md new file mode 100644 index 00000000000..0c96ed5b359 --- /dev/null +++ b/samples/client/petstore/julia/docs/UserApi.md @@ -0,0 +1,254 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(_api::UserApi, user::User; _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> create_user(_api::UserApi, response_stream::Channel, user::User; _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse + +Create user + +This can only be done by the logged in user. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **UserApi** | API context | +**user** | [**User**](User.md)| Created user object | + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **create_users_with_array_input** +> create_users_with_array_input(_api::UserApi, user::Vector{User}; _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> create_users_with_array_input(_api::UserApi, response_stream::Channel, user::Vector{User}; _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse + +Creates list of users with given input array + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **UserApi** | API context | +**user** | [**Vector{User}**](User.md)| List of user object | + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **create_users_with_list_input** +> create_users_with_list_input(_api::UserApi, user::Vector{User}; _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> create_users_with_list_input(_api::UserApi, response_stream::Channel, user::Vector{User}; _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse + +Creates list of users with given input array + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **UserApi** | API context | +**user** | [**Vector{User}**](User.md)| List of user object | + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **delete_user** +> delete_user(_api::UserApi, username::String; _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> delete_user(_api::UserApi, response_stream::Channel, username::String; _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse + +Delete user + +This can only be done by the logged in user. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **UserApi** | API context | +**username** | **String**| The name that needs to be deleted | [default to nothing] + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **get_user_by_name** +> get_user_by_name(_api::UserApi, username::String; _mediaType=nothing) -> User, OpenAPI.Clients.ApiResponse
+> get_user_by_name(_api::UserApi, response_stream::Channel, username::String; _mediaType=nothing) -> Channel{ User }, OpenAPI.Clients.ApiResponse + +Get user by user name + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **UserApi** | API context | +**username** | **String**| The name that needs to be fetched. Use user1 for testing. | [default to nothing] + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **login_user** +> login_user(_api::UserApi, username::String, password::String; _mediaType=nothing) -> String, OpenAPI.Clients.ApiResponse
+> login_user(_api::UserApi, response_stream::Channel, username::String, password::String; _mediaType=nothing) -> Channel{ String }, OpenAPI.Clients.ApiResponse + +Logs user into the system + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **UserApi** | API context | +**username** | **String**| The user name for login | [default to nothing] +**password** | **String**| The password for login in clear text | [default to nothing] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **logout_user** +> logout_user(_api::UserApi; _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> logout_user(_api::UserApi, response_stream::Channel; _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse + +Logs out current logged in user session + + + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + +# **update_user** +> update_user(_api::UserApi, username::String, user::User; _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> update_user(_api::UserApi, response_stream::Channel, username::String, user::User; _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse + +Updated user + +This can only be done by the logged in user. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_api** | **UserApi** | API context | +**username** | **String**| name that need to be deleted | [default to nothing] +**user** | [**User**](User.md)| Updated user object | + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/julia/src/PetStoreClient.jl b/samples/client/petstore/julia/src/PetStoreClient.jl new file mode 100644 index 00000000000..1a427c742ef --- /dev/null +++ b/samples/client/petstore/julia/src/PetStoreClient.jl @@ -0,0 +1,18 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + +module PetStoreClient + +using Dates, TimeZones +using OpenAPI +using OpenAPI.Clients + +const API_VERSION = "1.0.0" + +include("modelincludes.jl") + +include("apis/api_PetApi.jl") +include("apis/api_StoreApi.jl") +include("apis/api_UserApi.jl") + +end # module PetStoreClient diff --git a/samples/client/petstore/julia/src/apis/api_PetApi.jl b/samples/client/petstore/julia/src/apis/api_PetApi.jl new file mode 100644 index 00000000000..49990a82e1d --- /dev/null +++ b/samples/client/petstore/julia/src/apis/api_PetApi.jl @@ -0,0 +1,285 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + +struct PetApi <: OpenAPI.APIClientImpl + client::OpenAPI.Clients.Client +end + +""" +The default API base path for APIs in `PetApi`. +This can be used to construct the `OpenAPI.Clients.Client` instance. +""" +basepath(::Type{ PetApi }) = "http://petstore.swagger.io/v2" + +const _returntypes_add_pet_PetApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => Pet, + Regex("^" * replace("405", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_add_pet(_api::PetApi, pet::Pet; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_add_pet_PetApi, "/pet", ["petstore_auth", ], pet) + OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", "application/xml", ] : [_mediaType]) + return _ctx +end + +@doc raw"""Add a new pet to the store + + + +Params: +- pet::Pet (required) + +Return: Pet, OpenAPI.Clients.ApiResponse +""" +function add_pet(_api::PetApi, pet::Pet; _mediaType=nothing) + _ctx = _oacinternal_add_pet(_api, pet; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function add_pet(_api::PetApi, response_stream::Channel, pet::Pet; _mediaType=nothing) + _ctx = _oacinternal_add_pet(_api, pet; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_delete_pet_PetApi = Dict{Regex,Type}( + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_delete_pet(_api::PetApi, pet_id::Int64; api_key=nothing, _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "DELETE", _returntypes_delete_pet_PetApi, "/pet/{petId}", ["petstore_auth", ]) + OpenAPI.Clients.set_param(_ctx.path, "petId", pet_id) # type Int64 + OpenAPI.Clients.set_param(_ctx.header, "api_key", api_key) # type String + OpenAPI.Clients.set_header_accept(_ctx, []) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Deletes a pet + + + +Params: +- pet_id::Int64 (required) +- api_key::String + +Return: Nothing, OpenAPI.Clients.ApiResponse +""" +function delete_pet(_api::PetApi, pet_id::Int64; api_key=nothing, _mediaType=nothing) + _ctx = _oacinternal_delete_pet(_api, pet_id; api_key=api_key, _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function delete_pet(_api::PetApi, response_stream::Channel, pet_id::Int64; api_key=nothing, _mediaType=nothing) + _ctx = _oacinternal_delete_pet(_api, pet_id; api_key=api_key, _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_find_pets_by_status_PetApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => Vector{Pet}, + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_find_pets_by_status(_api::PetApi, status::Vector{String}; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_find_pets_by_status_PetApi, "/pet/findByStatus", ["petstore_auth", ]) + OpenAPI.Clients.set_param(_ctx.query, "status", status) # type Vector{String} + OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Finds Pets by status + +Multiple status values can be provided with comma separated strings + +Params: +- status::Vector{String} (required) + +Return: Vector{Pet}, OpenAPI.Clients.ApiResponse +""" +function find_pets_by_status(_api::PetApi, status::Vector{String}; _mediaType=nothing) + _ctx = _oacinternal_find_pets_by_status(_api, status; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function find_pets_by_status(_api::PetApi, response_stream::Channel, status::Vector{String}; _mediaType=nothing) + _ctx = _oacinternal_find_pets_by_status(_api, status; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_find_pets_by_tags_PetApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => Vector{Pet}, + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_find_pets_by_tags(_api::PetApi, tags::Vector{String}; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_find_pets_by_tags_PetApi, "/pet/findByTags", ["petstore_auth", ]) + OpenAPI.Clients.set_param(_ctx.query, "tags", tags) # type Vector{String} + OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +Params: +- tags::Vector{String} (required) + +Return: Vector{Pet}, OpenAPI.Clients.ApiResponse +""" +function find_pets_by_tags(_api::PetApi, tags::Vector{String}; _mediaType=nothing) + _ctx = _oacinternal_find_pets_by_tags(_api, tags; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function find_pets_by_tags(_api::PetApi, response_stream::Channel, tags::Vector{String}; _mediaType=nothing) + _ctx = _oacinternal_find_pets_by_tags(_api, tags; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_get_pet_by_id_PetApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => Pet, + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, + Regex("^" * replace("404", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_get_pet_by_id(_api::PetApi, pet_id::Int64; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_get_pet_by_id_PetApi, "/pet/{petId}", ["api_key", ]) + OpenAPI.Clients.set_param(_ctx.path, "petId", pet_id) # type Int64 + OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Find pet by ID + +Returns a single pet + +Params: +- pet_id::Int64 (required) + +Return: Pet, OpenAPI.Clients.ApiResponse +""" +function get_pet_by_id(_api::PetApi, pet_id::Int64; _mediaType=nothing) + _ctx = _oacinternal_get_pet_by_id(_api, pet_id; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function get_pet_by_id(_api::PetApi, response_stream::Channel, pet_id::Int64; _mediaType=nothing) + _ctx = _oacinternal_get_pet_by_id(_api, pet_id; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_update_pet_PetApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => Pet, + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, + Regex("^" * replace("404", "x"=>".") * "\$") => Nothing, + Regex("^" * replace("405", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_update_pet(_api::PetApi, pet::Pet; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "PUT", _returntypes_update_pet_PetApi, "/pet", ["petstore_auth", ], pet) + OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", "application/xml", ] : [_mediaType]) + return _ctx +end + +@doc raw"""Update an existing pet + + + +Params: +- pet::Pet (required) + +Return: Pet, OpenAPI.Clients.ApiResponse +""" +function update_pet(_api::PetApi, pet::Pet; _mediaType=nothing) + _ctx = _oacinternal_update_pet(_api, pet; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function update_pet(_api::PetApi, response_stream::Channel, pet::Pet; _mediaType=nothing) + _ctx = _oacinternal_update_pet(_api, pet; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_update_pet_with_form_PetApi = Dict{Regex,Type}( + Regex("^" * replace("405", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_update_pet_with_form(_api::PetApi, pet_id::Int64; name=nothing, status=nothing, _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_update_pet_with_form_PetApi, "/pet/{petId}", ["petstore_auth", ]) + OpenAPI.Clients.set_param(_ctx.path, "petId", pet_id) # type Int64 + OpenAPI.Clients.set_param(_ctx.form, "name", name) # type String + OpenAPI.Clients.set_param(_ctx.form, "status", status) # type String + OpenAPI.Clients.set_header_accept(_ctx, []) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/x-www-form-urlencoded", ] : [_mediaType]) + return _ctx +end + +@doc raw"""Updates a pet in the store with form data + + + +Params: +- pet_id::Int64 (required) +- name::String +- status::String + +Return: Nothing, OpenAPI.Clients.ApiResponse +""" +function update_pet_with_form(_api::PetApi, pet_id::Int64; name=nothing, status=nothing, _mediaType=nothing) + _ctx = _oacinternal_update_pet_with_form(_api, pet_id; name=name, status=status, _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function update_pet_with_form(_api::PetApi, response_stream::Channel, pet_id::Int64; name=nothing, status=nothing, _mediaType=nothing) + _ctx = _oacinternal_update_pet_with_form(_api, pet_id; name=name, status=status, _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_upload_file_PetApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => ApiResponse, +) + +function _oacinternal_upload_file(_api::PetApi, pet_id::Int64; additional_metadata=nothing, file=nothing, _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_upload_file_PetApi, "/pet/{petId}/uploadImage", ["petstore_auth", ]) + OpenAPI.Clients.set_param(_ctx.path, "petId", pet_id) # type Int64 + OpenAPI.Clients.set_param(_ctx.form, "additionalMetadata", additional_metadata) # type String + OpenAPI.Clients.set_param(_ctx.file, "file", file) # type String + OpenAPI.Clients.set_header_accept(_ctx, ["application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["multipart/form-data", ] : [_mediaType]) + return _ctx +end + +@doc raw"""uploads an image + + + +Params: +- pet_id::Int64 (required) +- additional_metadata::String +- file::String + +Return: ApiResponse, OpenAPI.Clients.ApiResponse +""" +function upload_file(_api::PetApi, pet_id::Int64; additional_metadata=nothing, file=nothing, _mediaType=nothing) + _ctx = _oacinternal_upload_file(_api, pet_id; additional_metadata=additional_metadata, file=file, _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function upload_file(_api::PetApi, response_stream::Channel, pet_id::Int64; additional_metadata=nothing, file=nothing, _mediaType=nothing) + _ctx = _oacinternal_upload_file(_api, pet_id; additional_metadata=additional_metadata, file=file, _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +export add_pet +export delete_pet +export find_pets_by_status +export find_pets_by_tags +export get_pet_by_id +export update_pet +export update_pet_with_form +export upload_file diff --git a/samples/client/petstore/julia/src/apis/api_StoreApi.jl b/samples/client/petstore/julia/src/apis/api_StoreApi.jl new file mode 100644 index 00000000000..da58972f762 --- /dev/null +++ b/samples/client/petstore/julia/src/apis/api_StoreApi.jl @@ -0,0 +1,145 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + +struct StoreApi <: OpenAPI.APIClientImpl + client::OpenAPI.Clients.Client +end + +""" +The default API base path for APIs in `StoreApi`. +This can be used to construct the `OpenAPI.Clients.Client` instance. +""" +basepath(::Type{ StoreApi }) = "http://petstore.swagger.io/v2" + +const _returntypes_delete_order_StoreApi = Dict{Regex,Type}( + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, + Regex("^" * replace("404", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_delete_order(_api::StoreApi, order_id::String; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "DELETE", _returntypes_delete_order_StoreApi, "/store/order/{orderId}", []) + OpenAPI.Clients.set_param(_ctx.path, "orderId", order_id) # type String + OpenAPI.Clients.set_header_accept(_ctx, []) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +Params: +- order_id::String (required) + +Return: Nothing, OpenAPI.Clients.ApiResponse +""" +function delete_order(_api::StoreApi, order_id::String; _mediaType=nothing) + _ctx = _oacinternal_delete_order(_api, order_id; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function delete_order(_api::StoreApi, response_stream::Channel, order_id::String; _mediaType=nothing) + _ctx = _oacinternal_delete_order(_api, order_id; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_get_inventory_StoreApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => Dict{String, Int64}, +) + +function _oacinternal_get_inventory(_api::StoreApi; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_get_inventory_StoreApi, "/store/inventory", ["api_key", ]) + OpenAPI.Clients.set_header_accept(_ctx, ["application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Returns pet inventories by status + +Returns a map of status codes to quantities + +Params: + +Return: Dict{String, Int64}, OpenAPI.Clients.ApiResponse +""" +function get_inventory(_api::StoreApi; _mediaType=nothing) + _ctx = _oacinternal_get_inventory(_api; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function get_inventory(_api::StoreApi, response_stream::Channel; _mediaType=nothing) + _ctx = _oacinternal_get_inventory(_api; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_get_order_by_id_StoreApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => Order, + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, + Regex("^" * replace("404", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_get_order_by_id(_api::StoreApi, order_id::Int64; _mediaType=nothing) + OpenAPI.validate_param("order_id", "get_order_by_id", :maximum, order_id, 5, false) + OpenAPI.validate_param("order_id", "get_order_by_id", :minimum, order_id, 1, false) + + _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_get_order_by_id_StoreApi, "/store/order/{orderId}", []) + OpenAPI.Clients.set_param(_ctx.path, "orderId", order_id) # type Int64 + OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +Params: +- order_id::Int64 (required) + +Return: Order, OpenAPI.Clients.ApiResponse +""" +function get_order_by_id(_api::StoreApi, order_id::Int64; _mediaType=nothing) + _ctx = _oacinternal_get_order_by_id(_api, order_id; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function get_order_by_id(_api::StoreApi, response_stream::Channel, order_id::Int64; _mediaType=nothing) + _ctx = _oacinternal_get_order_by_id(_api, order_id; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_place_order_StoreApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => Order, + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_place_order(_api::StoreApi, order::Order; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_place_order_StoreApi, "/store/order", [], order) + OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", ] : [_mediaType]) + return _ctx +end + +@doc raw"""Place an order for a pet + + + +Params: +- order::Order (required) + +Return: Order, OpenAPI.Clients.ApiResponse +""" +function place_order(_api::StoreApi, order::Order; _mediaType=nothing) + _ctx = _oacinternal_place_order(_api, order; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function place_order(_api::StoreApi, response_stream::Channel, order::Order; _mediaType=nothing) + _ctx = _oacinternal_place_order(_api, order; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +export delete_order +export get_inventory +export get_order_by_id +export place_order diff --git a/samples/client/petstore/julia/src/apis/api_UserApi.jl b/samples/client/petstore/julia/src/apis/api_UserApi.jl new file mode 100644 index 00000000000..63e0df193ae --- /dev/null +++ b/samples/client/petstore/julia/src/apis/api_UserApi.jl @@ -0,0 +1,273 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + +struct UserApi <: OpenAPI.APIClientImpl + client::OpenAPI.Clients.Client +end + +""" +The default API base path for APIs in `UserApi`. +This can be used to construct the `OpenAPI.Clients.Client` instance. +""" +basepath(::Type{ UserApi }) = "http://petstore.swagger.io/v2" + +const _returntypes_create_user_UserApi = Dict{Regex,Type}( + Regex("^" * replace("0", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_create_user(_api::UserApi, user::User; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_create_user_UserApi, "/user", ["api_key", ], user) + OpenAPI.Clients.set_header_accept(_ctx, []) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", ] : [_mediaType]) + return _ctx +end + +@doc raw"""Create user + +This can only be done by the logged in user. + +Params: +- user::User (required) + +Return: Nothing, OpenAPI.Clients.ApiResponse +""" +function create_user(_api::UserApi, user::User; _mediaType=nothing) + _ctx = _oacinternal_create_user(_api, user; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function create_user(_api::UserApi, response_stream::Channel, user::User; _mediaType=nothing) + _ctx = _oacinternal_create_user(_api, user; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_create_users_with_array_input_UserApi = Dict{Regex,Type}( + Regex("^" * replace("0", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_create_users_with_array_input(_api::UserApi, user::Vector{User}; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_create_users_with_array_input_UserApi, "/user/createWithArray", ["api_key", ], user) + OpenAPI.Clients.set_header_accept(_ctx, []) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", ] : [_mediaType]) + return _ctx +end + +@doc raw"""Creates list of users with given input array + + + +Params: +- user::Vector{User} (required) + +Return: Nothing, OpenAPI.Clients.ApiResponse +""" +function create_users_with_array_input(_api::UserApi, user::Vector{User}; _mediaType=nothing) + _ctx = _oacinternal_create_users_with_array_input(_api, user; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function create_users_with_array_input(_api::UserApi, response_stream::Channel, user::Vector{User}; _mediaType=nothing) + _ctx = _oacinternal_create_users_with_array_input(_api, user; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_create_users_with_list_input_UserApi = Dict{Regex,Type}( + Regex("^" * replace("0", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_create_users_with_list_input(_api::UserApi, user::Vector{User}; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_create_users_with_list_input_UserApi, "/user/createWithList", ["api_key", ], user) + OpenAPI.Clients.set_header_accept(_ctx, []) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", ] : [_mediaType]) + return _ctx +end + +@doc raw"""Creates list of users with given input array + + + +Params: +- user::Vector{User} (required) + +Return: Nothing, OpenAPI.Clients.ApiResponse +""" +function create_users_with_list_input(_api::UserApi, user::Vector{User}; _mediaType=nothing) + _ctx = _oacinternal_create_users_with_list_input(_api, user; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function create_users_with_list_input(_api::UserApi, response_stream::Channel, user::Vector{User}; _mediaType=nothing) + _ctx = _oacinternal_create_users_with_list_input(_api, user; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_delete_user_UserApi = Dict{Regex,Type}( + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, + Regex("^" * replace("404", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_delete_user(_api::UserApi, username::String; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "DELETE", _returntypes_delete_user_UserApi, "/user/{username}", ["api_key", ]) + OpenAPI.Clients.set_param(_ctx.path, "username", username) # type String + OpenAPI.Clients.set_header_accept(_ctx, []) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Delete user + +This can only be done by the logged in user. + +Params: +- username::String (required) + +Return: Nothing, OpenAPI.Clients.ApiResponse +""" +function delete_user(_api::UserApi, username::String; _mediaType=nothing) + _ctx = _oacinternal_delete_user(_api, username; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function delete_user(_api::UserApi, response_stream::Channel, username::String; _mediaType=nothing) + _ctx = _oacinternal_delete_user(_api, username; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_get_user_by_name_UserApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => User, + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, + Regex("^" * replace("404", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_get_user_by_name(_api::UserApi, username::String; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_get_user_by_name_UserApi, "/user/{username}", []) + OpenAPI.Clients.set_param(_ctx.path, "username", username) # type String + OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Get user by user name + + + +Params: +- username::String (required) + +Return: User, OpenAPI.Clients.ApiResponse +""" +function get_user_by_name(_api::UserApi, username::String; _mediaType=nothing) + _ctx = _oacinternal_get_user_by_name(_api, username; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function get_user_by_name(_api::UserApi, response_stream::Channel, username::String; _mediaType=nothing) + _ctx = _oacinternal_get_user_by_name(_api, username; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_login_user_UserApi = Dict{Regex,Type}( + Regex("^" * replace("200", "x"=>".") * "\$") => String, + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_login_user(_api::UserApi, username::String, password::String; _mediaType=nothing) + + _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_login_user_UserApi, "/user/login", []) + OpenAPI.Clients.set_param(_ctx.query, "username", username) # type String + OpenAPI.Clients.set_param(_ctx.query, "password", password) # type String + OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ]) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Logs user into the system + + + +Params: +- username::String (required) +- password::String (required) + +Return: String, OpenAPI.Clients.ApiResponse +""" +function login_user(_api::UserApi, username::String, password::String; _mediaType=nothing) + _ctx = _oacinternal_login_user(_api, username, password; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function login_user(_api::UserApi, response_stream::Channel, username::String, password::String; _mediaType=nothing) + _ctx = _oacinternal_login_user(_api, username, password; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_logout_user_UserApi = Dict{Regex,Type}( + Regex("^" * replace("0", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_logout_user(_api::UserApi; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_logout_user_UserApi, "/user/logout", ["api_key", ]) + OpenAPI.Clients.set_header_accept(_ctx, []) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType]) + return _ctx +end + +@doc raw"""Logs out current logged in user session + + + +Params: + +Return: Nothing, OpenAPI.Clients.ApiResponse +""" +function logout_user(_api::UserApi; _mediaType=nothing) + _ctx = _oacinternal_logout_user(_api; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function logout_user(_api::UserApi, response_stream::Channel; _mediaType=nothing) + _ctx = _oacinternal_logout_user(_api; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +const _returntypes_update_user_UserApi = Dict{Regex,Type}( + Regex("^" * replace("400", "x"=>".") * "\$") => Nothing, + Regex("^" * replace("404", "x"=>".") * "\$") => Nothing, +) + +function _oacinternal_update_user(_api::UserApi, username::String, user::User; _mediaType=nothing) + _ctx = OpenAPI.Clients.Ctx(_api.client, "PUT", _returntypes_update_user_UserApi, "/user/{username}", ["api_key", ], user) + OpenAPI.Clients.set_param(_ctx.path, "username", username) # type String + OpenAPI.Clients.set_header_accept(_ctx, []) + OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", ] : [_mediaType]) + return _ctx +end + +@doc raw"""Updated user + +This can only be done by the logged in user. + +Params: +- username::String (required) +- user::User (required) + +Return: Nothing, OpenAPI.Clients.ApiResponse +""" +function update_user(_api::UserApi, username::String, user::User; _mediaType=nothing) + _ctx = _oacinternal_update_user(_api, username, user; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx) +end + +function update_user(_api::UserApi, response_stream::Channel, username::String, user::User; _mediaType=nothing) + _ctx = _oacinternal_update_user(_api, username, user; _mediaType=_mediaType) + return OpenAPI.Clients.exec(_ctx, response_stream) +end + +export create_user +export create_users_with_array_input +export create_users_with_list_input +export delete_user +export get_user_by_name +export login_user +export logout_user +export update_user diff --git a/samples/client/petstore/julia/src/modelincludes.jl b/samples/client/petstore/julia/src/modelincludes.jl new file mode 100644 index 00000000000..b3a3db84f30 --- /dev/null +++ b/samples/client/petstore/julia/src/modelincludes.jl @@ -0,0 +1,9 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + +include("models/model_ApiResponse.jl") +include("models/model_Category.jl") +include("models/model_Order.jl") +include("models/model_Pet.jl") +include("models/model_Tag.jl") +include("models/model_User.jl") diff --git a/samples/client/petstore/julia/src/models/model_ApiResponse.jl b/samples/client/petstore/julia/src/models/model_ApiResponse.jl new file mode 100644 index 00000000000..107fab6677f --- /dev/null +++ b/samples/client/petstore/julia/src/models/model_ApiResponse.jl @@ -0,0 +1,42 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""ApiResponse +Describes the result of uploading an image resource + + ApiResponse(; + code=nothing, + type=nothing, + message=nothing, + ) + + - code::Int64 + - type::String + - message::String +""" +Base.@kwdef mutable struct ApiResponse <: OpenAPI.APIModel + code::Union{Nothing, Int64} = nothing + type::Union{Nothing, String} = nothing + message::Union{Nothing, String} = nothing + + function ApiResponse(code, type, message, ) + OpenAPI.validate_property(ApiResponse, Symbol("code"), code) + OpenAPI.validate_property(ApiResponse, Symbol("type"), type) + OpenAPI.validate_property(ApiResponse, Symbol("message"), message) + return new(code, type, message, ) + end +end # type ApiResponse + +const _property_types_ApiResponse = Dict{Symbol,String}(Symbol("code")=>"Int64", Symbol("type")=>"String", Symbol("message")=>"String", ) +OpenAPI.property_type(::Type{ ApiResponse }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_ApiResponse[name]))} + +function check_required(o::ApiResponse) + true +end + +function OpenAPI.validate_property(::Type{ ApiResponse }, name::Symbol, val) + if name === Symbol("code") + OpenAPI.validate_param(name, "ApiResponse", :format, val, "int32") + end +end diff --git a/samples/client/petstore/julia/src/models/model_Category.jl b/samples/client/petstore/julia/src/models/model_Category.jl new file mode 100644 index 00000000000..bd583ab337c --- /dev/null +++ b/samples/client/petstore/julia/src/models/model_Category.jl @@ -0,0 +1,41 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""Category +A category for a pet + + Category(; + id=nothing, + name=nothing, + ) + + - id::Int64 + - name::String +""" +Base.@kwdef mutable struct Category <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + name::Union{Nothing, String} = nothing + + function Category(id, name, ) + OpenAPI.validate_property(Category, Symbol("id"), id) + OpenAPI.validate_property(Category, Symbol("name"), name) + return new(id, name, ) + end +end # type Category + +const _property_types_Category = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("name")=>"String", ) +OpenAPI.property_type(::Type{ Category }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_Category[name]))} + +function check_required(o::Category) + true +end + +function OpenAPI.validate_property(::Type{ Category }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "Category", :format, val, "int64") + end + if name === Symbol("name") + OpenAPI.validate_param(name, "Category", :pattern, val, r"^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$") + end +end diff --git a/samples/client/petstore/julia/src/models/model_Order.jl b/samples/client/petstore/julia/src/models/model_Order.jl new file mode 100644 index 00000000000..9443890b17b --- /dev/null +++ b/samples/client/petstore/julia/src/models/model_Order.jl @@ -0,0 +1,66 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""Order +An order for a pets from the pet store + + Order(; + id=nothing, + petId=nothing, + quantity=nothing, + shipDate=nothing, + status=nothing, + complete=false, + ) + + - id::Int64 + - petId::Int64 + - quantity::Int64 + - shipDate::ZonedDateTime + - status::String : Order Status + - complete::Bool +""" +Base.@kwdef mutable struct Order <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + petId::Union{Nothing, Int64} = nothing + quantity::Union{Nothing, Int64} = nothing + shipDate::Union{Nothing, ZonedDateTime} = nothing + status::Union{Nothing, String} = nothing + complete::Union{Nothing, Bool} = false + + function Order(id, petId, quantity, shipDate, status, complete, ) + OpenAPI.validate_property(Order, Symbol("id"), id) + OpenAPI.validate_property(Order, Symbol("petId"), petId) + OpenAPI.validate_property(Order, Symbol("quantity"), quantity) + OpenAPI.validate_property(Order, Symbol("shipDate"), shipDate) + OpenAPI.validate_property(Order, Symbol("status"), status) + OpenAPI.validate_property(Order, Symbol("complete"), complete) + return new(id, petId, quantity, shipDate, status, complete, ) + end +end # type Order + +const _property_types_Order = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("petId")=>"Int64", Symbol("quantity")=>"Int64", Symbol("shipDate")=>"ZonedDateTime", Symbol("status")=>"String", Symbol("complete")=>"Bool", ) +OpenAPI.property_type(::Type{ Order }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_Order[name]))} + +function check_required(o::Order) + true +end + +function OpenAPI.validate_property(::Type{ Order }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "Order", :format, val, "int64") + end + if name === Symbol("petId") + OpenAPI.validate_param(name, "Order", :format, val, "int64") + end + if name === Symbol("quantity") + OpenAPI.validate_param(name, "Order", :format, val, "int32") + end + if name === Symbol("shipDate") + OpenAPI.validate_param(name, "Order", :format, val, "date-time") + end + if name === Symbol("status") + OpenAPI.validate_param(name, "Order", :enum, val, ["placed", "approved", "delivered"]) + end +end diff --git a/samples/client/petstore/julia/src/models/model_Pet.jl b/samples/client/petstore/julia/src/models/model_Pet.jl new file mode 100644 index 00000000000..569a9326912 --- /dev/null +++ b/samples/client/petstore/julia/src/models/model_Pet.jl @@ -0,0 +1,59 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""Pet +A pet for sale in the pet store + + Pet(; + id=nothing, + category=nothing, + name=nothing, + photoUrls=nothing, + tags=nothing, + status=nothing, + ) + + - id::Int64 + - category::Category + - name::String + - photoUrls::Vector{String} + - tags::Vector{Tag} + - status::String : pet status in the store +""" +Base.@kwdef mutable struct Pet <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + category = nothing # spec type: Union{ Nothing, Category } + name::Union{Nothing, String} = nothing + photoUrls::Union{Nothing, Vector{String}} = nothing + tags::Union{Nothing, Vector} = nothing # spec type: Union{ Nothing, Vector{Tag} } + status::Union{Nothing, String} = nothing + + function Pet(id, category, name, photoUrls, tags, status, ) + OpenAPI.validate_property(Pet, Symbol("id"), id) + OpenAPI.validate_property(Pet, Symbol("category"), category) + OpenAPI.validate_property(Pet, Symbol("name"), name) + OpenAPI.validate_property(Pet, Symbol("photoUrls"), photoUrls) + OpenAPI.validate_property(Pet, Symbol("tags"), tags) + OpenAPI.validate_property(Pet, Symbol("status"), status) + return new(id, category, name, photoUrls, tags, status, ) + end +end # type Pet + +const _property_types_Pet = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("category")=>"Category", Symbol("name")=>"String", Symbol("photoUrls")=>"Vector{String}", Symbol("tags")=>"Vector{Tag}", Symbol("status")=>"String", ) +OpenAPI.property_type(::Type{ Pet }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_Pet[name]))} + +function check_required(o::Pet) + o.name === nothing && (return false) + o.photoUrls === nothing && (return false) + true +end + +function OpenAPI.validate_property(::Type{ Pet }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "Pet", :format, val, "int64") + end + if name === Symbol("status") + OpenAPI.validate_param(name, "Pet", :enum, val, ["available", "pending", "sold"]) + end +end diff --git a/samples/client/petstore/julia/src/models/model_Tag.jl b/samples/client/petstore/julia/src/models/model_Tag.jl new file mode 100644 index 00000000000..f717688e996 --- /dev/null +++ b/samples/client/petstore/julia/src/models/model_Tag.jl @@ -0,0 +1,38 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""Tag +A tag for a pet + + Tag(; + id=nothing, + name=nothing, + ) + + - id::Int64 + - name::String +""" +Base.@kwdef mutable struct Tag <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + name::Union{Nothing, String} = nothing + + function Tag(id, name, ) + OpenAPI.validate_property(Tag, Symbol("id"), id) + OpenAPI.validate_property(Tag, Symbol("name"), name) + return new(id, name, ) + end +end # type Tag + +const _property_types_Tag = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("name")=>"String", ) +OpenAPI.property_type(::Type{ Tag }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_Tag[name]))} + +function check_required(o::Tag) + true +end + +function OpenAPI.validate_property(::Type{ Tag }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "Tag", :format, val, "int64") + end +end diff --git a/samples/client/petstore/julia/src/models/model_User.jl b/samples/client/petstore/julia/src/models/model_User.jl new file mode 100644 index 00000000000..5af0ccd94da --- /dev/null +++ b/samples/client/petstore/julia/src/models/model_User.jl @@ -0,0 +1,65 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""User +A User who is purchasing from the pet store + + User(; + id=nothing, + username=nothing, + firstName=nothing, + lastName=nothing, + email=nothing, + password=nothing, + phone=nothing, + userStatus=nothing, + ) + + - id::Int64 + - username::String + - firstName::String + - lastName::String + - email::String + - password::String + - phone::String + - userStatus::Int64 : User Status +""" +Base.@kwdef mutable struct User <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + username::Union{Nothing, String} = nothing + firstName::Union{Nothing, String} = nothing + lastName::Union{Nothing, String} = nothing + email::Union{Nothing, String} = nothing + password::Union{Nothing, String} = nothing + phone::Union{Nothing, String} = nothing + userStatus::Union{Nothing, Int64} = nothing + + function User(id, username, firstName, lastName, email, password, phone, userStatus, ) + OpenAPI.validate_property(User, Symbol("id"), id) + OpenAPI.validate_property(User, Symbol("username"), username) + OpenAPI.validate_property(User, Symbol("firstName"), firstName) + OpenAPI.validate_property(User, Symbol("lastName"), lastName) + OpenAPI.validate_property(User, Symbol("email"), email) + OpenAPI.validate_property(User, Symbol("password"), password) + OpenAPI.validate_property(User, Symbol("phone"), phone) + OpenAPI.validate_property(User, Symbol("userStatus"), userStatus) + return new(id, username, firstName, lastName, email, password, phone, userStatus, ) + end +end # type User + +const _property_types_User = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("username")=>"String", Symbol("firstName")=>"String", Symbol("lastName")=>"String", Symbol("email")=>"String", Symbol("password")=>"String", Symbol("phone")=>"String", Symbol("userStatus")=>"Int64", ) +OpenAPI.property_type(::Type{ User }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_User[name]))} + +function check_required(o::User) + true +end + +function OpenAPI.validate_property(::Type{ User }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "User", :format, val, "int64") + end + if name === Symbol("userStatus") + OpenAPI.validate_param(name, "User", :format, val, "int32") + end +end diff --git a/samples/server/petstore/julia/.openapi-generator-ignore b/samples/server/petstore/julia/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/petstore/julia/.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/server/petstore/julia/.openapi-generator/FILES b/samples/server/petstore/julia/.openapi-generator/FILES new file mode 100644 index 00000000000..d9189bb54e3 --- /dev/null +++ b/samples/server/petstore/julia/.openapi-generator/FILES @@ -0,0 +1,21 @@ +README.md +docs/ApiResponse.md +docs/Category.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/StoreApi.md +docs/Tag.md +docs/User.md +docs/UserApi.md +src/PetStoreServer.jl +src/apis/api_PetApi.jl +src/apis/api_StoreApi.jl +src/apis/api_UserApi.jl +src/modelincludes.jl +src/models/model_ApiResponse.jl +src/models/model_Category.jl +src/models/model_Order.jl +src/models/model_Pet.jl +src/models/model_Tag.jl +src/models/model_User.jl diff --git a/samples/server/petstore/julia/.openapi-generator/VERSION b/samples/server/petstore/julia/.openapi-generator/VERSION new file mode 100644 index 00000000000..d6b4ec4aa78 --- /dev/null +++ b/samples/server/petstore/julia/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/julia/README.md b/samples/server/petstore/julia/README.md new file mode 100644 index 00000000000..e44f99e9b8c --- /dev/null +++ b/samples/server/petstore/julia/README.md @@ -0,0 +1,81 @@ +# Julia API server for PetStoreServer + +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 server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Build package: org.openapitools.codegen.languages.JuliaServerCodegen + + +## Installation +Place the Julia files generated under the `src` folder in your Julia project. Include PetStoreServer.jl in the project code. +It would include the module named PetStoreServer. + +Implement the server methods as listed below. They are also documented with the PetStoreServer module. +Launch a HTTP server with a router that has all handlers registered. A `register` method is provided in PetStoreServer module for convenience. + +```julia +register( + router::HTTP.Router, # Router to register handlers in + impl; # Module that implements the server methods + path_prefix::String="", # Prefix to be applied to all paths + optional_middlewares... # Optional middlewares to be applied to all handlers +) +``` + +Optional middlewares can be one or more of: +- `init`: called before the request is processed +- `pre_validation`: called after the request is parsed but before validation +- `pre_invoke`: called after validation but before the handler is invoked +- `post_invoke`: called after the handler is invoked but before the response is sent + +The order in which middlewares are invoked are: +`init |> read |> pre_validation |> validate |> pre_invoke |> invoke |> post_invoke` + + +## API Endpoints + +The following server methods must be implemented: + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + + +## Models + + - [ApiResponse](docs/ApiResponse.md) + - [Category](docs/Category.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + + +## Author + + + diff --git a/samples/server/petstore/julia/docs/ApiResponse.md b/samples/server/petstore/julia/docs/ApiResponse.md new file mode 100644 index 00000000000..664dd2452f3 --- /dev/null +++ b/samples/server/petstore/julia/docs/ApiResponse.md @@ -0,0 +1,14 @@ +# ApiResponse + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Int64** | | [optional] [default to nothing] +**type** | **String** | | [optional] [default to nothing] +**message** | **String** | | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/julia/docs/Category.md b/samples/server/petstore/julia/docs/Category.md new file mode 100644 index 00000000000..4e932906e78 --- /dev/null +++ b/samples/server/petstore/julia/docs/Category.md @@ -0,0 +1,13 @@ +# Category + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**name** | **String** | | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/julia/docs/Order.md b/samples/server/petstore/julia/docs/Order.md new file mode 100644 index 00000000000..b815c052612 --- /dev/null +++ b/samples/server/petstore/julia/docs/Order.md @@ -0,0 +1,17 @@ +# Order + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**petId** | **Int64** | | [optional] [default to nothing] +**quantity** | **Int64** | | [optional] [default to nothing] +**shipDate** | **ZonedDateTime** | | [optional] [default to nothing] +**status** | **String** | Order Status | [optional] [default to nothing] +**complete** | **Bool** | | [optional] [default to false] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/julia/docs/Pet.md b/samples/server/petstore/julia/docs/Pet.md new file mode 100644 index 00000000000..a8bba4c8932 --- /dev/null +++ b/samples/server/petstore/julia/docs/Pet.md @@ -0,0 +1,17 @@ +# Pet + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**category** | [***Category**](Category.md) | | [optional] [default to nothing] +**name** | **String** | | [default to nothing] +**photoUrls** | **Vector{String}** | | [default to nothing] +**tags** | [**Vector{Tag}**](Tag.md) | | [optional] [default to nothing] +**status** | **String** | pet status in the store | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/julia/docs/PetApi.md b/samples/server/petstore/julia/docs/PetApi.md new file mode 100644 index 00000000000..5dab323f1de --- /dev/null +++ b/samples/server/petstore/julia/docs/PetApi.md @@ -0,0 +1,268 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **add_pet** +> add_pet(req::HTTP.Request, pet::Pet;) -> Pet + +Add a new pet to the store + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_pet** +> delete_pet(req::HTTP.Request, pet_id::Int64; api_key=nothing,) -> Nothing + +Deletes a pet + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**pet_id** | **Int64**| Pet id to delete | [default to nothing] + +### Optional Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **api_key** | **String**| | [default to nothing] + +### Return type + +Nothing + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_status** +> find_pets_by_status(req::HTTP.Request, status::Vector{String};) -> Vector{Pet} + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**status** | [**Vector{String}**](String.md)| Status values that need to be considered for filter | [default to nothing] + +### Return type + +[**Vector{Pet}**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_tags** +> find_pets_by_tags(req::HTTP.Request, tags::Vector{String};) -> Vector{Pet} + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**tags** | [**Vector{String}**](String.md)| Tags to filter by | [default to nothing] + +### Return type + +[**Vector{Pet}**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_pet_by_id** +> get_pet_by_id(req::HTTP.Request, pet_id::Int64;) -> Pet + +Find pet by ID + +Returns a single pet + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**pet_id** | **Int64**| ID of pet to return | [default to nothing] + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet** +> update_pet(req::HTTP.Request, pet::Pet;) -> Pet + +Update an existing pet + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet_with_form** +> update_pet_with_form(req::HTTP.Request, pet_id::Int64; name=nothing, status=nothing,) -> Nothing + +Updates a pet in the store with form data + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**pet_id** | **Int64**| ID of pet that needs to be updated | [default to nothing] + +### Optional Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **name** | **String**| Updated name of the pet | [default to nothing] + **status** | **String**| Updated status of the pet | [default to nothing] + +### Return type + +Nothing + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **upload_file** +> upload_file(req::HTTP.Request, pet_id::Int64; additional_metadata=nothing, file=nothing,) -> ApiResponse + +uploads an image + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**pet_id** | **Int64**| ID of pet to update | [default to nothing] + +### Optional Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **additional_metadata** | **String**| Additional data to pass to server | [default to nothing] + **file** | **String****String**| file to upload | [default to nothing] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/server/petstore/julia/docs/StoreApi.md b/samples/server/petstore/julia/docs/StoreApi.md new file mode 100644 index 00000000000..47304d2d166 --- /dev/null +++ b/samples/server/petstore/julia/docs/StoreApi.md @@ -0,0 +1,124 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order(req::HTTP.Request, order_id::String;) -> Nothing + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**order_id** | **String**| ID of the order that needs to be deleted | [default to nothing] + +### Return type + +Nothing + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_inventory** +> get_inventory(req::HTTP.Request;) -> Dict{String, Int64} + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +**Dict{String, Int64}** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_order_by_id** +> get_order_by_id(req::HTTP.Request, order_id::Int64;) -> Order + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**order_id** | **Int64**| ID of pet that needs to be fetched | [default to nothing] + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **place_order** +> place_order(req::HTTP.Request, order::Order;) -> Order + +Place an order for a pet + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**order** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/server/petstore/julia/docs/Tag.md b/samples/server/petstore/julia/docs/Tag.md new file mode 100644 index 00000000000..c904872204a --- /dev/null +++ b/samples/server/petstore/julia/docs/Tag.md @@ -0,0 +1,13 @@ +# Tag + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**name** | **String** | | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/julia/docs/User.md b/samples/server/petstore/julia/docs/User.md new file mode 100644 index 00000000000..5318b5a2f86 --- /dev/null +++ b/samples/server/petstore/julia/docs/User.md @@ -0,0 +1,19 @@ +# User + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int64** | | [optional] [default to nothing] +**username** | **String** | | [optional] [default to nothing] +**firstName** | **String** | | [optional] [default to nothing] +**lastName** | **String** | | [optional] [default to nothing] +**email** | **String** | | [optional] [default to nothing] +**password** | **String** | | [optional] [default to nothing] +**phone** | **String** | | [optional] [default to nothing] +**userStatus** | **Int64** | User Status | [optional] [default to nothing] + + +[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/julia/docs/UserApi.md b/samples/server/petstore/julia/docs/UserApi.md new file mode 100644 index 00000000000..a2d358000f9 --- /dev/null +++ b/samples/server/petstore/julia/docs/UserApi.md @@ -0,0 +1,246 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(req::HTTP.Request, user::User;) -> Nothing + +Create user + +This can only be done by the logged in user. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**user** | [**User**](User.md)| Created user object | + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_array_input** +> create_users_with_array_input(req::HTTP.Request, user::Vector{User};) -> Nothing + +Creates list of users with given input array + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**user** | [**Vector{User}**](User.md)| List of user object | + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_list_input** +> create_users_with_list_input(req::HTTP.Request, user::Vector{User};) -> Nothing + +Creates list of users with given input array + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**user** | [**Vector{User}**](User.md)| List of user object | + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_user** +> delete_user(req::HTTP.Request, username::String;) -> Nothing + +Delete user + +This can only be done by the logged in user. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**username** | **String**| The name that needs to be deleted | [default to nothing] + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_user_by_name** +> get_user_by_name(req::HTTP.Request, username::String;) -> User + +Get user by user name + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**username** | **String**| The name that needs to be fetched. Use user1 for testing. | [default to nothing] + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **login_user** +> login_user(req::HTTP.Request, username::String, password::String;) -> String + +Logs user into the system + + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**username** | **String**| The user name for login | [default to nothing] +**password** | **String**| The password for login in clear text | [default to nothing] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **logout_user** +> logout_user(req::HTTP.Request;) -> Nothing + +Logs out current logged in user session + + + +### Required Parameters +This endpoint does not need any parameter. + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_user** +> update_user(req::HTTP.Request, username::String, user::User;) -> Nothing + +Updated user + +This can only be done by the logged in user. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **req** | **HTTP.Request** | The HTTP Request object | +**username** | **String**| name that need to be deleted | [default to nothing] +**user** | [**User**](User.md)| Updated user object | + +### Return type + +Nothing + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/server/petstore/julia/src/PetStoreServer.jl b/samples/server/petstore/julia/src/PetStoreServer.jl new file mode 100644 index 00000000000..2a628275035 --- /dev/null +++ b/samples/server/petstore/julia/src/PetStoreServer.jl @@ -0,0 +1,115 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw""" +Encapsulates generated server code for PetStoreServer + +The following server methods must be implemented: + +- **add_pet** + - *invocation:* POST /pet + - *signature:* add_pet(req::HTTP.Request, pet::Pet;) -> Pet +- **delete_pet** + - *invocation:* DELETE /pet/{petId} + - *signature:* delete_pet(req::HTTP.Request, pet_id::Int64; api_key=nothing,) -> Nothing +- **find_pets_by_status** + - *invocation:* GET /pet/findByStatus + - *signature:* find_pets_by_status(req::HTTP.Request, status::Vector{String};) -> Vector{Pet} +- **find_pets_by_tags** + - *invocation:* GET /pet/findByTags + - *signature:* find_pets_by_tags(req::HTTP.Request, tags::Vector{String};) -> Vector{Pet} +- **get_pet_by_id** + - *invocation:* GET /pet/{petId} + - *signature:* get_pet_by_id(req::HTTP.Request, pet_id::Int64;) -> Pet +- **update_pet** + - *invocation:* PUT /pet + - *signature:* update_pet(req::HTTP.Request, pet::Pet;) -> Pet +- **update_pet_with_form** + - *invocation:* POST /pet/{petId} + - *signature:* update_pet_with_form(req::HTTP.Request, pet_id::Int64; name=nothing, status=nothing,) -> Nothing +- **upload_file** + - *invocation:* POST /pet/{petId}/uploadImage + - *signature:* upload_file(req::HTTP.Request, pet_id::Int64; additional_metadata=nothing, file=nothing,) -> ApiResponse +- **delete_order** + - *invocation:* DELETE /store/order/{orderId} + - *signature:* delete_order(req::HTTP.Request, order_id::String;) -> Nothing +- **get_inventory** + - *invocation:* GET /store/inventory + - *signature:* get_inventory(req::HTTP.Request;) -> Dict{String, Int64} +- **get_order_by_id** + - *invocation:* GET /store/order/{orderId} + - *signature:* get_order_by_id(req::HTTP.Request, order_id::Int64;) -> Order +- **place_order** + - *invocation:* POST /store/order + - *signature:* place_order(req::HTTP.Request, order::Order;) -> Order +- **create_user** + - *invocation:* POST /user + - *signature:* create_user(req::HTTP.Request, user::User;) -> Nothing +- **create_users_with_array_input** + - *invocation:* POST /user/createWithArray + - *signature:* create_users_with_array_input(req::HTTP.Request, user::Vector{User};) -> Nothing +- **create_users_with_list_input** + - *invocation:* POST /user/createWithList + - *signature:* create_users_with_list_input(req::HTTP.Request, user::Vector{User};) -> Nothing +- **delete_user** + - *invocation:* DELETE /user/{username} + - *signature:* delete_user(req::HTTP.Request, username::String;) -> Nothing +- **get_user_by_name** + - *invocation:* GET /user/{username} + - *signature:* get_user_by_name(req::HTTP.Request, username::String;) -> User +- **login_user** + - *invocation:* GET /user/login + - *signature:* login_user(req::HTTP.Request, username::String, password::String;) -> String +- **logout_user** + - *invocation:* GET /user/logout + - *signature:* logout_user(req::HTTP.Request;) -> Nothing +- **update_user** + - *invocation:* PUT /user/{username} + - *signature:* update_user(req::HTTP.Request, username::String, user::User;) -> Nothing +""" +module PetStoreServer + +using HTTP +using URIs +using Dates +using TimeZones +using OpenAPI +using OpenAPI.Servers + +const API_VERSION = "1.0.0" + +include("modelincludes.jl") + +include("apis/api_PetApi.jl") +include("apis/api_StoreApi.jl") +include("apis/api_UserApi.jl") + +""" +Register handlers for all APIs in this module in the supplied `Router` instance. + +Paramerets: +- `router`: Router to register handlers in +- `impl`: module that implements the server methods + +Optional parameters: +- `path_prefix`: prefix to be applied to all paths +- `optional_middlewares`: Register one or more optional middlewares to be applied to all requests. + +Optional middlewares can be one or more of: + - `init`: called before the request is processed + - `pre_validation`: called after the request is parsed but before validation + - `pre_invoke`: called after validation but before the handler is invoked + - `post_invoke`: called after the handler is invoked but before the response is sent + +The order in which middlewares are invoked are: +`init |> read |> pre_validation |> validate |> pre_invoke |> invoke |> post_invoke` +""" +function register(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...) + registerPetApi(router, impl; path_prefix=path_prefix, optional_middlewares...) + registerStoreApi(router, impl; path_prefix=path_prefix, optional_middlewares...) + registerUserApi(router, impl; path_prefix=path_prefix, optional_middlewares...) + return router +end + +end # module PetStoreServer diff --git a/samples/server/petstore/julia/src/apis/api_PetApi.jl b/samples/server/petstore/julia/src/apis/api_PetApi.jl new file mode 100644 index 00000000000..95dae56e137 --- /dev/null +++ b/samples/server/petstore/julia/src/apis/api_PetApi.jl @@ -0,0 +1,246 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +function add_pet_read(handler) + function add_pet_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + openapi_params["Pet"] = OpenAPI.Servers.to_param_type(Pet, String(req.body)) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function add_pet_validate(handler) + function add_pet_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function add_pet_invoke(impl; post_invoke=nothing) + function add_pet_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.add_pet(req::HTTP.Request, openapi_params["Pet"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function delete_pet_read(handler) + function delete_pet_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + path_params = HTTP.getparams(req) + openapi_params["petId"] = OpenAPI.Servers.to_param(Int64, path_params, "petId", required=true, ) + headers = Dict{String,String}(HTTP.headers(req)) + openapi_params["api_key"] = OpenAPI.Servers.to_param(String, headers, "api_key", ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function delete_pet_validate(handler) + function delete_pet_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function delete_pet_invoke(impl; post_invoke=nothing) + function delete_pet_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.delete_pet(req::HTTP.Request, openapi_params["petId"]; api_key=get(openapi_params, "api_key", nothing),) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function find_pets_by_status_read(handler) + function find_pets_by_status_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + query_params = HTTP.queryparams(URIs.URI(req.target)) + openapi_params["status"] = OpenAPI.Servers.to_param(Vector{String}, query_params, "status", required=true, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function find_pets_by_status_validate(handler) + function find_pets_by_status_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function find_pets_by_status_invoke(impl; post_invoke=nothing) + function find_pets_by_status_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.find_pets_by_status(req::HTTP.Request, openapi_params["status"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function find_pets_by_tags_read(handler) + function find_pets_by_tags_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + query_params = HTTP.queryparams(URIs.URI(req.target)) + openapi_params["tags"] = OpenAPI.Servers.to_param(Vector{String}, query_params, "tags", required=true, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function find_pets_by_tags_validate(handler) + function find_pets_by_tags_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function find_pets_by_tags_invoke(impl; post_invoke=nothing) + function find_pets_by_tags_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.find_pets_by_tags(req::HTTP.Request, openapi_params["tags"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function get_pet_by_id_read(handler) + function get_pet_by_id_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + path_params = HTTP.getparams(req) + openapi_params["petId"] = OpenAPI.Servers.to_param(Int64, path_params, "petId", required=true, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function get_pet_by_id_validate(handler) + function get_pet_by_id_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function get_pet_by_id_invoke(impl; post_invoke=nothing) + function get_pet_by_id_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.get_pet_by_id(req::HTTP.Request, openapi_params["petId"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function update_pet_read(handler) + function update_pet_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + openapi_params["Pet"] = OpenAPI.Servers.to_param_type(Pet, String(req.body)) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function update_pet_validate(handler) + function update_pet_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function update_pet_invoke(impl; post_invoke=nothing) + function update_pet_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.update_pet(req::HTTP.Request, openapi_params["Pet"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function update_pet_with_form_read(handler) + function update_pet_with_form_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + path_params = HTTP.getparams(req) + openapi_params["petId"] = OpenAPI.Servers.to_param(Int64, path_params, "petId", required=true, ) + form_data = HTTP.parse_multipart_form(req) + openapi_params["name"] = OpenAPI.Servers.to_param(String, form_data, "name"; multipart=true, isfile=false, ) + openapi_params["status"] = OpenAPI.Servers.to_param(String, form_data, "status"; multipart=true, isfile=false, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function update_pet_with_form_validate(handler) + function update_pet_with_form_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function update_pet_with_form_invoke(impl; post_invoke=nothing) + function update_pet_with_form_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.update_pet_with_form(req::HTTP.Request, openapi_params["petId"]; name=get(openapi_params, "name", nothing), status=get(openapi_params, "status", nothing),) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function upload_file_read(handler) + function upload_file_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + path_params = HTTP.getparams(req) + openapi_params["petId"] = OpenAPI.Servers.to_param(Int64, path_params, "petId", required=true, ) + form_data = HTTP.parse_multipart_form(req) + openapi_params["additionalMetadata"] = OpenAPI.Servers.to_param(String, form_data, "additionalMetadata"; multipart=true, isfile=false, ) + openapi_params["file"] = OpenAPI.Servers.to_param(String, form_data, "file"; multipart=true, isfile=true, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function upload_file_validate(handler) + function upload_file_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function upload_file_invoke(impl; post_invoke=nothing) + function upload_file_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.upload_file(req::HTTP.Request, openapi_params["petId"]; additional_metadata=get(openapi_params, "additionalMetadata", nothing), file=get(openapi_params, "file", nothing),) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + + +function registerPetApi(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...) + HTTP.register!(router, "POST", path_prefix * "/pet", OpenAPI.Servers.middleware(impl, add_pet_read, add_pet_validate, add_pet_invoke; optional_middlewares...)) + HTTP.register!(router, "DELETE", path_prefix * "/pet/{petId}", OpenAPI.Servers.middleware(impl, delete_pet_read, delete_pet_validate, delete_pet_invoke; optional_middlewares...)) + HTTP.register!(router, "GET", path_prefix * "/pet/findByStatus", OpenAPI.Servers.middleware(impl, find_pets_by_status_read, find_pets_by_status_validate, find_pets_by_status_invoke; optional_middlewares...)) + HTTP.register!(router, "GET", path_prefix * "/pet/findByTags", OpenAPI.Servers.middleware(impl, find_pets_by_tags_read, find_pets_by_tags_validate, find_pets_by_tags_invoke; optional_middlewares...)) + HTTP.register!(router, "GET", path_prefix * "/pet/{petId}", OpenAPI.Servers.middleware(impl, get_pet_by_id_read, get_pet_by_id_validate, get_pet_by_id_invoke; optional_middlewares...)) + HTTP.register!(router, "PUT", path_prefix * "/pet", OpenAPI.Servers.middleware(impl, update_pet_read, update_pet_validate, update_pet_invoke; optional_middlewares...)) + HTTP.register!(router, "POST", path_prefix * "/pet/{petId}", OpenAPI.Servers.middleware(impl, update_pet_with_form_read, update_pet_with_form_validate, update_pet_with_form_invoke; optional_middlewares...)) + HTTP.register!(router, "POST", path_prefix * "/pet/{petId}/uploadImage", OpenAPI.Servers.middleware(impl, upload_file_read, upload_file_validate, upload_file_invoke; optional_middlewares...)) + return router +end diff --git a/samples/server/petstore/julia/src/apis/api_StoreApi.jl b/samples/server/petstore/julia/src/apis/api_StoreApi.jl new file mode 100644 index 00000000000..b982905d37a --- /dev/null +++ b/samples/server/petstore/julia/src/apis/api_StoreApi.jl @@ -0,0 +1,124 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +function delete_order_read(handler) + function delete_order_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + path_params = HTTP.getparams(req) + openapi_params["orderId"] = OpenAPI.Servers.to_param(String, path_params, "orderId", required=true, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function delete_order_validate(handler) + function delete_order_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function delete_order_invoke(impl; post_invoke=nothing) + function delete_order_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.delete_order(req::HTTP.Request, openapi_params["orderId"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function get_inventory_read(handler) + function get_inventory_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function get_inventory_validate(handler) + function get_inventory_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function get_inventory_invoke(impl; post_invoke=nothing) + function get_inventory_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.get_inventory(req::HTTP.Request;) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function get_order_by_id_read(handler) + function get_order_by_id_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + path_params = HTTP.getparams(req) + openapi_params["orderId"] = OpenAPI.Servers.to_param(Int64, path_params, "orderId", required=true, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function get_order_by_id_validate(handler) + function get_order_by_id_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + OpenAPI.validate_param("orderId", "get_order_by_id", :maximum, openapi_params["orderId"], 5, false) + OpenAPI.validate_param("orderId", "get_order_by_id", :minimum, openapi_params["orderId"], 1, false) + + return handler(req) + end +end + +function get_order_by_id_invoke(impl; post_invoke=nothing) + function get_order_by_id_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.get_order_by_id(req::HTTP.Request, openapi_params["orderId"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function place_order_read(handler) + function place_order_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + openapi_params["Order"] = OpenAPI.Servers.to_param_type(Order, String(req.body)) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function place_order_validate(handler) + function place_order_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function place_order_invoke(impl; post_invoke=nothing) + function place_order_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.place_order(req::HTTP.Request, openapi_params["Order"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + + +function registerStoreApi(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...) + HTTP.register!(router, "DELETE", path_prefix * "/store/order/{orderId}", OpenAPI.Servers.middleware(impl, delete_order_read, delete_order_validate, delete_order_invoke; optional_middlewares...)) + HTTP.register!(router, "GET", path_prefix * "/store/inventory", OpenAPI.Servers.middleware(impl, get_inventory_read, get_inventory_validate, get_inventory_invoke; optional_middlewares...)) + HTTP.register!(router, "GET", path_prefix * "/store/order/{orderId}", OpenAPI.Servers.middleware(impl, get_order_by_id_read, get_order_by_id_validate, get_order_by_id_invoke; optional_middlewares...)) + HTTP.register!(router, "POST", path_prefix * "/store/order", OpenAPI.Servers.middleware(impl, place_order_read, place_order_validate, place_order_invoke; optional_middlewares...)) + return router +end diff --git a/samples/server/petstore/julia/src/apis/api_UserApi.jl b/samples/server/petstore/julia/src/apis/api_UserApi.jl new file mode 100644 index 00000000000..f8033b32330 --- /dev/null +++ b/samples/server/petstore/julia/src/apis/api_UserApi.jl @@ -0,0 +1,238 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +function create_user_read(handler) + function create_user_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + openapi_params["User"] = OpenAPI.Servers.to_param_type(User, String(req.body)) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function create_user_validate(handler) + function create_user_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function create_user_invoke(impl; post_invoke=nothing) + function create_user_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.create_user(req::HTTP.Request, openapi_params["User"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function create_users_with_array_input_read(handler) + function create_users_with_array_input_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + openapi_params["User"] = OpenAPI.Servers.to_param_type(Vector{User}, String(req.body)) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function create_users_with_array_input_validate(handler) + function create_users_with_array_input_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function create_users_with_array_input_invoke(impl; post_invoke=nothing) + function create_users_with_array_input_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.create_users_with_array_input(req::HTTP.Request, openapi_params["User"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function create_users_with_list_input_read(handler) + function create_users_with_list_input_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + openapi_params["User"] = OpenAPI.Servers.to_param_type(Vector{User}, String(req.body)) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function create_users_with_list_input_validate(handler) + function create_users_with_list_input_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function create_users_with_list_input_invoke(impl; post_invoke=nothing) + function create_users_with_list_input_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.create_users_with_list_input(req::HTTP.Request, openapi_params["User"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function delete_user_read(handler) + function delete_user_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + path_params = HTTP.getparams(req) + openapi_params["username"] = OpenAPI.Servers.to_param(String, path_params, "username", required=true, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function delete_user_validate(handler) + function delete_user_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function delete_user_invoke(impl; post_invoke=nothing) + function delete_user_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.delete_user(req::HTTP.Request, openapi_params["username"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function get_user_by_name_read(handler) + function get_user_by_name_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + path_params = HTTP.getparams(req) + openapi_params["username"] = OpenAPI.Servers.to_param(String, path_params, "username", required=true, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function get_user_by_name_validate(handler) + function get_user_by_name_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function get_user_by_name_invoke(impl; post_invoke=nothing) + function get_user_by_name_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.get_user_by_name(req::HTTP.Request, openapi_params["username"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function login_user_read(handler) + function login_user_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + query_params = HTTP.queryparams(URIs.URI(req.target)) + openapi_params["username"] = OpenAPI.Servers.to_param(String, query_params, "username", required=true, ) + openapi_params["password"] = OpenAPI.Servers.to_param(String, query_params, "password", required=true, ) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function login_user_validate(handler) + function login_user_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + + return handler(req) + end +end + +function login_user_invoke(impl; post_invoke=nothing) + function login_user_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.login_user(req::HTTP.Request, openapi_params["username"], openapi_params["password"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function logout_user_read(handler) + function logout_user_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function logout_user_validate(handler) + function logout_user_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function logout_user_invoke(impl; post_invoke=nothing) + function logout_user_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.logout_user(req::HTTP.Request;) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + +function update_user_read(handler) + function update_user_read_handler(req::HTTP.Request) + openapi_params = Dict{String,Any}() + path_params = HTTP.getparams(req) + openapi_params["username"] = OpenAPI.Servers.to_param(String, path_params, "username", required=true, ) + openapi_params["User"] = OpenAPI.Servers.to_param_type(User, String(req.body)) + req.context[:openapi_params] = openapi_params + + return handler(req) + end +end + +function update_user_validate(handler) + function update_user_validate_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + + return handler(req) + end +end + +function update_user_invoke(impl; post_invoke=nothing) + function update_user_invoke_handler(req::HTTP.Request) + openapi_params = req.context[:openapi_params] + ret = impl.update_user(req::HTTP.Request, openapi_params["username"], openapi_params["User"];) + resp = OpenAPI.Servers.server_response(ret) + return (post_invoke === nothing) ? resp : post_invoke(req, resp) + end +end + + +function registerUserApi(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...) + HTTP.register!(router, "POST", path_prefix * "/user", OpenAPI.Servers.middleware(impl, create_user_read, create_user_validate, create_user_invoke; optional_middlewares...)) + HTTP.register!(router, "POST", path_prefix * "/user/createWithArray", OpenAPI.Servers.middleware(impl, create_users_with_array_input_read, create_users_with_array_input_validate, create_users_with_array_input_invoke; optional_middlewares...)) + HTTP.register!(router, "POST", path_prefix * "/user/createWithList", OpenAPI.Servers.middleware(impl, create_users_with_list_input_read, create_users_with_list_input_validate, create_users_with_list_input_invoke; optional_middlewares...)) + HTTP.register!(router, "DELETE", path_prefix * "/user/{username}", OpenAPI.Servers.middleware(impl, delete_user_read, delete_user_validate, delete_user_invoke; optional_middlewares...)) + HTTP.register!(router, "GET", path_prefix * "/user/{username}", OpenAPI.Servers.middleware(impl, get_user_by_name_read, get_user_by_name_validate, get_user_by_name_invoke; optional_middlewares...)) + HTTP.register!(router, "GET", path_prefix * "/user/login", OpenAPI.Servers.middleware(impl, login_user_read, login_user_validate, login_user_invoke; optional_middlewares...)) + HTTP.register!(router, "GET", path_prefix * "/user/logout", OpenAPI.Servers.middleware(impl, logout_user_read, logout_user_validate, logout_user_invoke; optional_middlewares...)) + HTTP.register!(router, "PUT", path_prefix * "/user/{username}", OpenAPI.Servers.middleware(impl, update_user_read, update_user_validate, update_user_invoke; optional_middlewares...)) + return router +end diff --git a/samples/server/petstore/julia/src/modelincludes.jl b/samples/server/petstore/julia/src/modelincludes.jl new file mode 100644 index 00000000000..b3a3db84f30 --- /dev/null +++ b/samples/server/petstore/julia/src/modelincludes.jl @@ -0,0 +1,9 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + +include("models/model_ApiResponse.jl") +include("models/model_Category.jl") +include("models/model_Order.jl") +include("models/model_Pet.jl") +include("models/model_Tag.jl") +include("models/model_User.jl") diff --git a/samples/server/petstore/julia/src/models/model_ApiResponse.jl b/samples/server/petstore/julia/src/models/model_ApiResponse.jl new file mode 100644 index 00000000000..ab65bc17482 --- /dev/null +++ b/samples/server/petstore/julia/src/models/model_ApiResponse.jl @@ -0,0 +1,41 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""Describes the result of uploading an image resource + + ApiResponse(; + code=nothing, + type=nothing, + message=nothing, + ) + + - code::Int64 + - type::String + - message::String +""" +Base.@kwdef mutable struct ApiResponse <: OpenAPI.APIModel + code::Union{Nothing, Int64} = nothing + type::Union{Nothing, String} = nothing + message::Union{Nothing, String} = nothing + + function ApiResponse(code, type, message, ) + OpenAPI.validate_property(ApiResponse, Symbol("code"), code) + OpenAPI.validate_property(ApiResponse, Symbol("type"), type) + OpenAPI.validate_property(ApiResponse, Symbol("message"), message) + return new(code, type, message, ) + end +end # type ApiResponse + +const _property_types_ApiResponse = Dict{Symbol,String}(Symbol("code")=>"Int64", Symbol("type")=>"String", Symbol("message")=>"String", ) +OpenAPI.property_type(::Type{ ApiResponse }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_ApiResponse[name]))} + +function check_required(o::ApiResponse) + true +end + +function OpenAPI.validate_property(::Type{ ApiResponse }, name::Symbol, val) + if name === Symbol("code") + OpenAPI.validate_param(name, "ApiResponse", :format, val, "int32") + end +end diff --git a/samples/server/petstore/julia/src/models/model_Category.jl b/samples/server/petstore/julia/src/models/model_Category.jl new file mode 100644 index 00000000000..66c0bf76687 --- /dev/null +++ b/samples/server/petstore/julia/src/models/model_Category.jl @@ -0,0 +1,40 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""A category for a pet + + Category(; + id=nothing, + name=nothing, + ) + + - id::Int64 + - name::String +""" +Base.@kwdef mutable struct Category <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + name::Union{Nothing, String} = nothing + + function Category(id, name, ) + OpenAPI.validate_property(Category, Symbol("id"), id) + OpenAPI.validate_property(Category, Symbol("name"), name) + return new(id, name, ) + end +end # type Category + +const _property_types_Category = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("name")=>"String", ) +OpenAPI.property_type(::Type{ Category }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_Category[name]))} + +function check_required(o::Category) + true +end + +function OpenAPI.validate_property(::Type{ Category }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "Category", :format, val, "int64") + end + if name === Symbol("name") + OpenAPI.validate_param(name, "Category", :pattern, val, r"^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$") + end +end diff --git a/samples/server/petstore/julia/src/models/model_Order.jl b/samples/server/petstore/julia/src/models/model_Order.jl new file mode 100644 index 00000000000..52feda46476 --- /dev/null +++ b/samples/server/petstore/julia/src/models/model_Order.jl @@ -0,0 +1,65 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""An order for a pets from the pet store + + Order(; + id=nothing, + petId=nothing, + quantity=nothing, + shipDate=nothing, + status=nothing, + complete=false, + ) + + - id::Int64 + - petId::Int64 + - quantity::Int64 + - shipDate::ZonedDateTime + - status::String : Order Status + - complete::Bool +""" +Base.@kwdef mutable struct Order <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + petId::Union{Nothing, Int64} = nothing + quantity::Union{Nothing, Int64} = nothing + shipDate::Union{Nothing, ZonedDateTime} = nothing + status::Union{Nothing, String} = nothing + complete::Union{Nothing, Bool} = false + + function Order(id, petId, quantity, shipDate, status, complete, ) + OpenAPI.validate_property(Order, Symbol("id"), id) + OpenAPI.validate_property(Order, Symbol("petId"), petId) + OpenAPI.validate_property(Order, Symbol("quantity"), quantity) + OpenAPI.validate_property(Order, Symbol("shipDate"), shipDate) + OpenAPI.validate_property(Order, Symbol("status"), status) + OpenAPI.validate_property(Order, Symbol("complete"), complete) + return new(id, petId, quantity, shipDate, status, complete, ) + end +end # type Order + +const _property_types_Order = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("petId")=>"Int64", Symbol("quantity")=>"Int64", Symbol("shipDate")=>"ZonedDateTime", Symbol("status")=>"String", Symbol("complete")=>"Bool", ) +OpenAPI.property_type(::Type{ Order }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_Order[name]))} + +function check_required(o::Order) + true +end + +function OpenAPI.validate_property(::Type{ Order }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "Order", :format, val, "int64") + end + if name === Symbol("petId") + OpenAPI.validate_param(name, "Order", :format, val, "int64") + end + if name === Symbol("quantity") + OpenAPI.validate_param(name, "Order", :format, val, "int32") + end + if name === Symbol("shipDate") + OpenAPI.validate_param(name, "Order", :format, val, "date-time") + end + if name === Symbol("status") + OpenAPI.validate_param(name, "Order", :enum, val, ["placed", "approved", "delivered"]) + end +end diff --git a/samples/server/petstore/julia/src/models/model_Pet.jl b/samples/server/petstore/julia/src/models/model_Pet.jl new file mode 100644 index 00000000000..f7ce8bd5541 --- /dev/null +++ b/samples/server/petstore/julia/src/models/model_Pet.jl @@ -0,0 +1,58 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""A pet for sale in the pet store + + Pet(; + id=nothing, + category=nothing, + name=nothing, + photoUrls=nothing, + tags=nothing, + status=nothing, + ) + + - id::Int64 + - category::Category + - name::String + - photoUrls::Vector{String} + - tags::Vector{Tag} + - status::String : pet status in the store +""" +Base.@kwdef mutable struct Pet <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + category = nothing # spec type: Union{ Nothing, Category } + name::Union{Nothing, String} = nothing + photoUrls::Union{Nothing, Vector{String}} = nothing + tags::Union{Nothing, Vector} = nothing # spec type: Union{ Nothing, Vector{Tag} } + status::Union{Nothing, String} = nothing + + function Pet(id, category, name, photoUrls, tags, status, ) + OpenAPI.validate_property(Pet, Symbol("id"), id) + OpenAPI.validate_property(Pet, Symbol("category"), category) + OpenAPI.validate_property(Pet, Symbol("name"), name) + OpenAPI.validate_property(Pet, Symbol("photoUrls"), photoUrls) + OpenAPI.validate_property(Pet, Symbol("tags"), tags) + OpenAPI.validate_property(Pet, Symbol("status"), status) + return new(id, category, name, photoUrls, tags, status, ) + end +end # type Pet + +const _property_types_Pet = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("category")=>"Category", Symbol("name")=>"String", Symbol("photoUrls")=>"Vector{String}", Symbol("tags")=>"Vector{Tag}", Symbol("status")=>"String", ) +OpenAPI.property_type(::Type{ Pet }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_Pet[name]))} + +function check_required(o::Pet) + o.name === nothing && (return false) + o.photoUrls === nothing && (return false) + true +end + +function OpenAPI.validate_property(::Type{ Pet }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "Pet", :format, val, "int64") + end + if name === Symbol("status") + OpenAPI.validate_param(name, "Pet", :enum, val, ["available", "pending", "sold"]) + end +end diff --git a/samples/server/petstore/julia/src/models/model_Tag.jl b/samples/server/petstore/julia/src/models/model_Tag.jl new file mode 100644 index 00000000000..8eb2533685c --- /dev/null +++ b/samples/server/petstore/julia/src/models/model_Tag.jl @@ -0,0 +1,37 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""A tag for a pet + + Tag(; + id=nothing, + name=nothing, + ) + + - id::Int64 + - name::String +""" +Base.@kwdef mutable struct Tag <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + name::Union{Nothing, String} = nothing + + function Tag(id, name, ) + OpenAPI.validate_property(Tag, Symbol("id"), id) + OpenAPI.validate_property(Tag, Symbol("name"), name) + return new(id, name, ) + end +end # type Tag + +const _property_types_Tag = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("name")=>"String", ) +OpenAPI.property_type(::Type{ Tag }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_Tag[name]))} + +function check_required(o::Tag) + true +end + +function OpenAPI.validate_property(::Type{ Tag }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "Tag", :format, val, "int64") + end +end diff --git a/samples/server/petstore/julia/src/models/model_User.jl b/samples/server/petstore/julia/src/models/model_User.jl new file mode 100644 index 00000000000..cb7685b65ac --- /dev/null +++ b/samples/server/petstore/julia/src/models/model_User.jl @@ -0,0 +1,64 @@ +# This file was generated by the Julia OpenAPI Code Generator +# Do not modify this file directly. Modify the OpenAPI specification instead. + + +@doc raw"""A User who is purchasing from the pet store + + User(; + id=nothing, + username=nothing, + firstName=nothing, + lastName=nothing, + email=nothing, + password=nothing, + phone=nothing, + userStatus=nothing, + ) + + - id::Int64 + - username::String + - firstName::String + - lastName::String + - email::String + - password::String + - phone::String + - userStatus::Int64 : User Status +""" +Base.@kwdef mutable struct User <: OpenAPI.APIModel + id::Union{Nothing, Int64} = nothing + username::Union{Nothing, String} = nothing + firstName::Union{Nothing, String} = nothing + lastName::Union{Nothing, String} = nothing + email::Union{Nothing, String} = nothing + password::Union{Nothing, String} = nothing + phone::Union{Nothing, String} = nothing + userStatus::Union{Nothing, Int64} = nothing + + function User(id, username, firstName, lastName, email, password, phone, userStatus, ) + OpenAPI.validate_property(User, Symbol("id"), id) + OpenAPI.validate_property(User, Symbol("username"), username) + OpenAPI.validate_property(User, Symbol("firstName"), firstName) + OpenAPI.validate_property(User, Symbol("lastName"), lastName) + OpenAPI.validate_property(User, Symbol("email"), email) + OpenAPI.validate_property(User, Symbol("password"), password) + OpenAPI.validate_property(User, Symbol("phone"), phone) + OpenAPI.validate_property(User, Symbol("userStatus"), userStatus) + return new(id, username, firstName, lastName, email, password, phone, userStatus, ) + end +end # type User + +const _property_types_User = Dict{Symbol,String}(Symbol("id")=>"Int64", Symbol("username")=>"String", Symbol("firstName")=>"String", Symbol("lastName")=>"String", Symbol("email")=>"String", Symbol("password")=>"String", Symbol("phone")=>"String", Symbol("userStatus")=>"Int64", ) +OpenAPI.property_type(::Type{ User }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_User[name]))} + +function check_required(o::User) + true +end + +function OpenAPI.validate_property(::Type{ User }, name::Symbol, val) + if name === Symbol("id") + OpenAPI.validate_param(name, "User", :format, val, "int64") + end + if name === Symbol("userStatus") + OpenAPI.validate_param(name, "User", :format, val, "int32") + end +end