forked from loafle/openapi-generator-original
[Eiffel] fix Eiffel schema lookup, clean up outdated samples (#15901)
* make all unmaintained samples executable * remove samples not generated by any config (not even unmaintained configs) * remove deleted samples from github workflows
This commit is contained in:
parent
47f2f5f3e7
commit
33e120a14d
1
.github/workflows/samples-dotnet.yaml
vendored
1
.github/workflows/samples-dotnet.yaml
vendored
@ -8,7 +8,6 @@ on:
|
|||||||
- 'samples/server/petstore/aspnetcore-6.0/**'
|
- 'samples/server/petstore/aspnetcore-6.0/**'
|
||||||
- 'samples/server/petstore/aspnetcore-6.0-pocoModels/**'
|
- 'samples/server/petstore/aspnetcore-6.0-pocoModels/**'
|
||||||
- 'samples/server/petstore/aspnetcore-6.0-useSwashBuckle/**'
|
- 'samples/server/petstore/aspnetcore-6.0-useSwashBuckle/**'
|
||||||
- 'samples/server/petstore/aspnetcore-6.0-useNewtonsoft/**'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- 'samples/client/petstore/csharp/**net6.0**/'
|
- 'samples/client/petstore/csharp/**net6.0**/'
|
||||||
|
@ -6,7 +6,6 @@ on:
|
|||||||
- 'samples/server/petstore/aspnetcore-6.0/**'
|
- 'samples/server/petstore/aspnetcore-6.0/**'
|
||||||
- 'samples/server/petstore/aspnetcore-6.0-pocoModels/**'
|
- 'samples/server/petstore/aspnetcore-6.0-pocoModels/**'
|
||||||
- 'samples/server/petstore/aspnetcore-6.0-useSwashBuckle/**'
|
- 'samples/server/petstore/aspnetcore-6.0-useSwashBuckle/**'
|
||||||
- 'samples/server/petstore/aspnetcore-6.0-useNewtonsoft/**'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- 'samples/server/petstore/aspnetcore-6.0/**'
|
- 'samples/server/petstore/aspnetcore-6.0/**'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
generatorName: cpp-qt5-client
|
generatorName: cpp-qt-client
|
||||||
outputDir: samples/client/petstore/cpp-qt5
|
outputDir: samples/client/petstore/cpp-qt
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||||
templateDir: modules/openapi-generator/src/main/resources/cpp-qt5-client
|
templateDir: modules/openapi-generator/src/main/resources/cpp-qt-client
|
@ -1,4 +1,4 @@
|
|||||||
generatorName: cpp-qt5-qhttpengine-server
|
generatorName: cpp-qt-qhttpengine-server
|
||||||
outputDir: samples/client/petstore/cpp-qt5-qhttpengine-server
|
outputDir: samples/client/petstore/cpp-qt-qhttpengine-server
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||||
templateDir: modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server
|
templateDir: modules/openapi-generator/src/main/resources/cpp-qt-qhttpengine-server
|
@ -1,6 +0,0 @@
|
|||||||
generatorName: csharp
|
|
||||||
outputDir: samples/openapi3/client/petstore/csharp/OpenAPIClient
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
|
||||||
additionalProperties:
|
|
||||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
|
@ -1,7 +0,0 @@
|
|||||||
generatorName: csharp
|
|
||||||
outputDir: samples/client/petstore/csharp/OpenAPIClientNetStandard
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
|
||||||
additionalProperties:
|
|
||||||
targetFramework: netstandard1.3
|
|
||||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
|
@ -1,8 +0,0 @@
|
|||||||
generatorName: csharp
|
|
||||||
outputDir: samples/client/petstore/csharp/OpenAPIClientWithPropertyChanged
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
|
||||||
additionalProperties:
|
|
||||||
packageGuid: '{5CD900DE-8266-412F-A758-28E1F9C623D5}'
|
|
||||||
generatePropertyChanged: "true"
|
|
||||||
optionalEmitDefaultValues: "true"
|
|
@ -1,6 +0,0 @@
|
|||||||
generatorName: csharp-dotnet2
|
|
||||||
outputDir: samples/client/petstore/csharp-dotnet2/OpenAPIClientTest/Lib/OpenAPIClient
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp-dotnet2
|
|
||||||
additionalProperties:
|
|
||||||
hideGenerationTimestamp: "true"
|
|
@ -278,9 +278,6 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
|||||||
childrenByParent.put(model.parent, model);
|
childrenByParent.put(model.parent, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(model.parentSchema)) {
|
|
||||||
model.parentSchema = model.parentSchema.toLowerCase(Locale.ROOT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
# Swagger Codegen Ignore
|
|
||||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
|
||||||
|
|
||||||
# Use this file to prevent files from being overwritten by the generator.
|
|
||||||
# The patterns follow closely to .gitignore or .dockerignore.
|
|
||||||
|
|
||||||
# As an example, the C# client generator defines ApiClient.cs.
|
|
||||||
# You can make changes and tell Swagger Codegen 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
|
|
@ -1 +0,0 @@
|
|||||||
2.2.3-SNAPSHOT
|
|
@ -1,12 +0,0 @@
|
|||||||
organization := ""
|
|
||||||
|
|
||||||
name := "-client"
|
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
|
||||||
"com.wordnik.swagger" %% "swagger-async-httpclient" % "0.3.5",
|
|
||||||
"joda-time" % "joda-time" % "2.3",
|
|
||||||
"org.joda" % "joda-convert" % "1.3.1",
|
|
||||||
"ch.qos.logback" % "logback-classic" % "1.0.13" % "provided",
|
|
||||||
"org.scalatest" %% "scalatest" % "2.2.1" % "test",
|
|
||||||
"junit" % "junit" % "4.11" % "test"
|
|
||||||
)
|
|
@ -1,28 +0,0 @@
|
|||||||
package io.swagger.client
|
|
||||||
|
|
||||||
import io.swagger.client.api._
|
|
||||||
|
|
||||||
import com.wordnik.swagger.client._
|
|
||||||
|
|
||||||
import java.io.Closeable
|
|
||||||
|
|
||||||
class SwaggerClient(config: SwaggerConfig) extends Closeable {
|
|
||||||
val locator = config.locator
|
|
||||||
val name = config.name
|
|
||||||
|
|
||||||
private[this] val client = transportClient
|
|
||||||
|
|
||||||
protected def transportClient: TransportClient = new RestClient(config)
|
|
||||||
|
|
||||||
val pet = new PetApi(client, config)
|
|
||||||
|
|
||||||
val store = new StoreApi(client, config)
|
|
||||||
|
|
||||||
val user = new UserApi(client, config)
|
|
||||||
|
|
||||||
|
|
||||||
def close() {
|
|
||||||
client.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
|||||||
package io.swagger.client.api
|
|
||||||
|
|
||||||
import io.swagger.client.model.ApiResponse
|
|
||||||
import java.io.File
|
|
||||||
import io.swagger.client.model.Pet
|
|
||||||
import com.wordnik.swagger.client._
|
|
||||||
import scala.concurrent.Future
|
|
||||||
import collection.mutable
|
|
||||||
|
|
||||||
class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
|
||||||
|
|
||||||
def addPet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/pet"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->addPet")
|
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def deletePet(petId: Long,
|
|
||||||
apiKey: Option[String] = None
|
|
||||||
)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/pet/{petId}")
|
|
||||||
replaceAll ("\\{" + "petId" + "\\}",petId.toString))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
apiKey match {
|
|
||||||
case Some(param) => headerParams += "api_key" -> param.toString
|
|
||||||
case _ => headerParams
|
|
||||||
}
|
|
||||||
|
|
||||||
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def findPetsByStatus(status: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/pet/findByStatus"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (status == null) throw new Exception("Missing required parameter 'status' when calling PetApi->findPetsByStatus")
|
|
||||||
queryParams += "status" -> status.toString
|
|
||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def findPetsByTags(tags: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/pet/findByTags"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (tags == null) throw new Exception("Missing required parameter 'tags' when calling PetApi->findPetsByTags")
|
|
||||||
queryParams += "tags" -> tags.toString
|
|
||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def getPetById(petId: Long)(implicit reader: ClientResponseReader[Pet]): Future[Pet] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/pet/{petId}")
|
|
||||||
replaceAll ("\\{" + "petId" + "\\}",petId.toString))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def updatePet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/pet"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->updatePet")
|
|
||||||
|
|
||||||
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def updatePetWithForm(petId: Long,
|
|
||||||
name: Option[String] = None,
|
|
||||||
status: Option[String] = None
|
|
||||||
)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/pet/{petId}")
|
|
||||||
replaceAll ("\\{" + "petId" + "\\}",petId.toString))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def uploadFile(petId: Long,
|
|
||||||
additionalMetadata: Option[String] = None,
|
|
||||||
file: Option[File] = None
|
|
||||||
)(implicit reader: ClientResponseReader[ApiResponse]): Future[ApiResponse] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/pet/{petId}/uploadImage")
|
|
||||||
replaceAll ("\\{" + "petId" + "\\}",petId.toString))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
package io.swagger.client.api
|
|
||||||
|
|
||||||
import io.swagger.client.model.Order
|
|
||||||
import com.wordnik.swagger.client._
|
|
||||||
import scala.concurrent.Future
|
|
||||||
import collection.mutable
|
|
||||||
|
|
||||||
class StoreApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
|
||||||
|
|
||||||
def deleteOrder(orderId: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/store/order/{orderId}")
|
|
||||||
replaceAll ("\\{" + "orderId" + "\\}",orderId.toString))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (orderId == null) throw new Exception("Missing required parameter 'orderId' when calling StoreApi->deleteOrder")
|
|
||||||
|
|
||||||
|
|
||||||
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def getInventory()(implicit reader: ClientResponseReader[Map[String, Integer]]): Future[Map[String, Integer]] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/store/inventory"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def getOrderById(orderId: Long)(implicit reader: ClientResponseReader[Order]): Future[Order] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/store/order/{orderId}")
|
|
||||||
replaceAll ("\\{" + "orderId" + "\\}",orderId.toString))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def placeOrder(body: Order)(implicit reader: ClientResponseReader[Order], writer: RequestWriter[Order]): Future[Order] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/store/order"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling StoreApi->placeOrder")
|
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,152 +0,0 @@
|
|||||||
package io.swagger.client.api
|
|
||||||
|
|
||||||
import io.swagger.client.model.User
|
|
||||||
import com.wordnik.swagger.client._
|
|
||||||
import scala.concurrent.Future
|
|
||||||
import collection.mutable
|
|
||||||
|
|
||||||
class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
|
||||||
|
|
||||||
def createUser(body: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/user"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUser")
|
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def createUsersWithArrayInput(body: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/user/createWithArray"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithArrayInput")
|
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def createUsersWithListInput(body: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/user/createWithList"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithListInput")
|
|
||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def deleteUser(username: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/user/{username}")
|
|
||||||
replaceAll ("\\{" + "username" + "\\}",username.toString))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->deleteUser")
|
|
||||||
|
|
||||||
|
|
||||||
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def getUserByName(username: String)(implicit reader: ClientResponseReader[User]): Future[User] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/user/{username}")
|
|
||||||
replaceAll ("\\{" + "username" + "\\}",username.toString))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->getUserByName")
|
|
||||||
|
|
||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def loginUser(username: String,
|
|
||||||
password: String)(implicit reader: ClientResponseReader[String]): Future[String] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/user/login"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->loginUser")
|
|
||||||
|
|
||||||
if (password == null) throw new Exception("Missing required parameter 'password' when calling UserApi->loginUser")
|
|
||||||
|
|
||||||
queryParams += "username" -> username.toString
|
|
||||||
queryParams += "password" -> password.toString
|
|
||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def logoutUser()(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/user/logout"))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def updateUser(username: String,
|
|
||||||
body: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = {
|
|
||||||
// create path and map variables
|
|
||||||
val path = (addFmt("/user/{username}")
|
|
||||||
replaceAll ("\\{" + "username" + "\\}",username.toString))
|
|
||||||
|
|
||||||
// query params
|
|
||||||
val queryParams = new mutable.HashMap[String, String]
|
|
||||||
val headerParams = new mutable.HashMap[String, String]
|
|
||||||
|
|
||||||
if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->updateUser")
|
|
||||||
|
|
||||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->updateUser")
|
|
||||||
|
|
||||||
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
|
||||||
resFuture flatMap { resp =>
|
|
||||||
process(reader.read(resp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package io.swagger.client.model
|
|
||||||
|
|
||||||
import org.joda.time.DateTime
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
|
|
||||||
case class ApiResponse (
|
|
||||||
code: Option[Integer],
|
|
||||||
_type: Option[String],
|
|
||||||
message: Option[String]
|
|
||||||
)
|
|
@ -1,10 +0,0 @@
|
|||||||
package io.swagger.client.model
|
|
||||||
|
|
||||||
import org.joda.time.DateTime
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
|
|
||||||
case class Category (
|
|
||||||
id: Option[Long],
|
|
||||||
name: Option[String]
|
|
||||||
)
|
|
@ -1,14 +0,0 @@
|
|||||||
package io.swagger.client.model
|
|
||||||
|
|
||||||
import org.joda.time.DateTime
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
|
|
||||||
case class Order (
|
|
||||||
id: Option[Long],
|
|
||||||
petId: Option[Long],
|
|
||||||
quantity: Option[Integer],
|
|
||||||
shipDate: Option[DateTime],
|
|
||||||
status: Option[String], // Order Status
|
|
||||||
complete: Option[Boolean]
|
|
||||||
)
|
|
@ -1,14 +0,0 @@
|
|||||||
package io.swagger.client.model
|
|
||||||
|
|
||||||
import org.joda.time.DateTime
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
|
|
||||||
case class Pet (
|
|
||||||
id: Option[Long],
|
|
||||||
category: Option[Category],
|
|
||||||
name: String,
|
|
||||||
photoUrls: List[String],
|
|
||||||
tags: Option[List[Tag]],
|
|
||||||
status: Option[String] // pet status in the store
|
|
||||||
)
|
|
@ -1,10 +0,0 @@
|
|||||||
package io.swagger.client.model
|
|
||||||
|
|
||||||
import org.joda.time.DateTime
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
|
|
||||||
case class Tag (
|
|
||||||
id: Option[Long],
|
|
||||||
name: Option[String]
|
|
||||||
)
|
|
@ -1,16 +0,0 @@
|
|||||||
package io.swagger.client.model
|
|
||||||
|
|
||||||
import org.joda.time.DateTime
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
|
|
||||||
case class User (
|
|
||||||
id: Option[Long],
|
|
||||||
username: Option[String],
|
|
||||||
firstName: Option[String],
|
|
||||||
lastName: Option[String],
|
|
||||||
email: Option[String],
|
|
||||||
password: Option[String],
|
|
||||||
phone: Option[String],
|
|
||||||
userStatus: Option[Integer] // User Status
|
|
||||||
)
|
|
@ -1,36 +0,0 @@
|
|||||||
import java.net.URI
|
|
||||||
|
|
||||||
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
|
||||||
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
|
||||||
import com.wordnik.swagger.client.SwaggerConfig
|
|
||||||
import io.swagger.client.SwaggerClient
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.scalatest._
|
|
||||||
import org.scalatest.junit.JUnitRunner
|
|
||||||
|
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
|
||||||
import scala.concurrent._
|
|
||||||
import scala.concurrent.duration._
|
|
||||||
import scala.util.{Failure, Success}
|
|
||||||
|
|
||||||
@RunWith(classOf[JUnitRunner])
|
|
||||||
class SimpleTest extends FlatSpec with Matchers {
|
|
||||||
implicit val formats = org.json4s.DefaultFormats
|
|
||||||
implicit val reader = JsonFormatsReader
|
|
||||||
implicit val writer = JsonFormatsWriter
|
|
||||||
|
|
||||||
it should "call the api" in {
|
|
||||||
val config = SwaggerConfig.forUrl(new URI("http://petstore.swagger.io/v2"))
|
|
||||||
val client = new SwaggerClient(config)
|
|
||||||
|
|
||||||
val future = client.pet.getPetById(3)
|
|
||||||
val await = Await.ready(future, Duration.Inf)
|
|
||||||
|
|
||||||
await onComplete {
|
|
||||||
case Success(pet) => {
|
|
||||||
println(pet)
|
|
||||||
}
|
|
||||||
case Failure(t) => println("failed " + t.getMessage)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
# 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
|
|
@ -1,13 +0,0 @@
|
|||||||
.openapi-generator-ignore
|
|
||||||
README.md
|
|
||||||
pom.xml
|
|
||||||
src/main/java/org/openapitools/api/ApiUtil.java
|
|
||||||
src/main/java/org/openapitools/api/PetApi.java
|
|
||||||
src/main/java/org/openapitools/api/StoreApi.java
|
|
||||||
src/main/java/org/openapitools/api/UserApi.java
|
|
||||||
src/main/java/org/openapitools/model/Category.java
|
|
||||||
src/main/java/org/openapitools/model/ModelApiResponse.java
|
|
||||||
src/main/java/org/openapitools/model/Order.java
|
|
||||||
src/main/java/org/openapitools/model/Pet.java
|
|
||||||
src/main/java/org/openapitools/model/Tag.java
|
|
||||||
src/main/java/org/openapitools/model/User.java
|
|
@ -1 +0,0 @@
|
|||||||
7.0.0-SNAPSHOT
|
|
@ -1,27 +0,0 @@
|
|||||||
|
|
||||||
# OpenAPI generated API stub
|
|
||||||
|
|
||||||
Spring Framework stub
|
|
||||||
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
|
||||||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub.
|
|
||||||
This is an example of building API stub interfaces in Java using the Spring framework.
|
|
||||||
|
|
||||||
The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints
|
|
||||||
by adding ```@Controller``` classes that implement the interface. Eg:
|
|
||||||
```java
|
|
||||||
@Controller
|
|
||||||
public class PetController implements PetApi {
|
|
||||||
// implement all PetApi methods
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg:
|
|
||||||
```java
|
|
||||||
@FeignClient(name="pet", url="http://petstore.swagger.io/v2")
|
|
||||||
public interface PetClient extends PetApi {
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
@ -1,83 +0,0 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>org.openapitools</groupId>
|
|
||||||
<artifactId>spring-stubs</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<name>spring-stubs</name>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<springfox.version>2.9.2</springfox.version>
|
|
||||||
<swagger-ui.version>4.10.3</swagger-ui.version>
|
|
||||||
</properties>
|
|
||||||
<parent>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>2.5.14</version>
|
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
|
||||||
</parent>
|
|
||||||
<build>
|
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
|
||||||
</build>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-commons</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!--SpringFox dependencies -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
|
||||||
<version>${springfox.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.webjars</groupId>
|
|
||||||
<artifactId>swagger-ui</artifactId>
|
|
||||||
<version>${swagger-ui.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.webjars</groupId>
|
|
||||||
<artifactId>webjars-locator-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- @Nullable annotation -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
|
||||||
<artifactId>jsr305</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
|
||||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openapitools</groupId>
|
|
||||||
<artifactId>jackson-databind-nullable</artifactId>
|
|
||||||
<version>0.2.2</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Bean Validation API support -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
@ -1,19 +0,0 @@
|
|||||||
package org.openapitools.api;
|
|
||||||
|
|
||||||
import org.springframework.web.context.request.NativeWebRequest;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class ApiUtil {
|
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
|
||||||
try {
|
|
||||||
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
|
||||||
res.setCharacterEncoding("UTF-8");
|
|
||||||
res.addHeader("Content-Type", contentType);
|
|
||||||
res.getWriter().print(example);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,395 +0,0 @@
|
|||||||
/**
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.0.0-SNAPSHOT).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
package org.openapitools.api;
|
|
||||||
|
|
||||||
import org.openapitools.model.ModelApiResponse;
|
|
||||||
import org.openapitools.model.Pet;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.context.request.NativeWebRequest;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
|
|
||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
|
||||||
@Validated
|
|
||||||
@Api(value = "pet", description = "Everything about your Pets")
|
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface PetApi {
|
|
||||||
|
|
||||||
default Optional<NativeWebRequest> getRequest() {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /pet : Add a new pet to the store
|
|
||||||
*
|
|
||||||
* @param body Pet object that needs to be added to the store (required)
|
|
||||||
* @return Invalid input (status code 405)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "pet" },
|
|
||||||
value = "Add a new pet to the store",
|
|
||||||
nickname = "addPet",
|
|
||||||
notes = "",
|
|
||||||
authorizations = {
|
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
|
||||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 405, message = "Invalid input")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.POST,
|
|
||||||
value = "/pet",
|
|
||||||
consumes = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> addPet(
|
|
||||||
@ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DELETE /pet/{petId} : Deletes a pet
|
|
||||||
*
|
|
||||||
* @param petId Pet id to delete (required)
|
|
||||||
* @param apiKey (optional)
|
|
||||||
* @return Invalid pet value (status code 400)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "pet" },
|
|
||||||
value = "Deletes a pet",
|
|
||||||
nickname = "deletePet",
|
|
||||||
notes = "",
|
|
||||||
authorizations = {
|
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
|
||||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 400, message = "Invalid pet value")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.DELETE,
|
|
||||||
value = "/pet/{petId}"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> deletePet(
|
|
||||||
@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId,
|
|
||||||
@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /pet/findByStatus : Finds Pets by status
|
|
||||||
* Multiple status values can be provided with comma separated strings
|
|
||||||
*
|
|
||||||
* @param status Status values that need to be considered for filter (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
* or Invalid status value (status code 400)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "pet" },
|
|
||||||
value = "Finds Pets by status",
|
|
||||||
nickname = "findPetsByStatus",
|
|
||||||
notes = "Multiple status values can be provided with comma separated strings",
|
|
||||||
response = Pet.class,
|
|
||||||
responseContainer = "List",
|
|
||||||
authorizations = {
|
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
|
||||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
|
|
||||||
@ApiResponse(code = 400, message = "Invalid status value")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.GET,
|
|
||||||
value = "/pet/findByStatus",
|
|
||||||
produces = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<List<Pet>> findPetsByStatus(
|
|
||||||
@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status
|
|
||||||
) {
|
|
||||||
getRequest().ifPresent(request -> {
|
|
||||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
|
||||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
|
||||||
String exampleString = "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status> </Pet>";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /pet/findByTags : Finds Pets by tags
|
|
||||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
||||||
*
|
|
||||||
* @param tags Tags to filter by (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
* or Invalid tag value (status code 400)
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "pet" },
|
|
||||||
value = "Finds Pets by tags",
|
|
||||||
nickname = "findPetsByTags",
|
|
||||||
notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
|
|
||||||
response = Pet.class,
|
|
||||||
responseContainer = "List",
|
|
||||||
authorizations = {
|
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
|
||||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
|
|
||||||
@ApiResponse(code = 400, message = "Invalid tag value")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.GET,
|
|
||||||
value = "/pet/findByTags",
|
|
||||||
produces = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<List<Pet>> findPetsByTags(
|
|
||||||
@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags
|
|
||||||
) {
|
|
||||||
getRequest().ifPresent(request -> {
|
|
||||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
|
||||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
|
||||||
String exampleString = "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status> </Pet>";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /pet/{petId} : Find pet by ID
|
|
||||||
* Returns a single pet
|
|
||||||
*
|
|
||||||
* @param petId ID of pet to return (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
* or Invalid ID supplied (status code 400)
|
|
||||||
* or Pet not found (status code 404)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "pet" },
|
|
||||||
value = "Find pet by ID",
|
|
||||||
nickname = "getPetById",
|
|
||||||
notes = "Returns a single pet",
|
|
||||||
response = Pet.class,
|
|
||||||
authorizations = {
|
|
||||||
@Authorization(value = "api_key")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = Pet.class),
|
|
||||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
|
||||||
@ApiResponse(code = 404, message = "Pet not found")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.GET,
|
|
||||||
value = "/pet/{petId}",
|
|
||||||
produces = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Pet> getPetById(
|
|
||||||
@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId
|
|
||||||
) {
|
|
||||||
getRequest().ifPresent(request -> {
|
|
||||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
|
||||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
|
||||||
String exampleString = "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status> </Pet>";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PUT /pet : Update an existing pet
|
|
||||||
*
|
|
||||||
* @param body Pet object that needs to be added to the store (required)
|
|
||||||
* @return Invalid ID supplied (status code 400)
|
|
||||||
* or Pet not found (status code 404)
|
|
||||||
* or Validation exception (status code 405)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "pet" },
|
|
||||||
value = "Update an existing pet",
|
|
||||||
nickname = "updatePet",
|
|
||||||
notes = "",
|
|
||||||
authorizations = {
|
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
|
||||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
|
||||||
@ApiResponse(code = 404, message = "Pet not found"),
|
|
||||||
@ApiResponse(code = 405, message = "Validation exception")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.PUT,
|
|
||||||
value = "/pet",
|
|
||||||
consumes = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> updatePet(
|
|
||||||
@ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet body
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /pet/{petId} : Updates a pet in the store with form data
|
|
||||||
*
|
|
||||||
* @param petId ID of pet that needs to be updated (required)
|
|
||||||
* @param name Updated name of the pet (optional)
|
|
||||||
* @param status Updated status of the pet (optional)
|
|
||||||
* @return Invalid input (status code 405)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "pet" },
|
|
||||||
value = "Updates a pet in the store with form data",
|
|
||||||
nickname = "updatePetWithForm",
|
|
||||||
notes = "",
|
|
||||||
authorizations = {
|
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
|
||||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 405, message = "Invalid input")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.POST,
|
|
||||||
value = "/pet/{petId}",
|
|
||||||
consumes = "application/x-www-form-urlencoded"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> updatePetWithForm(
|
|
||||||
@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId,
|
|
||||||
@ApiParam(value = "Updated name of the pet") @Valid @RequestParam(value = "name", required = false) String name,
|
|
||||||
@ApiParam(value = "Updated status of the pet") @Valid @RequestParam(value = "status", required = false) String status
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /pet/{petId}/uploadImage : uploads an image
|
|
||||||
*
|
|
||||||
* @param petId ID of pet to update (required)
|
|
||||||
* @param additionalMetadata Additional data to pass to server (optional)
|
|
||||||
* @param file file to upload (optional)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "pet" },
|
|
||||||
value = "uploads an image",
|
|
||||||
nickname = "uploadFile",
|
|
||||||
notes = "",
|
|
||||||
response = ModelApiResponse.class,
|
|
||||||
authorizations = {
|
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
|
||||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class)
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.POST,
|
|
||||||
value = "/pet/{petId}/uploadImage",
|
|
||||||
produces = "application/json",
|
|
||||||
consumes = "multipart/form-data"
|
|
||||||
)
|
|
||||||
default ResponseEntity<ModelApiResponse> uploadFile(
|
|
||||||
@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId,
|
|
||||||
@ApiParam(value = "Additional data to pass to server") @Valid @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata,
|
|
||||||
@ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file
|
|
||||||
) {
|
|
||||||
getRequest().ifPresent(request -> {
|
|
||||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
|
||||||
String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,195 +0,0 @@
|
|||||||
/**
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.0.0-SNAPSHOT).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
package org.openapitools.api;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import org.openapitools.model.Order;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.context.request.NativeWebRequest;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
|
|
||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
|
||||||
@Validated
|
|
||||||
@Api(value = "store", description = "Access to Petstore orders")
|
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface StoreApi {
|
|
||||||
|
|
||||||
default Optional<NativeWebRequest> getRequest() {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DELETE /store/order/{orderId} : Delete purchase order by ID
|
|
||||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
|
||||||
*
|
|
||||||
* @param orderId ID of the order that needs to be deleted (required)
|
|
||||||
* @return Invalid ID supplied (status code 400)
|
|
||||||
* or Order not found (status code 404)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "store" },
|
|
||||||
value = "Delete purchase order by ID",
|
|
||||||
nickname = "deleteOrder",
|
|
||||||
notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors"
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
|
||||||
@ApiResponse(code = 404, message = "Order not found")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.DELETE,
|
|
||||||
value = "/store/order/{orderId}"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> deleteOrder(
|
|
||||||
@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /store/inventory : Returns pet inventories by status
|
|
||||||
* Returns a map of status codes to quantities
|
|
||||||
*
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "store" },
|
|
||||||
value = "Returns pet inventories by status",
|
|
||||||
nickname = "getInventory",
|
|
||||||
notes = "Returns a map of status codes to quantities",
|
|
||||||
response = Integer.class,
|
|
||||||
responseContainer = "Map",
|
|
||||||
authorizations = {
|
|
||||||
@Authorization(value = "api_key")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.GET,
|
|
||||||
value = "/store/inventory",
|
|
||||||
produces = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Map<String, Integer>> getInventory(
|
|
||||||
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /store/order/{orderId} : Find purchase order by ID
|
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
|
||||||
*
|
|
||||||
* @param orderId ID of pet that needs to be fetched (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
* or Invalid ID supplied (status code 400)
|
|
||||||
* or Order not found (status code 404)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "store" },
|
|
||||||
value = "Find purchase order by ID",
|
|
||||||
nickname = "getOrderById",
|
|
||||||
notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions",
|
|
||||||
response = Order.class
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
|
||||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
|
||||||
@ApiResponse(code = 404, message = "Order not found")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.GET,
|
|
||||||
value = "/store/order/{orderId}",
|
|
||||||
produces = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Order> getOrderById(
|
|
||||||
@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId
|
|
||||||
) {
|
|
||||||
getRequest().ifPresent(request -> {
|
|
||||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
|
||||||
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
|
||||||
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /store/order : Place an order for a pet
|
|
||||||
*
|
|
||||||
* @param body order placed for purchasing the pet (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
* or Invalid Order (status code 400)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "store" },
|
|
||||||
value = "Place an order for a pet",
|
|
||||||
nickname = "placeOrder",
|
|
||||||
notes = "",
|
|
||||||
response = Order.class
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
|
||||||
@ApiResponse(code = 400, message = "Invalid Order")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.POST,
|
|
||||||
value = "/store/order",
|
|
||||||
produces = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Order> placeOrder(
|
|
||||||
@ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order body
|
|
||||||
) {
|
|
||||||
getRequest().ifPresent(request -> {
|
|
||||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
|
||||||
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
|
||||||
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,294 +0,0 @@
|
|||||||
/**
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.0.0-SNAPSHOT).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
package org.openapitools.api;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import org.openapitools.model.User;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.context.request.NativeWebRequest;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
|
|
||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
|
||||||
@Validated
|
|
||||||
@Api(value = "user", description = "Operations about user")
|
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface UserApi {
|
|
||||||
|
|
||||||
default Optional<NativeWebRequest> getRequest() {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /user : Create user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* @param body Created user object (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "user" },
|
|
||||||
value = "Create user",
|
|
||||||
nickname = "createUser",
|
|
||||||
notes = "This can only be done by the logged in user."
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.POST,
|
|
||||||
value = "/user"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> createUser(
|
|
||||||
@ApiParam(value = "Created user object", required = true) @Valid @RequestBody User body
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /user/createWithArray : Creates list of users with given input array
|
|
||||||
*
|
|
||||||
* @param body List of user object (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "user" },
|
|
||||||
value = "Creates list of users with given input array",
|
|
||||||
nickname = "createUsersWithArrayInput",
|
|
||||||
notes = ""
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.POST,
|
|
||||||
value = "/user/createWithArray"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> createUsersWithArrayInput(
|
|
||||||
@ApiParam(value = "List of user object", required = true) @Valid @RequestBody List<User> body
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /user/createWithList : Creates list of users with given input array
|
|
||||||
*
|
|
||||||
* @param body List of user object (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "user" },
|
|
||||||
value = "Creates list of users with given input array",
|
|
||||||
nickname = "createUsersWithListInput",
|
|
||||||
notes = ""
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.POST,
|
|
||||||
value = "/user/createWithList"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> createUsersWithListInput(
|
|
||||||
@ApiParam(value = "List of user object", required = true) @Valid @RequestBody List<User> body
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DELETE /user/{username} : Delete user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* @param username The name that needs to be deleted (required)
|
|
||||||
* @return Invalid username supplied (status code 400)
|
|
||||||
* or User not found (status code 404)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "user" },
|
|
||||||
value = "Delete user",
|
|
||||||
nickname = "deleteUser",
|
|
||||||
notes = "This can only be done by the logged in user."
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 400, message = "Invalid username supplied"),
|
|
||||||
@ApiResponse(code = 404, message = "User not found")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.DELETE,
|
|
||||||
value = "/user/{username}"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> deleteUser(
|
|
||||||
@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /user/{username} : Get user by user name
|
|
||||||
*
|
|
||||||
* @param username The name that needs to be fetched. Use user1 for testing. (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
* or Invalid username supplied (status code 400)
|
|
||||||
* or User not found (status code 404)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "user" },
|
|
||||||
value = "Get user by user name",
|
|
||||||
nickname = "getUserByName",
|
|
||||||
notes = "",
|
|
||||||
response = User.class
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = User.class),
|
|
||||||
@ApiResponse(code = 400, message = "Invalid username supplied"),
|
|
||||||
@ApiResponse(code = 404, message = "User not found")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.GET,
|
|
||||||
value = "/user/{username}",
|
|
||||||
produces = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<User> getUserByName(
|
|
||||||
@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username
|
|
||||||
) {
|
|
||||||
getRequest().ifPresent(request -> {
|
|
||||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
|
||||||
String exampleString = "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
|
||||||
String exampleString = "<User> <id>123456789</id> <username>aeiou</username> <firstName>aeiou</firstName> <lastName>aeiou</lastName> <email>aeiou</email> <password>aeiou</password> <phone>aeiou</phone> <userStatus>123</userStatus> </User>";
|
|
||||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /user/login : Logs user into the system
|
|
||||||
*
|
|
||||||
* @param username The user name for login (required)
|
|
||||||
* @param password The password for login in clear text (required)
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
* or Invalid username/password supplied (status code 400)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "user" },
|
|
||||||
value = "Logs user into the system",
|
|
||||||
nickname = "loginUser",
|
|
||||||
notes = "",
|
|
||||||
response = String.class
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = String.class),
|
|
||||||
@ApiResponse(code = 400, message = "Invalid username/password supplied")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.GET,
|
|
||||||
value = "/user/login",
|
|
||||||
produces = "application/json"
|
|
||||||
)
|
|
||||||
default ResponseEntity<String> loginUser(
|
|
||||||
@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,
|
|
||||||
@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET /user/logout : Logs out current logged in user session
|
|
||||||
*
|
|
||||||
* @return successful operation (status code 200)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "user" },
|
|
||||||
value = "Logs out current logged in user session",
|
|
||||||
nickname = "logoutUser",
|
|
||||||
notes = ""
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 200, message = "successful operation")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.GET,
|
|
||||||
value = "/user/logout"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> logoutUser(
|
|
||||||
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PUT /user/{username} : Updated user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* @param username name that need to be deleted (required)
|
|
||||||
* @param body Updated user object (required)
|
|
||||||
* @return Invalid user supplied (status code 400)
|
|
||||||
* or User not found (status code 404)
|
|
||||||
*/
|
|
||||||
@ApiOperation(
|
|
||||||
tags = { "user" },
|
|
||||||
value = "Updated user",
|
|
||||||
nickname = "updateUser",
|
|
||||||
notes = "This can only be done by the logged in user."
|
|
||||||
)
|
|
||||||
@ApiResponses({
|
|
||||||
@ApiResponse(code = 400, message = "Invalid user supplied"),
|
|
||||||
@ApiResponse(code = 404, message = "User not found")
|
|
||||||
})
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.PUT,
|
|
||||||
value = "/user/{username}"
|
|
||||||
)
|
|
||||||
default ResponseEntity<Void> updateUser(
|
|
||||||
@ApiParam(value = "name that need to be deleted", required = true) @PathVariable("username") String username,
|
|
||||||
@ApiParam(value = "Updated user object", required = true) @Valid @RequestBody User body
|
|
||||||
) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,109 +0,0 @@
|
|||||||
package org.openapitools.model;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Objects;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.openapitools.jackson.nullable.JsonNullable;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A category for a pet
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModel(description = "A category for a pet")
|
|
||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
|
||||||
public class Category {
|
|
||||||
|
|
||||||
@JsonProperty("id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public Category id(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id
|
|
||||||
* @return id
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Category name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get name
|
|
||||||
* @return name
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Category category = (Category) o;
|
|
||||||
return Objects.equals(this.id, category.id) &&
|
|
||||||
Objects.equals(this.name, category.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("class Category {\n");
|
|
||||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
|
||||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
|
||||||
sb.append("}");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert the given object to string with each line indented by 4 spaces
|
|
||||||
* (except the first line).
|
|
||||||
*/
|
|
||||||
private String toIndentedString(Object o) {
|
|
||||||
if (o == null) {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
return o.toString().replace("\n", "\n ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,135 +0,0 @@
|
|||||||
package org.openapitools.model;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Objects;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.openapitools.jackson.nullable.JsonNullable;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Describes the result of uploading an image resource
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModel(description = "Describes the result of uploading an image resource")
|
|
||||||
@JsonTypeName("ApiResponse")
|
|
||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
|
||||||
public class ModelApiResponse {
|
|
||||||
|
|
||||||
@JsonProperty("code")
|
|
||||||
private Integer code;
|
|
||||||
|
|
||||||
@JsonProperty("type")
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
@JsonProperty("message")
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
public ModelApiResponse code(Integer code) {
|
|
||||||
this.code = code;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get code
|
|
||||||
* @return code
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Integer getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(Integer code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelApiResponse type(String type) {
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get type
|
|
||||||
* @return type
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelApiResponse message(String message) {
|
|
||||||
this.message = message;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get message
|
|
||||||
* @return message
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ModelApiResponse _apiResponse = (ModelApiResponse) o;
|
|
||||||
return Objects.equals(this.code, _apiResponse.code) &&
|
|
||||||
Objects.equals(this.type, _apiResponse.type) &&
|
|
||||||
Objects.equals(this.message, _apiResponse.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(code, type, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("class ModelApiResponse {\n");
|
|
||||||
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
|
||||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
|
||||||
sb.append(" message: ").append(toIndentedString(message)).append("\n");
|
|
||||||
sb.append("}");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert the given object to string with each line indented by 4 spaces
|
|
||||||
* (except the first line).
|
|
||||||
*/
|
|
||||||
private String toIndentedString(Object o) {
|
|
||||||
if (o == null) {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
return o.toString().replace("\n", "\n ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,246 +0,0 @@
|
|||||||
package org.openapitools.model;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Objects;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
import org.openapitools.jackson.nullable.JsonNullable;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An order for a pets from the pet store
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModel(description = "An order for a pets from the pet store")
|
|
||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
|
||||||
public class Order {
|
|
||||||
|
|
||||||
@JsonProperty("id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@JsonProperty("petId")
|
|
||||||
private Long petId;
|
|
||||||
|
|
||||||
@JsonProperty("quantity")
|
|
||||||
private Integer quantity;
|
|
||||||
|
|
||||||
@JsonProperty("shipDate")
|
|
||||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
|
||||||
private OffsetDateTime shipDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Order Status
|
|
||||||
*/
|
|
||||||
public enum StatusEnum {
|
|
||||||
PLACED("placed"),
|
|
||||||
|
|
||||||
APPROVED("approved"),
|
|
||||||
|
|
||||||
DELIVERED("delivered");
|
|
||||||
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
StatusEnum(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonValue
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.valueOf(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonCreator
|
|
||||||
public static StatusEnum fromValue(String value) {
|
|
||||||
for (StatusEnum b : StatusEnum.values()) {
|
|
||||||
if (b.value.equals(value)) {
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty("status")
|
|
||||||
private StatusEnum status;
|
|
||||||
|
|
||||||
@JsonProperty("complete")
|
|
||||||
private Boolean complete = false;
|
|
||||||
|
|
||||||
public Order id(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id
|
|
||||||
* @return id
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Order petId(Long petId) {
|
|
||||||
this.petId = petId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get petId
|
|
||||||
* @return petId
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Long getPetId() {
|
|
||||||
return petId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPetId(Long petId) {
|
|
||||||
this.petId = petId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Order quantity(Integer quantity) {
|
|
||||||
this.quantity = quantity;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get quantity
|
|
||||||
* @return quantity
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Integer getQuantity() {
|
|
||||||
return quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQuantity(Integer quantity) {
|
|
||||||
this.quantity = quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Order shipDate(OffsetDateTime shipDate) {
|
|
||||||
this.shipDate = shipDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get shipDate
|
|
||||||
* @return shipDate
|
|
||||||
*/
|
|
||||||
@Valid
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public OffsetDateTime getShipDate() {
|
|
||||||
return shipDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShipDate(OffsetDateTime shipDate) {
|
|
||||||
this.shipDate = shipDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Order status(StatusEnum status) {
|
|
||||||
this.status = status;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Order Status
|
|
||||||
* @return status
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "Order Status")
|
|
||||||
public StatusEnum getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(StatusEnum status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Order complete(Boolean complete) {
|
|
||||||
this.complete = complete;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get complete
|
|
||||||
* @return complete
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Boolean getComplete() {
|
|
||||||
return complete;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComplete(Boolean complete) {
|
|
||||||
this.complete = complete;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Order order = (Order) o;
|
|
||||||
return Objects.equals(this.id, order.id) &&
|
|
||||||
Objects.equals(this.petId, order.petId) &&
|
|
||||||
Objects.equals(this.quantity, order.quantity) &&
|
|
||||||
Objects.equals(this.shipDate, order.shipDate) &&
|
|
||||||
Objects.equals(this.status, order.status) &&
|
|
||||||
Objects.equals(this.complete, order.complete);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, petId, quantity, shipDate, status, complete);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("class Order {\n");
|
|
||||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
|
||||||
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
|
|
||||||
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
|
|
||||||
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
|
|
||||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
|
||||||
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
|
|
||||||
sb.append("}");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert the given object to string with each line indented by 4 spaces
|
|
||||||
* (except the first line).
|
|
||||||
*/
|
|
||||||
private String toIndentedString(Object o) {
|
|
||||||
if (o == null) {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
return o.toString().replace("\n", "\n ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,262 +0,0 @@
|
|||||||
package org.openapitools.model;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Objects;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import org.openapitools.model.Category;
|
|
||||||
import org.openapitools.model.Tag;
|
|
||||||
import org.openapitools.jackson.nullable.JsonNullable;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A pet for sale in the pet store
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModel(description = "A pet for sale in the pet store")
|
|
||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
|
||||||
public class Pet {
|
|
||||||
|
|
||||||
@JsonProperty("id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@JsonProperty("category")
|
|
||||||
private Category category;
|
|
||||||
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@JsonProperty("photoUrls")
|
|
||||||
@Valid
|
|
||||||
private List<String> photoUrls = new ArrayList<>();
|
|
||||||
|
|
||||||
@JsonProperty("tags")
|
|
||||||
@Valid
|
|
||||||
private List<Tag> tags = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pet status in the store
|
|
||||||
*/
|
|
||||||
public enum StatusEnum {
|
|
||||||
AVAILABLE("available"),
|
|
||||||
|
|
||||||
PENDING("pending"),
|
|
||||||
|
|
||||||
SOLD("sold");
|
|
||||||
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
StatusEnum(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonValue
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.valueOf(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonCreator
|
|
||||||
public static StatusEnum fromValue(String value) {
|
|
||||||
for (StatusEnum b : StatusEnum.values()) {
|
|
||||||
if (b.value.equals(value)) {
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty("status")
|
|
||||||
private StatusEnum status;
|
|
||||||
|
|
||||||
public Pet id(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id
|
|
||||||
* @return id
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pet category(Category category) {
|
|
||||||
this.category = category;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get category
|
|
||||||
* @return category
|
|
||||||
*/
|
|
||||||
@Valid
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Category getCategory() {
|
|
||||||
return category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCategory(Category category) {
|
|
||||||
this.category = category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pet name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get name
|
|
||||||
* @return name
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
@ApiModelProperty(example = "doggie", required = true, value = "")
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pet photoUrls(List<String> photoUrls) {
|
|
||||||
this.photoUrls = photoUrls;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
|
||||||
this.photoUrls.add(photoUrlsItem);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get photoUrls
|
|
||||||
* @return photoUrls
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
@ApiModelProperty(required = true, value = "")
|
|
||||||
public List<String> getPhotoUrls() {
|
|
||||||
return photoUrls;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPhotoUrls(List<String> photoUrls) {
|
|
||||||
this.photoUrls = photoUrls;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pet tags(List<Tag> tags) {
|
|
||||||
this.tags = tags;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pet addTagsItem(Tag tagsItem) {
|
|
||||||
if (this.tags == null) {
|
|
||||||
this.tags = new ArrayList<>();
|
|
||||||
}
|
|
||||||
this.tags.add(tagsItem);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get tags
|
|
||||||
* @return tags
|
|
||||||
*/
|
|
||||||
@Valid
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public List<Tag> getTags() {
|
|
||||||
return tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTags(List<Tag> tags) {
|
|
||||||
this.tags = tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pet status(StatusEnum status) {
|
|
||||||
this.status = status;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pet status in the store
|
|
||||||
* @return status
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "pet status in the store")
|
|
||||||
public StatusEnum getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(StatusEnum status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Pet pet = (Pet) o;
|
|
||||||
return Objects.equals(this.id, pet.id) &&
|
|
||||||
Objects.equals(this.category, pet.category) &&
|
|
||||||
Objects.equals(this.name, pet.name) &&
|
|
||||||
Objects.equals(this.photoUrls, pet.photoUrls) &&
|
|
||||||
Objects.equals(this.tags, pet.tags) &&
|
|
||||||
Objects.equals(this.status, pet.status);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, category, name, photoUrls, tags, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("class Pet {\n");
|
|
||||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
|
||||||
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
|
||||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
|
||||||
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
|
|
||||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
|
||||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
|
||||||
sb.append("}");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert the given object to string with each line indented by 4 spaces
|
|
||||||
* (except the first line).
|
|
||||||
*/
|
|
||||||
private String toIndentedString(Object o) {
|
|
||||||
if (o == null) {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
return o.toString().replace("\n", "\n ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
|||||||
package org.openapitools.model;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Objects;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.openapitools.jackson.nullable.JsonNullable;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A tag for a pet
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModel(description = "A tag for a pet")
|
|
||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
|
||||||
public class Tag {
|
|
||||||
|
|
||||||
@JsonProperty("id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public Tag id(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id
|
|
||||||
* @return id
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tag name(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get name
|
|
||||||
* @return name
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Tag tag = (Tag) o;
|
|
||||||
return Objects.equals(this.id, tag.id) &&
|
|
||||||
Objects.equals(this.name, tag.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("class Tag {\n");
|
|
||||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
|
||||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
|
||||||
sb.append("}");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert the given object to string with each line indented by 4 spaces
|
|
||||||
* (except the first line).
|
|
||||||
*/
|
|
||||||
private String toIndentedString(Object o) {
|
|
||||||
if (o == null) {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
return o.toString().replace("\n", "\n ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,253 +0,0 @@
|
|||||||
package org.openapitools.model;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Objects;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.openapitools.jackson.nullable.JsonNullable;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A User who is purchasing from the pet store
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModel(description = "A User who is purchasing from the pet store")
|
|
||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
|
||||||
public class User {
|
|
||||||
|
|
||||||
@JsonProperty("id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@JsonProperty("username")
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
@JsonProperty("firstName")
|
|
||||||
private String firstName;
|
|
||||||
|
|
||||||
@JsonProperty("lastName")
|
|
||||||
private String lastName;
|
|
||||||
|
|
||||||
@JsonProperty("email")
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
@JsonProperty("password")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@JsonProperty("phone")
|
|
||||||
private String phone;
|
|
||||||
|
|
||||||
@JsonProperty("userStatus")
|
|
||||||
private Integer userStatus;
|
|
||||||
|
|
||||||
public User id(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id
|
|
||||||
* @return id
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User username(String username) {
|
|
||||||
this.username = username;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get username
|
|
||||||
* @return username
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User firstName(String firstName) {
|
|
||||||
this.firstName = firstName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get firstName
|
|
||||||
* @return firstName
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getFirstName() {
|
|
||||||
return firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFirstName(String firstName) {
|
|
||||||
this.firstName = firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User lastName(String lastName) {
|
|
||||||
this.lastName = lastName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get lastName
|
|
||||||
* @return lastName
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getLastName() {
|
|
||||||
return lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastName(String lastName) {
|
|
||||||
this.lastName = lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User email(String email) {
|
|
||||||
this.email = email;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get email
|
|
||||||
* @return email
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getEmail() {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User password(String password) {
|
|
||||||
this.password = password;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get password
|
|
||||||
* @return password
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User phone(String phone) {
|
|
||||||
this.phone = phone;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get phone
|
|
||||||
* @return phone
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "")
|
|
||||||
public String getPhone() {
|
|
||||||
return phone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPhone(String phone) {
|
|
||||||
this.phone = phone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User userStatus(Integer userStatus) {
|
|
||||||
this.userStatus = userStatus;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User Status
|
|
||||||
* @return userStatus
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "User Status")
|
|
||||||
public Integer getUserStatus() {
|
|
||||||
return userStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserStatus(Integer userStatus) {
|
|
||||||
this.userStatus = userStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
User user = (User) o;
|
|
||||||
return Objects.equals(this.id, user.id) &&
|
|
||||||
Objects.equals(this.username, user.username) &&
|
|
||||||
Objects.equals(this.firstName, user.firstName) &&
|
|
||||||
Objects.equals(this.lastName, user.lastName) &&
|
|
||||||
Objects.equals(this.email, user.email) &&
|
|
||||||
Objects.equals(this.password, user.password) &&
|
|
||||||
Objects.equals(this.phone, user.phone) &&
|
|
||||||
Objects.equals(this.userStatus, user.userStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("class User {\n");
|
|
||||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
|
||||||
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
|
||||||
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
|
|
||||||
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
|
|
||||||
sb.append(" email: ").append(toIndentedString(email)).append("\n");
|
|
||||||
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
|
||||||
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
|
||||||
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
|
||||||
sb.append("}");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert the given object to string with each line indented by 4 spaces
|
|
||||||
* (except the first line).
|
|
||||||
*/
|
|
||||||
private String toIndentedString(Object o) {
|
|
||||||
if (o == null) {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
return o.toString().replace("\n", "\n ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
5
samples/client/petstore/tiny/cpp/.gitignore
vendored
5
samples/client/petstore/tiny/cpp/.gitignore
vendored
@ -1,5 +0,0 @@
|
|||||||
.pio
|
|
||||||
.vscode/.browse.c_cpp.db*
|
|
||||||
.vscode/c_cpp_properties.json
|
|
||||||
.vscode/launch.json
|
|
||||||
.vscode/ipch
|
|
@ -1,23 +0,0 @@
|
|||||||
# 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
|
|
@ -1,30 +0,0 @@
|
|||||||
README.md
|
|
||||||
README.md
|
|
||||||
lib/Models/ApiResponse.cpp
|
|
||||||
lib/Models/ApiResponse.h
|
|
||||||
lib/Models/Category.cpp
|
|
||||||
lib/Models/Category.h
|
|
||||||
lib/Models/Helpers.cpp
|
|
||||||
lib/Models/Helpers.h
|
|
||||||
lib/Models/Order.cpp
|
|
||||||
lib/Models/Order.h
|
|
||||||
lib/Models/Pet.cpp
|
|
||||||
lib/Models/Pet.h
|
|
||||||
lib/Models/Tag.cpp
|
|
||||||
lib/Models/Tag.h
|
|
||||||
lib/Models/User.cpp
|
|
||||||
lib/Models/User.h
|
|
||||||
lib/service/AbstractService.cpp
|
|
||||||
lib/service/AbstractService.h
|
|
||||||
lib/service/PetApi.cpp
|
|
||||||
lib/service/PetApi.h
|
|
||||||
lib/service/Response.h
|
|
||||||
lib/service/StoreApi.cpp
|
|
||||||
lib/service/StoreApi.h
|
|
||||||
lib/service/UserApi.cpp
|
|
||||||
lib/service/UserApi.h
|
|
||||||
platformio.ini
|
|
||||||
pre_compiling_bourne.py
|
|
||||||
root.cert
|
|
||||||
src/main.cpp
|
|
||||||
test/RunTests.cpp
|
|
@ -1 +0,0 @@
|
|||||||
6.0.0-SNAPSHOT
|
|
@ -1,73 +0,0 @@
|
|||||||
# Documentation for OpenAPI Petstore
|
|
||||||
This is a client generator for microcontrollers on the Espressif32 platform and the Arduino framework
|
|
||||||
After the client have been generated, you have to change these following variables:
|
|
||||||
- root.cert | Provide your service root certificate.
|
|
||||||
- src/main.cpp | Change wifi name
|
|
||||||
- src/main.cpp | Change wifi password
|
|
||||||
- lib/service/AbstractService.h | Change to your url
|
|
||||||
|
|
||||||
# Documentation for OpenAPI Petstore 1.0.0 Tiny client cpp (Arduino)
|
|
||||||
|
|
||||||
The project is structured like this:
|
|
||||||
```
|
|
||||||
samples/client/petstore/tiny/cpp/
|
|
||||||
├── lib
|
|
||||||
│ ├── Models
|
|
||||||
│ ├── service
|
|
||||||
│ └── TestFiles
|
|
||||||
├── platformio.ini
|
|
||||||
├── pre_compiling_bourne.py
|
|
||||||
├── README.md
|
|
||||||
├── root.cert
|
|
||||||
├── src
|
|
||||||
│ └── main.cpp
|
|
||||||
└── test
|
|
||||||
└── RunTests.cpp
|
|
||||||
```
|
|
||||||
|
|
||||||
All URIs are relative to http://petstore.swagger.iohttp://petstore.swagger.io/v2
|
|
||||||
|
|
||||||
### PetApi
|
|
||||||
|Method | HTTP request | Description|
|
|
||||||
|------------- | ------------- | -------------|
|
|
||||||
|*addPet* | *POST* /pet | Add a new pet to the store.|
|
|
||||||
|*deletePet* | *DELETE* /pet/{petId} | Deletes a pet.|
|
|
||||||
|*findPetsByStatus* | *GET* /pet/findByStatus | Finds Pets by status.|
|
|
||||||
|*findPetsByTags* | *GET* /pet/findByTags | Finds Pets by tags.|
|
|
||||||
|*getPetById* | *GET* /pet/{petId} | Find pet by ID.|
|
|
||||||
|*updatePet* | *PUT* /pet | Update an existing pet.|
|
|
||||||
|*updatePetWithForm* | *POST* /pet/{petId} | Updates a pet in the store with form data.|
|
|
||||||
|*uploadFile* | *POST* /pet/{petId}/uploadImage | uploads an image.|
|
|
||||||
|
|
||||||
### StoreApi
|
|
||||||
|Method | HTTP request | Description|
|
|
||||||
|------------- | ------------- | -------------|
|
|
||||||
|*deleteOrder* | *DELETE* /store/order/{orderId} | Delete purchase order by ID.|
|
|
||||||
|*getInventory* | *GET* /store/inventory | Returns pet inventories by status.|
|
|
||||||
|*getOrderById* | *GET* /store/order/{orderId} | Find purchase order by ID.|
|
|
||||||
|*placeOrder* | *POST* /store/order | Place an order for a pet.|
|
|
||||||
|
|
||||||
### UserApi
|
|
||||||
|Method | HTTP request | Description|
|
|
||||||
|------------- | ------------- | -------------|
|
|
||||||
|*createUser* | *POST* /user | Create user.|
|
|
||||||
|*createUsersWithArrayInput* | *POST* /user/createWithArray | Creates list of users with given input array.|
|
|
||||||
|*createUsersWithListInput* | *POST* /user/createWithList | Creates list of users with given input array.|
|
|
||||||
|*deleteUser* | *DELETE* /user/{username} | Delete user.|
|
|
||||||
|*getUserByName* | *GET* /user/{username} | Get user by user name.|
|
|
||||||
|*loginUser* | *GET* /user/login | Logs user into the system.|
|
|
||||||
|*logoutUser* | *GET* /user/logout | Logs out current logged in user session.|
|
|
||||||
|*updateUser* | *PUT* /user/{username} | Updated user.|
|
|
||||||
|
|
||||||
|
|
||||||
## What are the Model files for the data structures/objects?
|
|
||||||
|Class | Description|
|
|
||||||
|------------- | -------------|
|
|
||||||
|*ApiResponse* | Describes the result of uploading an image resource|
|
|
||||||
|*Category* | A category for a pet|
|
|
||||||
|*Order* | An order for a pets from the pet store|
|
|
||||||
|*Pet* | A pet for sale in the pet store|
|
|
||||||
|*Tag* | A tag for a pet|
|
|
||||||
|*User* | A User who is purchasing from the pet store|
|
|
||||||
|
|
||||||
|
|
@ -1,139 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "ApiResponse.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
ApiResponse::ApiResponse()
|
|
||||||
{
|
|
||||||
code = int(0);
|
|
||||||
type = std::string();
|
|
||||||
message = std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
ApiResponse::ApiResponse(std::string jsonString)
|
|
||||||
{
|
|
||||||
this->fromJson(jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
ApiResponse::~ApiResponse()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ApiResponse::fromJson(std::string jsonObj)
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::parse(jsonObj);
|
|
||||||
|
|
||||||
const char *codeKey = "code";
|
|
||||||
|
|
||||||
if(object.has_key(codeKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[codeKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&code, value, "int");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *typeKey = "type";
|
|
||||||
|
|
||||||
if(object.has_key(typeKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[typeKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&type, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *messageKey = "message";
|
|
||||||
|
|
||||||
if(object.has_key(messageKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[messageKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&message, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bourne::json
|
|
||||||
ApiResponse::toJson()
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::object();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["code"] = getCode();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["type"] = getType();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["message"] = getMessage();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return object;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
ApiResponse::getCode()
|
|
||||||
{
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ApiResponse::setCode(int code)
|
|
||||||
{
|
|
||||||
this->code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
ApiResponse::getType()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ApiResponse::setType(std::string type)
|
|
||||||
{
|
|
||||||
this->type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
ApiResponse::getMessage()
|
|
||||||
{
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ApiResponse::setMessage(std::string message)
|
|
||||||
{
|
|
||||||
this->message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* ApiResponse.h
|
|
||||||
*
|
|
||||||
* Describes the result of uploading an image resource
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TINY_CPP_CLIENT_ApiResponse_H_
|
|
||||||
#define TINY_CPP_CLIENT_ApiResponse_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
#include "Helpers.h"
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Describes the result of uploading an image resource
|
|
||||||
*
|
|
||||||
* \ingroup Models
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ApiResponse{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*! \brief Constructor.
|
|
||||||
*/
|
|
||||||
ApiResponse();
|
|
||||||
ApiResponse(std::string jsonString);
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Destructor.
|
|
||||||
*/
|
|
||||||
virtual ~ApiResponse();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Retrieve a bourne JSON representation of this class.
|
|
||||||
*/
|
|
||||||
bourne::json toJson();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Fills in members of this class from bourne JSON object representing it.
|
|
||||||
*/
|
|
||||||
void fromJson(std::string jsonObj);
|
|
||||||
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
int getCode();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setCode(int code);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getType();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setType(std::string type);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getMessage();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setMessage(std::string message);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
int code{};
|
|
||||||
std::string type{};
|
|
||||||
std::string message{};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_ApiResponse_H_ */
|
|
@ -1,106 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Category.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
Category::Category()
|
|
||||||
{
|
|
||||||
id = long(0);
|
|
||||||
name = std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
Category::Category(std::string jsonString)
|
|
||||||
{
|
|
||||||
this->fromJson(jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
Category::~Category()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Category::fromJson(std::string jsonObj)
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::parse(jsonObj);
|
|
||||||
|
|
||||||
const char *idKey = "id";
|
|
||||||
|
|
||||||
if(object.has_key(idKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[idKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&id, value, "long");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *nameKey = "name";
|
|
||||||
|
|
||||||
if(object.has_key(nameKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[nameKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&name, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bourne::json
|
|
||||||
Category::toJson()
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::object();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["id"] = getId();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["name"] = getName();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return object;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
long
|
|
||||||
Category::getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Category::setId(long id)
|
|
||||||
{
|
|
||||||
this->id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
Category::getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Category::setName(std::string name)
|
|
||||||
{
|
|
||||||
this->name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Category.h
|
|
||||||
*
|
|
||||||
* A category for a pet
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TINY_CPP_CLIENT_Category_H_
|
|
||||||
#define TINY_CPP_CLIENT_Category_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
#include "Helpers.h"
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief A category for a pet
|
|
||||||
*
|
|
||||||
* \ingroup Models
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Category{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*! \brief Constructor.
|
|
||||||
*/
|
|
||||||
Category();
|
|
||||||
Category(std::string jsonString);
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Destructor.
|
|
||||||
*/
|
|
||||||
virtual ~Category();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Retrieve a bourne JSON representation of this class.
|
|
||||||
*/
|
|
||||||
bourne::json toJson();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Fills in members of this class from bourne JSON object representing it.
|
|
||||||
*/
|
|
||||||
void fromJson(std::string jsonObj);
|
|
||||||
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
long getId();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setId(long id);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getName();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setName(std::string name);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
long id{};
|
|
||||||
std::string name{};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_Category_H_ */
|
|
@ -1,102 +0,0 @@
|
|||||||
#include "Helpers.h"
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
bool isprimitive(std::string type){
|
|
||||||
if(type == "std::string" ||
|
|
||||||
type == "int" ||
|
|
||||||
type == "float" ||
|
|
||||||
type == "long" ||
|
|
||||||
type == "double" ||
|
|
||||||
type == "bool" ||
|
|
||||||
type == "std::map" ||
|
|
||||||
type == "std::list")
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
jsonToValue(void* target, bourne::json value, std::string type)
|
|
||||||
{
|
|
||||||
if (target == NULL || value.is_null()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (type.compare("bool") == 0)
|
|
||||||
{
|
|
||||||
bool* val = static_cast<bool*> (target);
|
|
||||||
*val = value.to_bool();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (type.compare("int") == 0)
|
|
||||||
{
|
|
||||||
int* val = static_cast<int*> (target);
|
|
||||||
*val = value.to_int();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (type.compare("float") == 0)
|
|
||||||
{
|
|
||||||
float* val = static_cast<float*> (target);
|
|
||||||
*val = (float)(value.to_float());
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (type.compare("long") == 0)
|
|
||||||
{
|
|
||||||
long* val = static_cast<long*> (target);
|
|
||||||
*val = (long)(value.to_int());
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (type.compare("double") == 0)
|
|
||||||
{
|
|
||||||
double* val = static_cast<double*> (target);
|
|
||||||
*val = value.to_float();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (type.compare("std::string") == 0)
|
|
||||||
{
|
|
||||||
std::string* val = static_cast<std::string*> (target);
|
|
||||||
*val = value.to_string();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
stringify(long input){
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << input;
|
|
||||||
return stream.str();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string
|
|
||||||
stringify(int input){
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << input;
|
|
||||||
return stream.str();
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string
|
|
||||||
stringify(double input){
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << input;
|
|
||||||
return stream.str();
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string
|
|
||||||
stringify(float input){
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << input;
|
|
||||||
return stream.str();
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string
|
|
||||||
stringify(std::string input){
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << input;
|
|
||||||
return stream.str();
|
|
||||||
};
|
|
@ -1,22 +0,0 @@
|
|||||||
#ifndef TINY_CPP_CLIENT_HELPERS_H_
|
|
||||||
#define TINY_CPP_CLIENT_HELPERS_H_
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
|
|
||||||
bool isprimitive(std::string type);
|
|
||||||
|
|
||||||
void jsonToValue(void* target, bourne::json value, std::string type);
|
|
||||||
|
|
||||||
std::string stringify(long input);
|
|
||||||
|
|
||||||
std::string stringify(int input);
|
|
||||||
|
|
||||||
std::string stringify(double input);
|
|
||||||
|
|
||||||
std::string stringify(float input);
|
|
||||||
|
|
||||||
std::string stringify(std::string input);
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_HELPERS_H_ */
|
|
||||||
|
|
@ -1,238 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Order.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
Order::Order()
|
|
||||||
{
|
|
||||||
id = long(0);
|
|
||||||
petId = long(0);
|
|
||||||
quantity = int(0);
|
|
||||||
shipDate = std::string();
|
|
||||||
status = std::string();
|
|
||||||
complete = bool(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Order::Order(std::string jsonString)
|
|
||||||
{
|
|
||||||
this->fromJson(jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
Order::~Order()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Order::fromJson(std::string jsonObj)
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::parse(jsonObj);
|
|
||||||
|
|
||||||
const char *idKey = "id";
|
|
||||||
|
|
||||||
if(object.has_key(idKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[idKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&id, value, "long");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *petIdKey = "petId";
|
|
||||||
|
|
||||||
if(object.has_key(petIdKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[petIdKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&petId, value, "long");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *quantityKey = "quantity";
|
|
||||||
|
|
||||||
if(object.has_key(quantityKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[quantityKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&quantity, value, "int");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *shipDateKey = "shipDate";
|
|
||||||
|
|
||||||
if(object.has_key(shipDateKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[shipDateKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&shipDate, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *statusKey = "status";
|
|
||||||
|
|
||||||
if(object.has_key(statusKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[statusKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&status, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *completeKey = "complete";
|
|
||||||
|
|
||||||
if(object.has_key(completeKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[completeKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&complete, value, "bool");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bourne::json
|
|
||||||
Order::toJson()
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::object();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["id"] = getId();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["petId"] = getPetId();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["quantity"] = getQuantity();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["shipDate"] = getShipDate();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["status"] = getStatus();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["complete"] = isComplete();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return object;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
long
|
|
||||||
Order::getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Order::setId(long id)
|
|
||||||
{
|
|
||||||
this->id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
long
|
|
||||||
Order::getPetId()
|
|
||||||
{
|
|
||||||
return petId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Order::setPetId(long petId)
|
|
||||||
{
|
|
||||||
this->petId = petId;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
Order::getQuantity()
|
|
||||||
{
|
|
||||||
return quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Order::setQuantity(int quantity)
|
|
||||||
{
|
|
||||||
this->quantity = quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
Order::getShipDate()
|
|
||||||
{
|
|
||||||
return shipDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Order::setShipDate(std::string shipDate)
|
|
||||||
{
|
|
||||||
this->shipDate = shipDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
Order::getStatus()
|
|
||||||
{
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Order::setStatus(std::string status)
|
|
||||||
{
|
|
||||||
this->status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
Order::isComplete()
|
|
||||||
{
|
|
||||||
return complete;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Order::setComplete(bool complete)
|
|
||||||
{
|
|
||||||
this->complete = complete;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Order.h
|
|
||||||
*
|
|
||||||
* An order for a pets from the pet store
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TINY_CPP_CLIENT_Order_H_
|
|
||||||
#define TINY_CPP_CLIENT_Order_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
#include "Helpers.h"
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief An order for a pets from the pet store
|
|
||||||
*
|
|
||||||
* \ingroup Models
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Order{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*! \brief Constructor.
|
|
||||||
*/
|
|
||||||
Order();
|
|
||||||
Order(std::string jsonString);
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Destructor.
|
|
||||||
*/
|
|
||||||
virtual ~Order();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Retrieve a bourne JSON representation of this class.
|
|
||||||
*/
|
|
||||||
bourne::json toJson();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Fills in members of this class from bourne JSON object representing it.
|
|
||||||
*/
|
|
||||||
void fromJson(std::string jsonObj);
|
|
||||||
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
long getId();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setId(long id);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
long getPetId();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setPetId(long petId);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
int getQuantity();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setQuantity(int quantity);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getShipDate();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setShipDate(std::string shipDate);
|
|
||||||
/*! \brief Get Order Status
|
|
||||||
*/
|
|
||||||
std::string getStatus();
|
|
||||||
|
|
||||||
/*! \brief Set Order Status
|
|
||||||
*/
|
|
||||||
void setStatus(std::string status);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
bool isComplete();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setComplete(bool complete);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
long id{};
|
|
||||||
long petId{};
|
|
||||||
int quantity{};
|
|
||||||
std::string shipDate{};
|
|
||||||
std::string status{};
|
|
||||||
bool complete{};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_Order_H_ */
|
|
@ -1,274 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Pet.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
Pet::Pet()
|
|
||||||
{
|
|
||||||
id = long(0);
|
|
||||||
category = Category();
|
|
||||||
name = std::string();
|
|
||||||
photoUrls = std::list<std::string>();
|
|
||||||
tags = std::list<Tag>();
|
|
||||||
status = std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
Pet::Pet(std::string jsonString)
|
|
||||||
{
|
|
||||||
this->fromJson(jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
Pet::~Pet()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Pet::fromJson(std::string jsonObj)
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::parse(jsonObj);
|
|
||||||
|
|
||||||
const char *idKey = "id";
|
|
||||||
|
|
||||||
if(object.has_key(idKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[idKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&id, value, "long");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *categoryKey = "category";
|
|
||||||
|
|
||||||
if(object.has_key(categoryKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[categoryKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Category* obj = &category;
|
|
||||||
obj->fromJson(value.dump());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *nameKey = "name";
|
|
||||||
|
|
||||||
if(object.has_key(nameKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[nameKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&name, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *photoUrlsKey = "photoUrls";
|
|
||||||
|
|
||||||
if(object.has_key(photoUrlsKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[photoUrlsKey];
|
|
||||||
|
|
||||||
|
|
||||||
std::list<std::string> photoUrls_list;
|
|
||||||
std::string element;
|
|
||||||
for(auto& var : value.array_range())
|
|
||||||
{
|
|
||||||
|
|
||||||
jsonToValue(&element, var, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
photoUrls_list.push_back(element);
|
|
||||||
}
|
|
||||||
photoUrls = photoUrls_list;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *tagsKey = "tags";
|
|
||||||
|
|
||||||
if(object.has_key(tagsKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[tagsKey];
|
|
||||||
|
|
||||||
|
|
||||||
std::list<Tag> tags_list;
|
|
||||||
Tag element;
|
|
||||||
for(auto& var : value.array_range())
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
element.fromJson(var.dump());
|
|
||||||
|
|
||||||
tags_list.push_back(element);
|
|
||||||
}
|
|
||||||
tags = tags_list;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *statusKey = "status";
|
|
||||||
|
|
||||||
if(object.has_key(statusKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[statusKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&status, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bourne::json
|
|
||||||
Pet::toJson()
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::object();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["id"] = getId();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["category"] = getCategory().toJson();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["name"] = getName();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::list<std::string> photoUrls_list = getPhotoUrls();
|
|
||||||
bourne::json photoUrls_arr = bourne::json::array();
|
|
||||||
|
|
||||||
for(auto& var : photoUrls_list)
|
|
||||||
{
|
|
||||||
photoUrls_arr.append(var);
|
|
||||||
}
|
|
||||||
object["photoUrls"] = photoUrls_arr;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::list<Tag> tags_list = getTags();
|
|
||||||
bourne::json tags_arr = bourne::json::array();
|
|
||||||
|
|
||||||
for(auto& var : tags_list)
|
|
||||||
{
|
|
||||||
Tag obj = var;
|
|
||||||
tags_arr.append(obj.toJson());
|
|
||||||
}
|
|
||||||
object["tags"] = tags_arr;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["status"] = getStatus();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return object;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
long
|
|
||||||
Pet::getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Pet::setId(long id)
|
|
||||||
{
|
|
||||||
this->id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
Category
|
|
||||||
Pet::getCategory()
|
|
||||||
{
|
|
||||||
return category;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Pet::setCategory(Category category)
|
|
||||||
{
|
|
||||||
this->category = category;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
Pet::getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Pet::setName(std::string name)
|
|
||||||
{
|
|
||||||
this->name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<std::string>
|
|
||||||
Pet::getPhotoUrls()
|
|
||||||
{
|
|
||||||
return photoUrls;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Pet::setPhotoUrls(std::list <std::string> photoUrls)
|
|
||||||
{
|
|
||||||
this->photoUrls = photoUrls;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<Tag>
|
|
||||||
Pet::getTags()
|
|
||||||
{
|
|
||||||
return tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Pet::setTags(std::list <Tag> tags)
|
|
||||||
{
|
|
||||||
this->tags = tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
Pet::getStatus()
|
|
||||||
{
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Pet::setStatus(std::string status)
|
|
||||||
{
|
|
||||||
this->status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Pet.h
|
|
||||||
*
|
|
||||||
* A pet for sale in the pet store
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TINY_CPP_CLIENT_Pet_H_
|
|
||||||
#define TINY_CPP_CLIENT_Pet_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
#include "Helpers.h"
|
|
||||||
#include "Category.h"
|
|
||||||
#include "Tag.h"
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief A pet for sale in the pet store
|
|
||||||
*
|
|
||||||
* \ingroup Models
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Pet{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*! \brief Constructor.
|
|
||||||
*/
|
|
||||||
Pet();
|
|
||||||
Pet(std::string jsonString);
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Destructor.
|
|
||||||
*/
|
|
||||||
virtual ~Pet();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Retrieve a bourne JSON representation of this class.
|
|
||||||
*/
|
|
||||||
bourne::json toJson();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Fills in members of this class from bourne JSON object representing it.
|
|
||||||
*/
|
|
||||||
void fromJson(std::string jsonObj);
|
|
||||||
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
long getId();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setId(long id);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
Category getCategory();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setCategory(Category category);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getName();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setName(std::string name);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::list<std::string> getPhotoUrls();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setPhotoUrls(std::list <std::string> photoUrls);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::list<Tag> getTags();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setTags(std::list <Tag> tags);
|
|
||||||
/*! \brief Get pet status in the store
|
|
||||||
*/
|
|
||||||
std::string getStatus();
|
|
||||||
|
|
||||||
/*! \brief Set pet status in the store
|
|
||||||
*/
|
|
||||||
void setStatus(std::string status);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
long id{};
|
|
||||||
Category category;
|
|
||||||
std::string name{};
|
|
||||||
std::list<std::string> photoUrls;
|
|
||||||
std::list<Tag> tags;
|
|
||||||
std::string status{};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_Pet_H_ */
|
|
@ -1,106 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Tag.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
Tag::Tag()
|
|
||||||
{
|
|
||||||
id = long(0);
|
|
||||||
name = std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
Tag::Tag(std::string jsonString)
|
|
||||||
{
|
|
||||||
this->fromJson(jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
Tag::~Tag()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Tag::fromJson(std::string jsonObj)
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::parse(jsonObj);
|
|
||||||
|
|
||||||
const char *idKey = "id";
|
|
||||||
|
|
||||||
if(object.has_key(idKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[idKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&id, value, "long");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *nameKey = "name";
|
|
||||||
|
|
||||||
if(object.has_key(nameKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[nameKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&name, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bourne::json
|
|
||||||
Tag::toJson()
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::object();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["id"] = getId();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["name"] = getName();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return object;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
long
|
|
||||||
Tag::getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Tag::setId(long id)
|
|
||||||
{
|
|
||||||
this->id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
Tag::getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Tag::setName(std::string name)
|
|
||||||
{
|
|
||||||
this->name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Tag.h
|
|
||||||
*
|
|
||||||
* A tag for a pet
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TINY_CPP_CLIENT_Tag_H_
|
|
||||||
#define TINY_CPP_CLIENT_Tag_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
#include "Helpers.h"
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief A tag for a pet
|
|
||||||
*
|
|
||||||
* \ingroup Models
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Tag{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*! \brief Constructor.
|
|
||||||
*/
|
|
||||||
Tag();
|
|
||||||
Tag(std::string jsonString);
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Destructor.
|
|
||||||
*/
|
|
||||||
virtual ~Tag();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Retrieve a bourne JSON representation of this class.
|
|
||||||
*/
|
|
||||||
bourne::json toJson();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Fills in members of this class from bourne JSON object representing it.
|
|
||||||
*/
|
|
||||||
void fromJson(std::string jsonObj);
|
|
||||||
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
long getId();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setId(long id);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getName();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setName(std::string name);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
long id{};
|
|
||||||
std::string name{};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_Tag_H_ */
|
|
@ -1,304 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "User.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
User::User()
|
|
||||||
{
|
|
||||||
id = long(0);
|
|
||||||
username = std::string();
|
|
||||||
firstName = std::string();
|
|
||||||
lastName = std::string();
|
|
||||||
email = std::string();
|
|
||||||
password = std::string();
|
|
||||||
phone = std::string();
|
|
||||||
userStatus = int(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
User::User(std::string jsonString)
|
|
||||||
{
|
|
||||||
this->fromJson(jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
User::~User()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
User::fromJson(std::string jsonObj)
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::parse(jsonObj);
|
|
||||||
|
|
||||||
const char *idKey = "id";
|
|
||||||
|
|
||||||
if(object.has_key(idKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[idKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&id, value, "long");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *usernameKey = "username";
|
|
||||||
|
|
||||||
if(object.has_key(usernameKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[usernameKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&username, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *firstNameKey = "firstName";
|
|
||||||
|
|
||||||
if(object.has_key(firstNameKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[firstNameKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&firstName, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *lastNameKey = "lastName";
|
|
||||||
|
|
||||||
if(object.has_key(lastNameKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[lastNameKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&lastName, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *emailKey = "email";
|
|
||||||
|
|
||||||
if(object.has_key(emailKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[emailKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&email, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *passwordKey = "password";
|
|
||||||
|
|
||||||
if(object.has_key(passwordKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[passwordKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&password, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *phoneKey = "phone";
|
|
||||||
|
|
||||||
if(object.has_key(phoneKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[phoneKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&phone, value, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *userStatusKey = "userStatus";
|
|
||||||
|
|
||||||
if(object.has_key(userStatusKey))
|
|
||||||
{
|
|
||||||
bourne::json value = object[userStatusKey];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jsonToValue(&userStatus, value, "int");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bourne::json
|
|
||||||
User::toJson()
|
|
||||||
{
|
|
||||||
bourne::json object = bourne::json::object();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["id"] = getId();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["username"] = getUsername();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["firstName"] = getFirstName();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["lastName"] = getLastName();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["email"] = getEmail();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["password"] = getPassword();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["phone"] = getPhone();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
object["userStatus"] = getUserStatus();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return object;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
long
|
|
||||||
User::getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
User::setId(long id)
|
|
||||||
{
|
|
||||||
this->id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
User::getUsername()
|
|
||||||
{
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
User::setUsername(std::string username)
|
|
||||||
{
|
|
||||||
this->username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
User::getFirstName()
|
|
||||||
{
|
|
||||||
return firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
User::setFirstName(std::string firstName)
|
|
||||||
{
|
|
||||||
this->firstName = firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
User::getLastName()
|
|
||||||
{
|
|
||||||
return lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
User::setLastName(std::string lastName)
|
|
||||||
{
|
|
||||||
this->lastName = lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
User::getEmail()
|
|
||||||
{
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
User::setEmail(std::string email)
|
|
||||||
{
|
|
||||||
this->email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
User::getPassword()
|
|
||||||
{
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
User::setPassword(std::string password)
|
|
||||||
{
|
|
||||||
this->password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
|
||||||
User::getPhone()
|
|
||||||
{
|
|
||||||
return phone;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
User::setPhone(std::string phone)
|
|
||||||
{
|
|
||||||
this->phone = phone;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
User::getUserStatus()
|
|
||||||
{
|
|
||||||
return userStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
User::setUserStatus(int userStatus)
|
|
||||||
{
|
|
||||||
this->userStatus = userStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* User.h
|
|
||||||
*
|
|
||||||
* A User who is purchasing from the pet store
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TINY_CPP_CLIENT_User_H_
|
|
||||||
#define TINY_CPP_CLIENT_User_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
#include "Helpers.h"
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief A User who is purchasing from the pet store
|
|
||||||
*
|
|
||||||
* \ingroup Models
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class User{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*! \brief Constructor.
|
|
||||||
*/
|
|
||||||
User();
|
|
||||||
User(std::string jsonString);
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Destructor.
|
|
||||||
*/
|
|
||||||
virtual ~User();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Retrieve a bourne JSON representation of this class.
|
|
||||||
*/
|
|
||||||
bourne::json toJson();
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Fills in members of this class from bourne JSON object representing it.
|
|
||||||
*/
|
|
||||||
void fromJson(std::string jsonObj);
|
|
||||||
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
long getId();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setId(long id);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getUsername();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setUsername(std::string username);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getFirstName();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setFirstName(std::string firstName);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getLastName();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setLastName(std::string lastName);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getEmail();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setEmail(std::string email);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getPassword();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setPassword(std::string password);
|
|
||||||
/*! \brief Get
|
|
||||||
*/
|
|
||||||
std::string getPhone();
|
|
||||||
|
|
||||||
/*! \brief Set
|
|
||||||
*/
|
|
||||||
void setPhone(std::string phone);
|
|
||||||
/*! \brief Get User Status
|
|
||||||
*/
|
|
||||||
int getUserStatus();
|
|
||||||
|
|
||||||
/*! \brief Set User Status
|
|
||||||
*/
|
|
||||||
void setUserStatus(int userStatus);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
long id{};
|
|
||||||
std::string username{};
|
|
||||||
std::string firstName{};
|
|
||||||
std::string lastName{};
|
|
||||||
std::string email{};
|
|
||||||
std::string password{};
|
|
||||||
std::string phone{};
|
|
||||||
int userStatus{};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_User_H_ */
|
|
@ -1,139 +0,0 @@
|
|||||||
|
|
||||||
#include "ApiResponse.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <list>
|
|
||||||
#include <unity.h>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_ApiResponse_code_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"code", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
ApiResponse obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(1, obj.getCode());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_ApiResponse_type_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"type", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
ApiResponse obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getType().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_ApiResponse_message_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"message", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
ApiResponse obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getMessage().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_ApiResponse_code_is_converted_to_json()
|
|
||||||
{
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"code", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
ApiResponse obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["code"] == output["code"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_ApiResponse_type_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"type", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
ApiResponse obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["type"] == output["type"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_ApiResponse_message_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"message", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
ApiResponse obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["message"] == output["message"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
|||||||
|
|
||||||
#include "Category.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <list>
|
|
||||||
#include <unity.h>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Category_id_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Category obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(1, obj.getId());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Category_name_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"name", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Category obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getName().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Category_id_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Category obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["id"] == output["id"]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Category_name_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"name", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Category obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["name"] == output["name"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,245 +0,0 @@
|
|||||||
|
|
||||||
#include "Order.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <list>
|
|
||||||
#include <unity.h>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_id_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(1, obj.getId());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_petId_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"petId", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(1, obj.getPetId());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_quantity_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"quantity", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(1, obj.getQuantity());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_shipDate_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_status_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"status", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getStatus().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_complete_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"complete", true
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT(true == obj.isComplete());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_id_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["id"] == output["id"]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_petId_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"petId", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["petId"] == output["petId"]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_quantity_is_converted_to_json()
|
|
||||||
{
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"quantity", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["quantity"] == output["quantity"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_shipDate_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_status_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"status", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["status"] == output["status"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Order_complete_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"complete", true
|
|
||||||
};
|
|
||||||
|
|
||||||
Order obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["complete"] == output["complete"]);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,145 +0,0 @@
|
|||||||
|
|
||||||
#include "Pet.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <list>
|
|
||||||
#include <unity.h>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Pet_id_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Pet obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(1, obj.getId());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Pet_name_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"name", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Pet obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getName().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Pet_status_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"status", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Pet obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getStatus().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Pet_id_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Pet obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["id"] == output["id"]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Pet_name_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"name", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Pet obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["name"] == output["name"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Pet_status_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"status", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Pet obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["status"] == output["status"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
|||||||
|
|
||||||
#include "Tag.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <list>
|
|
||||||
#include <unity.h>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Tag_id_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Tag obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(1, obj.getId());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Tag_name_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"name", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Tag obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getName().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_Tag_id_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Tag obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["id"] == output["id"]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_Tag_name_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"name", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
Tag obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["name"] == output["name"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,349 +0,0 @@
|
|||||||
|
|
||||||
#include "User.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <list>
|
|
||||||
#include <unity.h>
|
|
||||||
#include "bourne/json.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_id_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(1, obj.getId());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_username_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"username", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getUsername().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_firstName_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"firstName", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getFirstName().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_lastName_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"lastName", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getLastName().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_email_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"email", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getEmail().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_password_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"password", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getPassword().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_phone_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"phone", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING("hello", obj.getPhone().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_userStatus_is_assigned_from_json()
|
|
||||||
{
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"userStatus", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(1, obj.getUserStatus());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_id_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"id", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["id"] == output["id"]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_username_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"username", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["username"] == output["username"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_firstName_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"firstName", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["firstName"] == output["firstName"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_lastName_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"lastName", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["lastName"] == output["lastName"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_email_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"email", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["email"] == output["email"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_password_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"password", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["password"] == output["password"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_phone_is_converted_to_json()
|
|
||||||
{
|
|
||||||
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"phone", "hello"
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["phone"] == output["phone"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_User_userStatus_is_converted_to_json()
|
|
||||||
{
|
|
||||||
bourne::json input =
|
|
||||||
{
|
|
||||||
"userStatus", 1
|
|
||||||
};
|
|
||||||
|
|
||||||
User obj(input.dump());
|
|
||||||
|
|
||||||
bourne::json output = bourne::json::object();
|
|
||||||
|
|
||||||
output = obj.toJson();
|
|
||||||
|
|
||||||
TEST_ASSERT(input["userStatus"] == output["userStatus"]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
#include "AbstractService.h"
|
|
||||||
#include "Arduino.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Tiny::AbstractService::begin(std::string url){
|
|
||||||
http.begin(String(url.c_str()), test_root_ca); //HTTPS connection
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
#ifndef TINY_CPP_CLIENT_ABSTRACTSERVICE_H_
|
|
||||||
#define TINY_CPP_CLIENT_ABSTRACTSERVICE_H_
|
|
||||||
|
|
||||||
#include "HTTPClient.h"
|
|
||||||
#include "Response.h"
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class
|
|
||||||
* Generated with openapi::tiny-cpp-client
|
|
||||||
*/
|
|
||||||
class AbstractService {
|
|
||||||
public:
|
|
||||||
HTTPClient http;
|
|
||||||
std::string basepath = "https://petstore3.swagger.io/api/v3"; // TODO: change to your url
|
|
||||||
|
|
||||||
void begin(std::string url);
|
|
||||||
|
|
||||||
// Go and comment out a certificate in root.cert, if you get an error here
|
|
||||||
// Certificate from file
|
|
||||||
const char* test_root_ca =
|
|
||||||
#include "../../root.cert"
|
|
||||||
;
|
|
||||||
|
|
||||||
}; // end class
|
|
||||||
}// namespace Tinyclient
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_ABSTRACTSERVICE_H_ */
|
|
@ -1,418 +0,0 @@
|
|||||||
#include "PetApi.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Response<
|
|
||||||
Pet
|
|
||||||
>
|
|
||||||
PetApi::
|
|
||||||
addPet(
|
|
||||||
|
|
||||||
Pet pet
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/pet"; //
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body | pet
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | POST
|
|
||||||
http.addHeader("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
payload = pet.toJson().dump();
|
|
||||||
|
|
||||||
int httpCode = http.sendRequest("POST", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Pet obj(output_string);
|
|
||||||
|
|
||||||
|
|
||||||
Response<Pet> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
PetApi::
|
|
||||||
deletePet(
|
|
||||||
|
|
||||||
long petId
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string apiKey
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/pet/{petId}"; //petId
|
|
||||||
// Query |
|
|
||||||
// Headers | apiKey
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
std::string s_petId("{");
|
|
||||||
s_petId.append("petId");
|
|
||||||
s_petId.append("}");
|
|
||||||
|
|
||||||
int pos = url.find(s_petId);
|
|
||||||
|
|
||||||
url.erase(pos, s_petId.length());
|
|
||||||
url.insert(pos, stringify(petId));
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | DELETE
|
|
||||||
int httpCode = http.sendRequest("DELETE", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
std::list<Pet>
|
|
||||||
>
|
|
||||||
PetApi::
|
|
||||||
findPetsByStatus(
|
|
||||||
std::list<std::string> status
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/pet/findByStatus"; //
|
|
||||||
// Query | status
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | GET
|
|
||||||
int httpCode = http.sendRequest("GET", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::list<Pet> obj = std::list<Pet>();
|
|
||||||
bourne::json jsonPayload(output_string);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(auto& var : jsonPayload.array_range())
|
|
||||||
{
|
|
||||||
Pet tmp(var.dump());
|
|
||||||
obj.push_back(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Response<std::list<Pet>> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
std::list<Pet>
|
|
||||||
>
|
|
||||||
PetApi::
|
|
||||||
findPetsByTags(
|
|
||||||
std::list<std::string> tags
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/pet/findByTags"; //
|
|
||||||
// Query | tags
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | GET
|
|
||||||
int httpCode = http.sendRequest("GET", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::list<Pet> obj = std::list<Pet>();
|
|
||||||
bourne::json jsonPayload(output_string);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(auto& var : jsonPayload.array_range())
|
|
||||||
{
|
|
||||||
Pet tmp(var.dump());
|
|
||||||
obj.push_back(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Response<std::list<Pet>> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
Pet
|
|
||||||
>
|
|
||||||
PetApi::
|
|
||||||
getPetById(
|
|
||||||
|
|
||||||
long petId
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/pet/{petId}"; //petId
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
std::string s_petId("{");
|
|
||||||
s_petId.append("petId");
|
|
||||||
s_petId.append("}");
|
|
||||||
|
|
||||||
int pos = url.find(s_petId);
|
|
||||||
|
|
||||||
url.erase(pos, s_petId.length());
|
|
||||||
url.insert(pos, stringify(petId));
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | GET
|
|
||||||
int httpCode = http.sendRequest("GET", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Pet obj(output_string);
|
|
||||||
|
|
||||||
|
|
||||||
Response<Pet> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
Pet
|
|
||||||
>
|
|
||||||
PetApi::
|
|
||||||
updatePet(
|
|
||||||
|
|
||||||
Pet pet
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/pet"; //
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body | pet
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | PUT
|
|
||||||
http.addHeader("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
payload = pet.toJson().dump();
|
|
||||||
|
|
||||||
int httpCode = http.sendRequest("PUT", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Pet obj(output_string);
|
|
||||||
|
|
||||||
|
|
||||||
Response<Pet> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
PetApi::
|
|
||||||
updatePetWithForm(
|
|
||||||
|
|
||||||
long petId
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string name
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string status
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/pet/{petId}"; //petId
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form | name status
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
std::string s_petId("{");
|
|
||||||
s_petId.append("petId");
|
|
||||||
s_petId.append("}");
|
|
||||||
|
|
||||||
int pos = url.find(s_petId);
|
|
||||||
|
|
||||||
url.erase(pos, s_petId.length());
|
|
||||||
url.insert(pos, stringify(petId));
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | POST
|
|
||||||
int httpCode = http.sendRequest("POST", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
ApiResponse
|
|
||||||
>
|
|
||||||
PetApi::
|
|
||||||
uploadFile(
|
|
||||||
|
|
||||||
long petId
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string additionalMetadata
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string file
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/pet/{petId}/uploadImage"; //petId
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form | additionalMetadata file
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
std::string s_petId("{");
|
|
||||||
s_petId.append("petId");
|
|
||||||
s_petId.append("}");
|
|
||||||
|
|
||||||
int pos = url.find(s_petId);
|
|
||||||
|
|
||||||
url.erase(pos, s_petId.length());
|
|
||||||
url.insert(pos, stringify(petId));
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | POST
|
|
||||||
int httpCode = http.sendRequest("POST", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ApiResponse obj(output_string);
|
|
||||||
|
|
||||||
|
|
||||||
Response<ApiResponse> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
|||||||
#ifndef TINY_CPP_CLIENT_PetApi_H_
|
|
||||||
#define TINY_CPP_CLIENT_PetApi_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "Response.h"
|
|
||||||
#include "Arduino.h"
|
|
||||||
#include "AbstractService.h"
|
|
||||||
#include "Helpers.h"
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include "ApiResponse.h"
|
|
||||||
#include "Pet.h"
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class
|
|
||||||
* Generated with openapi::tiny-cpp-client
|
|
||||||
*/
|
|
||||||
|
|
||||||
class PetApi : public AbstractService {
|
|
||||||
public:
|
|
||||||
PetApi() = default;
|
|
||||||
|
|
||||||
virtual ~PetApi() = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new pet to the store.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param pet Pet object that needs to be added to the store *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
Pet
|
|
||||||
>
|
|
||||||
addPet(
|
|
||||||
|
|
||||||
Pet pet
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Deletes a pet.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param petId Pet id to delete *Required*
|
|
||||||
* \param apiKey
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
deletePet(
|
|
||||||
|
|
||||||
long petId
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string apiKey
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Finds Pets by status.
|
|
||||||
*
|
|
||||||
* Multiple status values can be provided with comma separated strings
|
|
||||||
* \param status Status values that need to be considered for filter *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
std::list<Pet>
|
|
||||||
>
|
|
||||||
findPetsByStatus(
|
|
||||||
std::list<std::string> status
|
|
||||||
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Finds Pets by tags.
|
|
||||||
*
|
|
||||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
||||||
* \param tags Tags to filter by *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
std::list<Pet>
|
|
||||||
>
|
|
||||||
findPetsByTags(
|
|
||||||
std::list<std::string> tags
|
|
||||||
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Find pet by ID.
|
|
||||||
*
|
|
||||||
* Returns a single pet
|
|
||||||
* \param petId ID of pet to return *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
Pet
|
|
||||||
>
|
|
||||||
getPetById(
|
|
||||||
|
|
||||||
long petId
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Update an existing pet.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param pet Pet object that needs to be added to the store *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
Pet
|
|
||||||
>
|
|
||||||
updatePet(
|
|
||||||
|
|
||||||
Pet pet
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Updates a pet in the store with form data.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param petId ID of pet that needs to be updated *Required*
|
|
||||||
* \param name Updated name of the pet
|
|
||||||
* \param status Updated status of the pet
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
updatePetWithForm(
|
|
||||||
|
|
||||||
long petId
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string name
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string status
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* uploads an image.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param petId ID of pet to update *Required*
|
|
||||||
* \param additionalMetadata Additional data to pass to server
|
|
||||||
* \param file file to upload
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
ApiResponse
|
|
||||||
>
|
|
||||||
uploadFile(
|
|
||||||
|
|
||||||
long petId
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string additionalMetadata
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string file
|
|
||||||
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_PetApi_H_ */
|
|
@ -1,25 +0,0 @@
|
|||||||
#ifndef TINY_CPP_CLIENT_RESPONSE_H_
|
|
||||||
#define TINY_CPP_CLIENT_RESPONSE_H_
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class
|
|
||||||
* Generated with openapi::tiny-cpp-client
|
|
||||||
*/
|
|
||||||
template <typename T = std::string>
|
|
||||||
class Response {
|
|
||||||
public:
|
|
||||||
|
|
||||||
Response(T _obj, int _code){
|
|
||||||
obj = _obj;
|
|
||||||
code = _code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int code;
|
|
||||||
T obj;
|
|
||||||
};
|
|
||||||
} // namespace Tinyclient
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_RESPONSE_H_ */
|
|
@ -1,185 +0,0 @@
|
|||||||
#include "StoreApi.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
StoreApi::
|
|
||||||
deleteOrder(
|
|
||||||
|
|
||||||
std::string orderId
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/store/order/{orderId}"; //orderId
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
std::string s_orderId("{");
|
|
||||||
s_orderId.append("orderId");
|
|
||||||
s_orderId.append("}");
|
|
||||||
|
|
||||||
int pos = url.find(s_orderId);
|
|
||||||
|
|
||||||
url.erase(pos, s_orderId.length());
|
|
||||||
url.insert(pos, stringify(orderId));
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | DELETE
|
|
||||||
int httpCode = http.sendRequest("DELETE", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
StoreApi::
|
|
||||||
getInventory(
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/store/inventory"; //
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | GET
|
|
||||||
int httpCode = http.sendRequest("GET", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TODO: Implement map logic here
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TODO: No support for maps.
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
Order
|
|
||||||
>
|
|
||||||
StoreApi::
|
|
||||||
getOrderById(
|
|
||||||
|
|
||||||
long orderId
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/store/order/{orderId}"; //orderId
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
std::string s_orderId("{");
|
|
||||||
s_orderId.append("orderId");
|
|
||||||
s_orderId.append("}");
|
|
||||||
|
|
||||||
int pos = url.find(s_orderId);
|
|
||||||
|
|
||||||
url.erase(pos, s_orderId.length());
|
|
||||||
url.insert(pos, stringify(orderId));
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | GET
|
|
||||||
int httpCode = http.sendRequest("GET", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Order obj(output_string);
|
|
||||||
|
|
||||||
|
|
||||||
Response<Order> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
Order
|
|
||||||
>
|
|
||||||
StoreApi::
|
|
||||||
placeOrder(
|
|
||||||
|
|
||||||
Order order
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/store/order"; //
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body | order
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | POST
|
|
||||||
http.addHeader("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
payload = order.toJson().dump();
|
|
||||||
|
|
||||||
int httpCode = http.sendRequest("POST", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Order obj(output_string);
|
|
||||||
|
|
||||||
|
|
||||||
Response<Order> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
|||||||
#ifndef TINY_CPP_CLIENT_StoreApi_H_
|
|
||||||
#define TINY_CPP_CLIENT_StoreApi_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "Response.h"
|
|
||||||
#include "Arduino.h"
|
|
||||||
#include "AbstractService.h"
|
|
||||||
#include "Helpers.h"
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include "Order.h"
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class
|
|
||||||
* Generated with openapi::tiny-cpp-client
|
|
||||||
*/
|
|
||||||
|
|
||||||
class StoreApi : public AbstractService {
|
|
||||||
public:
|
|
||||||
StoreApi() = default;
|
|
||||||
|
|
||||||
virtual ~StoreApi() = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete purchase order by ID.
|
|
||||||
*
|
|
||||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
|
||||||
* \param orderId ID of the order that needs to be deleted *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
deleteOrder(
|
|
||||||
|
|
||||||
std::string orderId
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Returns pet inventories by status.
|
|
||||||
*
|
|
||||||
* Returns a map of status codes to quantities
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
getInventory(
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Find purchase order by ID.
|
|
||||||
*
|
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
|
||||||
* \param orderId ID of pet that needs to be fetched *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
Order
|
|
||||||
>
|
|
||||||
getOrderById(
|
|
||||||
|
|
||||||
long orderId
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Place an order for a pet.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param order order placed for purchasing the pet *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
Order
|
|
||||||
>
|
|
||||||
placeOrder(
|
|
||||||
|
|
||||||
Order order
|
|
||||||
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_StoreApi_H_ */
|
|
@ -1,366 +0,0 @@
|
|||||||
#include "UserApi.h"
|
|
||||||
|
|
||||||
using namespace Tiny;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
UserApi::
|
|
||||||
createUser(
|
|
||||||
|
|
||||||
User user
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/user"; //
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body | user
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | POST
|
|
||||||
http.addHeader("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
payload = user.toJson().dump();
|
|
||||||
|
|
||||||
int httpCode = http.sendRequest("POST", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
UserApi::
|
|
||||||
createUsersWithArrayInput(
|
|
||||||
std::list<User> user
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/user/createWithArray"; //
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body | user
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | POST
|
|
||||||
http.addHeader("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json tmp_arr = bourne::json::array();
|
|
||||||
for(auto& var : user)
|
|
||||||
{
|
|
||||||
auto tmp = var.toJson();
|
|
||||||
tmp_arr.append(tmp);
|
|
||||||
|
|
||||||
}
|
|
||||||
payload = tmp_arr.dump();
|
|
||||||
|
|
||||||
|
|
||||||
int httpCode = http.sendRequest("POST", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
UserApi::
|
|
||||||
createUsersWithListInput(
|
|
||||||
std::list<User> user
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/user/createWithList"; //
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body | user
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | POST
|
|
||||||
http.addHeader("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json tmp_arr = bourne::json::array();
|
|
||||||
for(auto& var : user)
|
|
||||||
{
|
|
||||||
auto tmp = var.toJson();
|
|
||||||
tmp_arr.append(tmp);
|
|
||||||
|
|
||||||
}
|
|
||||||
payload = tmp_arr.dump();
|
|
||||||
|
|
||||||
|
|
||||||
int httpCode = http.sendRequest("POST", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
UserApi::
|
|
||||||
deleteUser(
|
|
||||||
|
|
||||||
std::string username
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/user/{username}"; //username
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
std::string s_username("{");
|
|
||||||
s_username.append("username");
|
|
||||||
s_username.append("}");
|
|
||||||
|
|
||||||
int pos = url.find(s_username);
|
|
||||||
|
|
||||||
url.erase(pos, s_username.length());
|
|
||||||
url.insert(pos, stringify(username));
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | DELETE
|
|
||||||
int httpCode = http.sendRequest("DELETE", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
User
|
|
||||||
>
|
|
||||||
UserApi::
|
|
||||||
getUserByName(
|
|
||||||
|
|
||||||
std::string username
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/user/{username}"; //username
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
std::string s_username("{");
|
|
||||||
s_username.append("username");
|
|
||||||
s_username.append("}");
|
|
||||||
|
|
||||||
int pos = url.find(s_username);
|
|
||||||
|
|
||||||
url.erase(pos, s_username.length());
|
|
||||||
url.insert(pos, stringify(username));
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | GET
|
|
||||||
int httpCode = http.sendRequest("GET", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
User obj(output_string);
|
|
||||||
|
|
||||||
|
|
||||||
Response<User> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
std::string
|
|
||||||
>
|
|
||||||
UserApi::
|
|
||||||
loginUser(
|
|
||||||
|
|
||||||
std::string username
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string password
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/user/login"; //
|
|
||||||
// Query | username password
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | GET
|
|
||||||
int httpCode = http.sendRequest("GET", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bourne::json jsonPayload(output_string);
|
|
||||||
std::string obj;
|
|
||||||
jsonToValue(&obj, jsonPayload, "std::string");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Response<std::string> response(obj, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
UserApi::
|
|
||||||
logoutUser(
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/user/logout"; //
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body |
|
|
||||||
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | GET
|
|
||||||
int httpCode = http.sendRequest("GET", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
UserApi::
|
|
||||||
updateUser(
|
|
||||||
|
|
||||||
std::string username
|
|
||||||
,
|
|
||||||
|
|
||||||
User user
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string url = basepath + "/user/{username}"; //username
|
|
||||||
// Query |
|
|
||||||
// Headers |
|
|
||||||
// Form |
|
|
||||||
// Body | user
|
|
||||||
|
|
||||||
std::string s_username("{");
|
|
||||||
s_username.append("username");
|
|
||||||
s_username.append("}");
|
|
||||||
|
|
||||||
int pos = url.find(s_username);
|
|
||||||
|
|
||||||
url.erase(pos, s_username.length());
|
|
||||||
url.insert(pos, stringify(username));
|
|
||||||
|
|
||||||
begin(url);
|
|
||||||
|
|
||||||
std::string payload = "";
|
|
||||||
// Send Request
|
|
||||||
// METHOD | PUT
|
|
||||||
http.addHeader("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
payload = user.toJson().dump();
|
|
||||||
|
|
||||||
int httpCode = http.sendRequest("PUT", reinterpret_cast<uint8_t*>(&payload[0]), payload.length());
|
|
||||||
|
|
||||||
// Handle Request
|
|
||||||
String output = http.getString();
|
|
||||||
std::string output_string = output.c_str();
|
|
||||||
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
|
|
||||||
Response<String> response(output, httpCode);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,147 +0,0 @@
|
|||||||
#ifndef TINY_CPP_CLIENT_UserApi_H_
|
|
||||||
#define TINY_CPP_CLIENT_UserApi_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "Response.h"
|
|
||||||
#include "Arduino.h"
|
|
||||||
#include "AbstractService.h"
|
|
||||||
#include "Helpers.h"
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include "User.h"
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace Tiny {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class
|
|
||||||
* Generated with openapi::tiny-cpp-client
|
|
||||||
*/
|
|
||||||
|
|
||||||
class UserApi : public AbstractService {
|
|
||||||
public:
|
|
||||||
UserApi() = default;
|
|
||||||
|
|
||||||
virtual ~UserApi() = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create user.
|
|
||||||
*
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
* \param user Created user object *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
createUser(
|
|
||||||
|
|
||||||
User user
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Creates list of users with given input array.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param user List of user object *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
createUsersWithArrayInput(
|
|
||||||
std::list<User> user
|
|
||||||
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Creates list of users with given input array.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param user List of user object *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
createUsersWithListInput(
|
|
||||||
std::list<User> user
|
|
||||||
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Delete user.
|
|
||||||
*
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
* \param username The name that needs to be deleted *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
deleteUser(
|
|
||||||
|
|
||||||
std::string username
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Get user by user name.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param username The name that needs to be fetched. Use user1 for testing. *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
User
|
|
||||||
>
|
|
||||||
getUserByName(
|
|
||||||
|
|
||||||
std::string username
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Logs user into the system.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* \param username The user name for login *Required*
|
|
||||||
* \param password The password for login in clear text *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
std::string
|
|
||||||
>
|
|
||||||
loginUser(
|
|
||||||
|
|
||||||
std::string username
|
|
||||||
,
|
|
||||||
|
|
||||||
std::string password
|
|
||||||
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Logs out current logged in user session.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
logoutUser(
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* Updated user.
|
|
||||||
*
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
* \param username name that need to be deleted *Required*
|
|
||||||
* \param user Updated user object *Required*
|
|
||||||
*/
|
|
||||||
Response<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
updateUser(
|
|
||||||
|
|
||||||
std::string username
|
|
||||||
,
|
|
||||||
|
|
||||||
User user
|
|
||||||
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TINY_CPP_CLIENT_UserApi_H_ */
|
|
@ -1,7 +0,0 @@
|
|||||||
[env:esp32]
|
|
||||||
platform = espressif32
|
|
||||||
board = nodemcu-32s
|
|
||||||
framework = arduino
|
|
||||||
lib_deps = https://github.com/steinwurf/bourne.git
|
|
||||||
extra_scripts = pre_compiling_bourne.py
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
|||||||
Import("env")
|
|
||||||
|
|
||||||
## Compatibility for bourne to work on microcontrollers
|
|
||||||
# We insert '#define _GLIBCXX_USE_C99' in files that use std::stoll or std::to_string
|
|
||||||
def insert_c99_into(file):
|
|
||||||
import fileinput
|
|
||||||
|
|
||||||
path = env['PROJECT_LIBDEPS_DIR'] + "/" + env['PIOENV'] + "/bourne/src/bourne/" + file
|
|
||||||
value = '#define _GLIBCXX_USE_C99 1\n'
|
|
||||||
|
|
||||||
for line in fileinput.FileInput(path,inplace=1):
|
|
||||||
if line.startswith('#define _GLIBCXX_USE_C99'):
|
|
||||||
continue
|
|
||||||
elif line.startswith('// D'):
|
|
||||||
line=line.replace(line,line+value)
|
|
||||||
print(line, end='')
|
|
||||||
|
|
||||||
def fix_parser():
|
|
||||||
insert_c99_into('detail/parser.cpp')
|
|
||||||
|
|
||||||
def fix_json():
|
|
||||||
insert_c99_into('json.cpp')
|
|
||||||
|
|
||||||
fix_parser()
|
|
||||||
fix_json()
|
|
@ -1,53 +0,0 @@
|
|||||||
// TODO: Provide your service root certificate.
|
|
||||||
// Below is two examples of root certificates.
|
|
||||||
|
|
||||||
// Let's encrypt root certificate
|
|
||||||
/**
|
|
||||||
"-----BEGIN CERTIFICATE-----\n" \
|
|
||||||
"MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" \
|
|
||||||
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" \
|
|
||||||
"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" \
|
|
||||||
"QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" \
|
|
||||||
"MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" \
|
|
||||||
"b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" \
|
|
||||||
"9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" \
|
|
||||||
"CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" \
|
|
||||||
"nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" \
|
|
||||||
"43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" \
|
|
||||||
"T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" \
|
|
||||||
"gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" \
|
|
||||||
"BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" \
|
|
||||||
"TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" \
|
|
||||||
"DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" \
|
|
||||||
"hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" \
|
|
||||||
"06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" \
|
|
||||||
"PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" \
|
|
||||||
"YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" \
|
|
||||||
"CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" \
|
|
||||||
"-----END CERTIFICATE-----\n"
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Amazon_Root_CA_1.pem
|
|
||||||
/**
|
|
||||||
"-----BEGIN CERTIFICATE-----\n" \
|
|
||||||
"MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" \
|
|
||||||
"ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" \
|
|
||||||
"b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" \
|
|
||||||
"MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" \
|
|
||||||
"b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" \
|
|
||||||
"ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" \
|
|
||||||
"9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" \
|
|
||||||
"IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" \
|
|
||||||
"VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" \
|
|
||||||
"93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" \
|
|
||||||
"jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" \
|
|
||||||
"AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" \
|
|
||||||
"A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" \
|
|
||||||
"U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" \
|
|
||||||
"N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" \
|
|
||||||
"o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" \
|
|
||||||
"5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" \
|
|
||||||
"rqXRfboQnoZsG4q5WTP468SQvvG5\n" \
|
|
||||||
"-----END CERTIFICATE-----\n" \
|
|
||||||
*/
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
|||||||
#include "PetApi.h"
|
|
||||||
|
|
||||||
const char* ssid = "your wifi name"; // TODO Change wifi name
|
|
||||||
const char* password = "Your wifi password"; //TODO Change wifi password
|
|
||||||
|
|
||||||
|
|
||||||
void setup(){
|
|
||||||
//Initialize serial and wait for port to open:
|
|
||||||
Serial.begin(9600);
|
|
||||||
delay(100);
|
|
||||||
|
|
||||||
Serial.print("Attempting to connect to SSID: ");
|
|
||||||
Serial.println(ssid);
|
|
||||||
WiFi.begin(ssid, password);
|
|
||||||
|
|
||||||
// attempt to connect to Wifi network:
|
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
|
||||||
Serial.print(".");
|
|
||||||
// wait 1 second for re-trying
|
|
||||||
delay(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
Serial.print("Connected to ");
|
|
||||||
Serial.println(ssid);
|
|
||||||
|
|
||||||
//Print LAN IP.
|
|
||||||
Serial.print("IP address set: ");
|
|
||||||
Serial.println(WiFi.localIP());
|
|
||||||
|
|
||||||
Tiny::PetApi petapi;
|
|
||||||
auto resp = petapi.getPetById(10);
|
|
||||||
Serial.println(resp.code);
|
|
||||||
Tiny::Pet pet = resp.obj;
|
|
||||||
Serial.println(pet.toJson().dump().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop(){}
|
|
@ -1,204 +0,0 @@
|
|||||||
|
|
||||||
#include "ApiResponseTest.cpp"
|
|
||||||
|
|
||||||
#include "CategoryTest.cpp"
|
|
||||||
|
|
||||||
#include "OrderTest.cpp"
|
|
||||||
|
|
||||||
#include "PetTest.cpp"
|
|
||||||
|
|
||||||
#include "TagTest.cpp"
|
|
||||||
|
|
||||||
#include "UserTest.cpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setUp(){}
|
|
||||||
|
|
||||||
void tearDown(){}
|
|
||||||
|
|
||||||
void runTests(){
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_ApiResponse_code_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_ApiResponse_type_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_ApiResponse_message_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Category_id_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Category_name_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_id_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_petId_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_quantity_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_shipDate_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_status_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_complete_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Pet_id_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Pet_name_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Pet_status_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Tag_id_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Tag_name_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_id_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_username_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_firstName_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_lastName_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_email_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_password_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_phone_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_userStatus_is_assigned_from_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_ApiResponse_code_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_ApiResponse_type_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_ApiResponse_message_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Category_id_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Category_name_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_id_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_petId_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_quantity_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_shipDate_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_status_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Order_complete_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Pet_id_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Pet_name_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Pet_status_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Tag_id_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_Tag_name_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_id_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_username_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_firstName_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_lastName_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_email_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_password_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_phone_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST(test_User_userStatus_is_converted_to_json);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
UNITY_BEGIN();
|
|
||||||
runTests();
|
|
||||||
return UNITY_END();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
UNITY_BEGIN();
|
|
||||||
runTests();
|
|
||||||
UNITY_END();
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
# 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
|
|
@ -1 +0,0 @@
|
|||||||
4.3.0-SNAPSHOT
|
|
@ -1,13 +0,0 @@
|
|||||||
# Generated k6 script
|
|
||||||
|
|
||||||
The `script.js` file contains most of the Swagger/OpenAPI specification and you can customize it to your needs.
|
|
||||||
|
|
||||||
Global header variables are defined at the top of the file, like `api_key`. Each path in the specification is converted into a [group](https://docs.k6.io/docs/tags-and-groups) in k6 and each group contains all the request methods related to that path. Path and query parameters are extracted from the specification and put at the start of the group. The URL is constructed from the base URL plus path and query.
|
|
||||||
|
|
||||||
k6 specific parameters are in the [`params`](https://docs.k6.io/docs/params-k6http) object, and `body` contains the [request](https://docs.k6.io/docs/http-requests) body which is in the form of `identifier: type`, which the `type` should be substituted by a proper value. Then goes the request and the check.
|
|
||||||
|
|
||||||
[Check](https://docs.k6.io/docs/checks) are like asserts but differ in that they don't halt execution, instead they just store the result of the check, pass or fail, and let the script execution continue.
|
|
||||||
|
|
||||||
Each request is always followed by a 0.1 second [sleep](https://docs.k6.io/docs/sleep-t-1) to prevent the script execution from flooding the system with too many requests simultaneously.
|
|
||||||
|
|
||||||
Note that the default iteration count and VU count is 1. So each request in each group will be executed once. For more information, see the [k6 options](https://docs.k6.io/docs/options).
|
|
@ -1,204 +0,0 @@
|
|||||||
/*
|
|
||||||
* OpenAPI Petstore
|
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: 1.0.0
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
* https://github.com/OpenAPITools/openapi-generator
|
|
||||||
*
|
|
||||||
* OpenAPI generator version: 4.3.0-SNAPSHOT
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import http from "k6/http";
|
|
||||||
import { group, check, sleep } from "k6";
|
|
||||||
|
|
||||||
const BASE_URL = "http://petstore.swagger.io/v2";
|
|
||||||
// Sleep duration between successive requests.
|
|
||||||
// You might want to edit the value of this variable or remove calls to the sleep function on the script.
|
|
||||||
const SLEEP_DURATION = 0.1;
|
|
||||||
// Global variables should be initialized.
|
|
||||||
let api_key = "TODO_EDIT_THE_API_KEY";
|
|
||||||
|
|
||||||
export default function() {
|
|
||||||
group("/pet", () => {
|
|
||||||
let url = BASE_URL + `/pet`;
|
|
||||||
// Request No. 1
|
|
||||||
// TODO: edit the parameters of the request body.
|
|
||||||
let body = {"id": "long", "category": {"id": "long", "name": "string"}, "name": "string", "photoUrls": "list", "tags": [{"id": "long", "name": "string"}], "status": "string"};
|
|
||||||
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
|
|
||||||
let request = http.put(url, body, params);
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
|
|
||||||
// Request No. 2
|
|
||||||
// TODO: edit the parameters of the request body.
|
|
||||||
body = {"id": "long", "category": {"id": "long", "name": "string"}, "name": "string", "photoUrls": "list", "tags": [{"id": "long", "name": "string"}], "status": "string"};
|
|
||||||
params = {headers: {"Content-Type": "application/json"}};
|
|
||||||
request = http.post(url, body, params);
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/pet/findByStatus", () => {
|
|
||||||
let status = "TODO_EDIT_THE_STATUS";
|
|
||||||
let url = BASE_URL + `/pet/findByStatus?status=${status}`;
|
|
||||||
// Request No. 1
|
|
||||||
let request = http.get(url);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/pet/findByTags", () => {
|
|
||||||
let tags = "TODO_EDIT_THE_TAGS";
|
|
||||||
let url = BASE_URL + `/pet/findByTags?tags=${tags}`;
|
|
||||||
// Request No. 1
|
|
||||||
let request = http.get(url);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/pet/{petId}", () => {
|
|
||||||
let petId = "TODO_EDIT_THE_PETID";
|
|
||||||
let url = BASE_URL + `/pet/${petId}`;
|
|
||||||
// Request No. 1
|
|
||||||
let request = http.get(url);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
|
|
||||||
// Request No. 2
|
|
||||||
// TODO: edit the parameters of the request body.
|
|
||||||
body = {"name": "string", "status": "string"};
|
|
||||||
params = {headers: {"Content-Type": "application/x-www-form-urlencoded"}};
|
|
||||||
request = http.post(url, body, params);
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
|
|
||||||
// Request No. 3
|
|
||||||
params = {headers: {"api_key": `${api_key}`}};
|
|
||||||
request = http.delete(url, params);
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/pet/{petId}/uploadImage", () => {
|
|
||||||
let petId = "TODO_EDIT_THE_PETID";
|
|
||||||
let url = BASE_URL + `/pet/${petId}/uploadImage`;
|
|
||||||
// Request No. 1
|
|
||||||
// TODO: edit the parameters of the request body.
|
|
||||||
let body = {"additionalMetadata": "string", "file": http.file(open("/path/to/file.bin", "b"), "test.bin")};
|
|
||||||
let params = {headers: {"Content-Type": "multipart/form-data", "Accept": "application/json"}};
|
|
||||||
let request = http.post(url, body, params);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/store/inventory", () => {
|
|
||||||
let url = BASE_URL + `/store/inventory`;
|
|
||||||
// Request No. 1
|
|
||||||
let request = http.get(url);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/store/order", () => {
|
|
||||||
let url = BASE_URL + `/store/order`;
|
|
||||||
// Request No. 1
|
|
||||||
// TODO: edit the parameters of the request body.
|
|
||||||
let body = {"id": "long", "petId": "long", "quantity": "integer", "shipDate": "date", "status": "string", "complete": "boolean"};
|
|
||||||
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
|
|
||||||
let request = http.post(url, body, params);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/store/order/{orderId}", () => {
|
|
||||||
let orderId = "TODO_EDIT_THE_ORDERID";
|
|
||||||
let url = BASE_URL + `/store/order/${orderId}`;
|
|
||||||
// Request No. 1
|
|
||||||
let request = http.get(url);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
|
|
||||||
// Request No. 2
|
|
||||||
request = http.delete(url);
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/user", () => {
|
|
||||||
let url = BASE_URL + `/user`;
|
|
||||||
// Request No. 1
|
|
||||||
// TODO: edit the parameters of the request body.
|
|
||||||
let body = {"id": "long", "username": "string", "firstName": "string", "lastName": "string", "email": "string", "password": "string", "phone": "string", "userStatus": "integer"};
|
|
||||||
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
|
|
||||||
let request = http.post(url, body, params);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/user/createWithArray", () => {
|
|
||||||
let url = BASE_URL + `/user/createWithArray`;
|
|
||||||
// Request No. 1
|
|
||||||
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
|
|
||||||
let request = http.post(url, params);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/user/createWithList", () => {
|
|
||||||
let url = BASE_URL + `/user/createWithList`;
|
|
||||||
// Request No. 1
|
|
||||||
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
|
|
||||||
let request = http.post(url, params);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/user/login", () => {
|
|
||||||
let password = "TODO_EDIT_THE_PASSWORD";
|
|
||||||
let username = "TODO_EDIT_THE_USERNAME";
|
|
||||||
let url = BASE_URL + `/user/login?username=${username}&password=${password}`;
|
|
||||||
// Request No. 1
|
|
||||||
let request = http.get(url);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/user/logout", () => {
|
|
||||||
let url = BASE_URL + `/user/logout`;
|
|
||||||
// Request No. 1
|
|
||||||
let request = http.get(url);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
group("/user/{username}", () => {
|
|
||||||
let username = "TODO_EDIT_THE_USERNAME";
|
|
||||||
let url = BASE_URL + `/user/${username}`;
|
|
||||||
// Request No. 1
|
|
||||||
let request = http.get(url);
|
|
||||||
check(request, {
|
|
||||||
"successful operation": (r) => r.status === 200
|
|
||||||
});
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
|
|
||||||
// Request No. 2
|
|
||||||
// TODO: edit the parameters of the request body.
|
|
||||||
body = {"id": "long", "username": "string", "firstName": "string", "lastName": "string", "email": "string", "password": "string", "phone": "string", "userStatus": "integer"};
|
|
||||||
params = {headers: {"Content-Type": "application/json"}};
|
|
||||||
request = http.put(url, body, params);
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
|
|
||||||
// Request No. 3
|
|
||||||
request = http.delete(url);
|
|
||||||
sleep(SLEEP_DURATION);
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
|
||||||
*.o
|
|
||||||
*.a
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Folders
|
|
||||||
_obj
|
|
||||||
_test
|
|
||||||
|
|
||||||
# Architecture specific extensions/prefixes
|
|
||||||
*.[568vq]
|
|
||||||
[568vq].out
|
|
||||||
|
|
||||||
*.cgo1.go
|
|
||||||
*.cgo2.c
|
|
||||||
_cgo_defun.c
|
|
||||||
_cgo_gotypes.go
|
|
||||||
_cgo_export.*
|
|
||||||
|
|
||||||
_testmain.go
|
|
||||||
|
|
||||||
*.exe
|
|
||||||
*.test
|
|
||||||
*.prof
|
|
@ -1,23 +0,0 @@
|
|||||||
# 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
|
|
@ -1,16 +0,0 @@
|
|||||||
.gitignore
|
|
||||||
.openapi-generator-ignore
|
|
||||||
.travis.yml
|
|
||||||
README.md
|
|
||||||
api/openapi.yaml
|
|
||||||
api_default.go
|
|
||||||
client.go
|
|
||||||
configuration.go
|
|
||||||
docs/ApiResponse.md
|
|
||||||
docs/DefaultApi.md
|
|
||||||
git_push.sh
|
|
||||||
go.mod
|
|
||||||
go.sum
|
|
||||||
model_api_response.go
|
|
||||||
response.go
|
|
||||||
utils.go
|
|
@ -1 +0,0 @@
|
|||||||
5.3.1-SNAPSHOT
|
|
@ -1,8 +0,0 @@
|
|||||||
language: go
|
|
||||||
|
|
||||||
install:
|
|
||||||
- go get -d -v .
|
|
||||||
|
|
||||||
script:
|
|
||||||
- go build -v ./
|
|
||||||
|
|
@ -1,113 +0,0 @@
|
|||||||
# Go API client for openapi
|
|
||||||
|
|
||||||
This is a sample server with a single endpoint that accepts two files via a multipart/form-data POST request.
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
|
|
||||||
|
|
||||||
- API version: 1.0.0
|
|
||||||
- Package version: 1.0.0
|
|
||||||
- Build package: org.openapitools.codegen.languages.GoClientCodegen
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
Install the following dependencies:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
go get github.com/stretchr/testify/assert
|
|
||||||
go get golang.org/x/oauth2
|
|
||||||
go get golang.org/x/net/context
|
|
||||||
```
|
|
||||||
|
|
||||||
Put the package under your project folder and add the following in import:
|
|
||||||
|
|
||||||
```golang
|
|
||||||
import sw "./openapi"
|
|
||||||
```
|
|
||||||
|
|
||||||
To use a proxy, set the environment variable `HTTP_PROXY`:
|
|
||||||
|
|
||||||
```golang
|
|
||||||
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configuration of Server URL
|
|
||||||
|
|
||||||
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
|
|
||||||
|
|
||||||
### Select Server Configuration
|
|
||||||
|
|
||||||
For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.
|
|
||||||
|
|
||||||
```golang
|
|
||||||
ctx := context.WithValue(context.Background(), sw.ContextServerIndex, 1)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Templated Server URL
|
|
||||||
|
|
||||||
Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.
|
|
||||||
|
|
||||||
```golang
|
|
||||||
ctx := context.WithValue(context.Background(), sw.ContextServerVariables, map[string]string{
|
|
||||||
"basePath": "v2",
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
Note, enum values are always validated and all unused variables are silently ignored.
|
|
||||||
|
|
||||||
### URLs Configuration per Operation
|
|
||||||
|
|
||||||
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
|
|
||||||
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
|
|
||||||
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.
|
|
||||||
|
|
||||||
```
|
|
||||||
ctx := context.WithValue(context.Background(), sw.ContextOperationServerIndices, map[string]int{
|
|
||||||
"{classname}Service.{nickname}": 2,
|
|
||||||
})
|
|
||||||
ctx = context.WithValue(context.Background(), sw.ContextOperationServerVariables, map[string]map[string]string{
|
|
||||||
"{classname}Service.{nickname}": {
|
|
||||||
"port": "8443",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Documentation for API Endpoints
|
|
||||||
|
|
||||||
All URIs are relative to *http://example.com*
|
|
||||||
|
|
||||||
Class | Method | HTTP request | Description
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
*DefaultApi* | [**UploadFiles**](docs/DefaultApi.md#uploadfiles) | **Post** /uploadFiles | uploads two files
|
|
||||||
|
|
||||||
|
|
||||||
## Documentation For Models
|
|
||||||
|
|
||||||
- [ApiResponse](docs/ApiResponse.md)
|
|
||||||
|
|
||||||
|
|
||||||
## Documentation For Authorization
|
|
||||||
|
|
||||||
Endpoints do not require authorization.
|
|
||||||
|
|
||||||
|
|
||||||
## Documentation for Utility Methods
|
|
||||||
|
|
||||||
Due to the fact that model structure members are all pointers, this package contains
|
|
||||||
a number of utility functions to easily obtain pointers to values of basic types.
|
|
||||||
Each of these functions takes a value of the given basic type and returns a pointer to it:
|
|
||||||
|
|
||||||
* `PtrBool`
|
|
||||||
* `PtrInt`
|
|
||||||
* `PtrInt32`
|
|
||||||
* `PtrInt64`
|
|
||||||
* `PtrFloat`
|
|
||||||
* `PtrFloat32`
|
|
||||||
* `PtrFloat64`
|
|
||||||
* `PtrString`
|
|
||||||
* `PtrTime`
|
|
||||||
|
|
||||||
## Author
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
|||||||
openapi: 3.0.0
|
|
||||||
info:
|
|
||||||
description: This is a sample server with a single endpoint that accepts two files
|
|
||||||
via a multipart/form-data POST request.
|
|
||||||
license:
|
|
||||||
name: Apache-2.0
|
|
||||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
title: Multiple Files via form-data
|
|
||||||
version: 1.0.0
|
|
||||||
servers:
|
|
||||||
- url: http://example.com
|
|
||||||
paths:
|
|
||||||
/uploadFiles:
|
|
||||||
post:
|
|
||||||
operationId: uploadFiles
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/inline_object'
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
secondFile:
|
|
||||||
description: another file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/ApiResponse'
|
|
||||||
description: successful operation
|
|
||||||
summary: uploads two files
|
|
||||||
components:
|
|
||||||
requestBodies:
|
|
||||||
inline_object:
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/inline_object'
|
|
||||||
schemas:
|
|
||||||
ApiResponse:
|
|
||||||
description: Describes the result of uploading files
|
|
||||||
example:
|
|
||||||
code: 0
|
|
||||||
type: type
|
|
||||||
message: message
|
|
||||||
properties:
|
|
||||||
code:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
type:
|
|
||||||
type: string
|
|
||||||
message:
|
|
||||||
type: string
|
|
||||||
title: An uploaded response
|
|
||||||
type: object
|
|
||||||
inline_object:
|
|
||||||
properties:
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
secondFile:
|
|
||||||
description: another file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
@ -1,172 +0,0 @@
|
|||||||
/*
|
|
||||||
Multiple Files via form-data
|
|
||||||
|
|
||||||
This is a sample server with a single endpoint that accepts two files via a multipart/form-data POST request.
|
|
||||||
|
|
||||||
API version: 1.0.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
||||||
|
|
||||||
package openapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
_context "context"
|
|
||||||
_ioutil "io/ioutil"
|
|
||||||
_nethttp "net/http"
|
|
||||||
_neturl "net/url"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Linger please
|
|
||||||
var (
|
|
||||||
_ _context.Context
|
|
||||||
)
|
|
||||||
|
|
||||||
// DefaultApiService DefaultApi service
|
|
||||||
type DefaultApiService service
|
|
||||||
|
|
||||||
type ApiUploadFilesRequest struct {
|
|
||||||
ctx _context.Context
|
|
||||||
ApiService *DefaultApiService
|
|
||||||
file **os.File
|
|
||||||
secondFile **os.File
|
|
||||||
}
|
|
||||||
|
|
||||||
// file to upload
|
|
||||||
func (r ApiUploadFilesRequest) File(file *os.File) ApiUploadFilesRequest {
|
|
||||||
r.file = &file
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
// another file to upload
|
|
||||||
func (r ApiUploadFilesRequest) SecondFile(secondFile *os.File) ApiUploadFilesRequest {
|
|
||||||
r.secondFile = &secondFile
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r ApiUploadFilesRequest) Execute() (ApiResponse, *_nethttp.Response, error) {
|
|
||||||
return r.ApiService.UploadFilesExecute(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
UploadFiles uploads two files
|
|
||||||
|
|
||||||
@param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
||||||
@return ApiUploadFilesRequest
|
|
||||||
*/
|
|
||||||
func (a *DefaultApiService) UploadFiles(ctx _context.Context) ApiUploadFilesRequest {
|
|
||||||
return ApiUploadFilesRequest{
|
|
||||||
ApiService: a,
|
|
||||||
ctx: ctx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute executes the request
|
|
||||||
// @return ApiResponse
|
|
||||||
func (a *DefaultApiService) UploadFilesExecute(r ApiUploadFilesRequest) (ApiResponse, *_nethttp.Response, error) {
|
|
||||||
var (
|
|
||||||
localVarHTTPMethod = _nethttp.MethodPost
|
|
||||||
localVarPostBody interface{}
|
|
||||||
formFiles []formFile
|
|
||||||
localVarReturnValue ApiResponse
|
|
||||||
)
|
|
||||||
|
|
||||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UploadFiles")
|
|
||||||
if err != nil {
|
|
||||||
return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarPath := localBasePath + "/uploadFiles"
|
|
||||||
|
|
||||||
localVarHeaderParams := make(map[string]string)
|
|
||||||
localVarQueryParams := _neturl.Values{}
|
|
||||||
localVarFormParams := _neturl.Values{}
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
|
||||||
localVarHTTPContentTypes := []string{"multipart/form-data"}
|
|
||||||
|
|
||||||
// set Content-Type header
|
|
||||||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
||||||
if localVarHTTPContentType != "" {
|
|
||||||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
||||||
}
|
|
||||||
|
|
||||||
// to determine the Accept header
|
|
||||||
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
||||||
|
|
||||||
// set Accept header
|
|
||||||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
||||||
if localVarHTTPHeaderAccept != "" {
|
|
||||||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
||||||
}
|
|
||||||
var fileLocalVarFormFileName string
|
|
||||||
var fileLocalVarFileName string
|
|
||||||
var fileLocalVarFileBytes []byte
|
|
||||||
|
|
||||||
fileLocalVarFormFileName = "file"
|
|
||||||
|
|
||||||
var fileLocalVarFile *os.File
|
|
||||||
if r.file != nil {
|
|
||||||
fileLocalVarFile = *r.file
|
|
||||||
}
|
|
||||||
if fileLocalVarFile != nil {
|
|
||||||
fbs, _ := _ioutil.ReadAll(fileLocalVarFile)
|
|
||||||
fileLocalVarFileBytes = fbs
|
|
||||||
fileLocalVarFileName = fileLocalVarFile.Name()
|
|
||||||
fileLocalVarFile.Close()
|
|
||||||
}
|
|
||||||
formFiles = append(formFiles, formFile{fileBytes: fileLocalVarFileBytes, fileName: fileLocalVarFileName, formFileName: fileLocalVarFormFileName})
|
|
||||||
var secondFileLocalVarFormFileName string
|
|
||||||
var secondFileLocalVarFileName string
|
|
||||||
var secondFileLocalVarFileBytes []byte
|
|
||||||
|
|
||||||
secondFileLocalVarFormFileName = "secondFile"
|
|
||||||
|
|
||||||
var secondFileLocalVarFile *os.File
|
|
||||||
if r.secondFile != nil {
|
|
||||||
secondFileLocalVarFile = *r.secondFile
|
|
||||||
}
|
|
||||||
if secondFileLocalVarFile != nil {
|
|
||||||
fbs, _ := _ioutil.ReadAll(secondFileLocalVarFile)
|
|
||||||
secondFileLocalVarFileBytes = fbs
|
|
||||||
secondFileLocalVarFileName = secondFileLocalVarFile.Name()
|
|
||||||
secondFileLocalVarFile.Close()
|
|
||||||
}
|
|
||||||
formFiles = append(formFiles, formFile{fileBytes: secondFileLocalVarFileBytes, fileName: secondFileLocalVarFileName, formFileName: secondFileLocalVarFormFileName})
|
|
||||||
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
||||||
if err != nil {
|
|
||||||
return localVarReturnValue, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
||||||
if err != nil || localVarHTTPResponse == nil {
|
|
||||||
return localVarReturnValue, localVarHTTPResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
|
|
||||||
localVarHTTPResponse.Body.Close()
|
|
||||||
localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))
|
|
||||||
if err != nil {
|
|
||||||
return localVarReturnValue, localVarHTTPResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if localVarHTTPResponse.StatusCode >= 300 {
|
|
||||||
newErr := GenericOpenAPIError{
|
|
||||||
body: localVarBody,
|
|
||||||
error: localVarHTTPResponse.Status,
|
|
||||||
}
|
|
||||||
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
||||||
}
|
|
||||||
|
|
||||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
newErr := GenericOpenAPIError{
|
|
||||||
body: localVarBody,
|
|
||||||
error: err.Error(),
|
|
||||||
}
|
|
||||||
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
||||||
}
|
|
||||||
|
|
||||||
return localVarReturnValue, localVarHTTPResponse, nil
|
|
||||||
}
|
|
@ -1,553 +0,0 @@
|
|||||||
/*
|
|
||||||
Multiple Files via form-data
|
|
||||||
|
|
||||||
This is a sample server with a single endpoint that accepts two files via a multipart/form-data POST request.
|
|
||||||
|
|
||||||
API version: 1.0.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
||||||
|
|
||||||
package openapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"encoding/xml"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"mime/multipart"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httputil"
|
|
||||||
"net/url"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"reflect"
|
|
||||||
"regexp"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
"unicode/utf8"
|
|
||||||
|
|
||||||
"golang.org/x/oauth2"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
|
|
||||||
xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
|
|
||||||
)
|
|
||||||
|
|
||||||
// APIClient manages communication with the Multiple Files via form-data API v1.0.0
|
|
||||||
// In most cases there should be only one, shared, APIClient.
|
|
||||||
type APIClient struct {
|
|
||||||
cfg *Configuration
|
|
||||||
common service // Reuse a single struct instead of allocating one for each service on the heap.
|
|
||||||
|
|
||||||
// API Services
|
|
||||||
|
|
||||||
DefaultApi *DefaultApiService
|
|
||||||
}
|
|
||||||
|
|
||||||
type service struct {
|
|
||||||
client *APIClient
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAPIClient creates a new API client. Requires a userAgent string describing your application.
|
|
||||||
// optionally a custom http.Client to allow for advanced features such as caching.
|
|
||||||
func NewAPIClient(cfg *Configuration) *APIClient {
|
|
||||||
if cfg.HTTPClient == nil {
|
|
||||||
cfg.HTTPClient = http.DefaultClient
|
|
||||||
}
|
|
||||||
|
|
||||||
c := &APIClient{}
|
|
||||||
c.cfg = cfg
|
|
||||||
c.common.client = c
|
|
||||||
|
|
||||||
// API Services
|
|
||||||
c.DefaultApi = (*DefaultApiService)(&c.common)
|
|
||||||
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func atoi(in string) (int, error) {
|
|
||||||
return strconv.Atoi(in)
|
|
||||||
}
|
|
||||||
|
|
||||||
// selectHeaderContentType select a content type from the available list.
|
|
||||||
func selectHeaderContentType(contentTypes []string) string {
|
|
||||||
if len(contentTypes) == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
if contains(contentTypes, "application/json") {
|
|
||||||
return "application/json"
|
|
||||||
}
|
|
||||||
return contentTypes[0] // use the first content type specified in 'consumes'
|
|
||||||
}
|
|
||||||
|
|
||||||
// selectHeaderAccept join all accept types and return
|
|
||||||
func selectHeaderAccept(accepts []string) string {
|
|
||||||
if len(accepts) == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if contains(accepts, "application/json") {
|
|
||||||
return "application/json"
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.Join(accepts, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
// contains is a case insensitive match, finding needle in a haystack
|
|
||||||
func contains(haystack []string, needle string) bool {
|
|
||||||
for _, a := range haystack {
|
|
||||||
if strings.ToLower(a) == strings.ToLower(needle) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify optional parameters are of the correct type.
|
|
||||||
func typeCheckParameter(obj interface{}, expected string, name string) error {
|
|
||||||
// Make sure there is an object.
|
|
||||||
if obj == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the type is as expected.
|
|
||||||
if reflect.TypeOf(obj).String() != expected {
|
|
||||||
return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String())
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// parameterToString convert interface{} parameters to string, using a delimiter if format is provided.
|
|
||||||
func parameterToString(obj interface{}, collectionFormat string) string {
|
|
||||||
var delimiter string
|
|
||||||
|
|
||||||
switch collectionFormat {
|
|
||||||
case "pipes":
|
|
||||||
delimiter = "|"
|
|
||||||
case "ssv":
|
|
||||||
delimiter = " "
|
|
||||||
case "tsv":
|
|
||||||
delimiter = "\t"
|
|
||||||
case "csv":
|
|
||||||
delimiter = ","
|
|
||||||
}
|
|
||||||
|
|
||||||
if reflect.TypeOf(obj).Kind() == reflect.Slice {
|
|
||||||
return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
|
|
||||||
} else if t, ok := obj.(time.Time); ok {
|
|
||||||
return t.Format(time.RFC3339)
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf("%v", obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper for converting interface{} parameters to json strings
|
|
||||||
func parameterToJson(obj interface{}) (string, error) {
|
|
||||||
jsonBuf, err := json.Marshal(obj)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return string(jsonBuf), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// callAPI do the request.
|
|
||||||
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
|
|
||||||
if c.cfg.Debug {
|
|
||||||
dump, err := httputil.DumpRequestOut(request, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
log.Printf("\n%s\n", string(dump))
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := c.cfg.HTTPClient.Do(request)
|
|
||||||
if err != nil {
|
|
||||||
return resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.cfg.Debug {
|
|
||||||
dump, err := httputil.DumpResponse(resp, true)
|
|
||||||
if err != nil {
|
|
||||||
return resp, err
|
|
||||||
}
|
|
||||||
log.Printf("\n%s\n", string(dump))
|
|
||||||
}
|
|
||||||
return resp, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow modification of underlying config for alternate implementations and testing
|
|
||||||
// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
|
|
||||||
func (c *APIClient) GetConfig() *Configuration {
|
|
||||||
return c.cfg
|
|
||||||
}
|
|
||||||
|
|
||||||
type formFile struct {
|
|
||||||
fileBytes []byte
|
|
||||||
fileName string
|
|
||||||
formFileName string
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepareRequest build the request
|
|
||||||
func (c *APIClient) prepareRequest(
|
|
||||||
ctx context.Context,
|
|
||||||
path string, method string,
|
|
||||||
postBody interface{},
|
|
||||||
headerParams map[string]string,
|
|
||||||
queryParams url.Values,
|
|
||||||
formParams url.Values,
|
|
||||||
formFiles []formFile) (localVarRequest *http.Request, err error) {
|
|
||||||
|
|
||||||
var body *bytes.Buffer
|
|
||||||
|
|
||||||
// Detect postBody type and post.
|
|
||||||
if postBody != nil {
|
|
||||||
contentType := headerParams["Content-Type"]
|
|
||||||
if contentType == "" {
|
|
||||||
contentType = detectContentType(postBody)
|
|
||||||
headerParams["Content-Type"] = contentType
|
|
||||||
}
|
|
||||||
|
|
||||||
body, err = setBody(postBody, contentType)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add form parameters and file if available.
|
|
||||||
if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) {
|
|
||||||
if body != nil {
|
|
||||||
return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
|
|
||||||
}
|
|
||||||
body = &bytes.Buffer{}
|
|
||||||
w := multipart.NewWriter(body)
|
|
||||||
|
|
||||||
for k, v := range formParams {
|
|
||||||
for _, iv := range v {
|
|
||||||
if strings.HasPrefix(k, "@") { // file
|
|
||||||
err = addFile(w, k[1:], iv)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
} else { // form value
|
|
||||||
w.WriteField(k, iv)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, formFile := range formFiles {
|
|
||||||
if len(formFile.fileBytes) > 0 && formFile.fileName != "" {
|
|
||||||
w.Boundary()
|
|
||||||
part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
_, err = part.Write(formFile.fileBytes)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the Boundary in the Content-Type
|
|
||||||
headerParams["Content-Type"] = w.FormDataContentType()
|
|
||||||
|
|
||||||
// Set Content-Length
|
|
||||||
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
|
|
||||||
w.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
|
|
||||||
if body != nil {
|
|
||||||
return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.")
|
|
||||||
}
|
|
||||||
body = &bytes.Buffer{}
|
|
||||||
body.WriteString(formParams.Encode())
|
|
||||||
// Set Content-Length
|
|
||||||
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup path and query parameters
|
|
||||||
url, err := url.Parse(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override request host, if applicable
|
|
||||||
if c.cfg.Host != "" {
|
|
||||||
url.Host = c.cfg.Host
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override request scheme, if applicable
|
|
||||||
if c.cfg.Scheme != "" {
|
|
||||||
url.Scheme = c.cfg.Scheme
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adding Query Param
|
|
||||||
query := url.Query()
|
|
||||||
for k, v := range queryParams {
|
|
||||||
for _, iv := range v {
|
|
||||||
query.Add(k, iv)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode the parameters.
|
|
||||||
url.RawQuery = query.Encode()
|
|
||||||
|
|
||||||
// Generate a new request
|
|
||||||
if body != nil {
|
|
||||||
localVarRequest, err = http.NewRequest(method, url.String(), body)
|
|
||||||
} else {
|
|
||||||
localVarRequest, err = http.NewRequest(method, url.String(), nil)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// add header parameters, if any
|
|
||||||
if len(headerParams) > 0 {
|
|
||||||
headers := http.Header{}
|
|
||||||
for h, v := range headerParams {
|
|
||||||
headers.Set(h, v)
|
|
||||||
}
|
|
||||||
localVarRequest.Header = headers
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the user agent to the request.
|
|
||||||
localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
|
|
||||||
|
|
||||||
if ctx != nil {
|
|
||||||
// add context to the request
|
|
||||||
localVarRequest = localVarRequest.WithContext(ctx)
|
|
||||||
|
|
||||||
// Walk through any authentication.
|
|
||||||
|
|
||||||
// OAuth2 authentication
|
|
||||||
if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok {
|
|
||||||
// We were able to grab an oauth2 token from the context
|
|
||||||
var latestToken *oauth2.Token
|
|
||||||
if latestToken, err = tok.Token(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
latestToken.SetAuthHeader(localVarRequest)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Basic HTTP Authentication
|
|
||||||
if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok {
|
|
||||||
localVarRequest.SetBasicAuth(auth.UserName, auth.Password)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AccessToken Authentication
|
|
||||||
if auth, ok := ctx.Value(ContextAccessToken).(string); ok {
|
|
||||||
localVarRequest.Header.Add("Authorization", "Bearer "+auth)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for header, value := range c.cfg.DefaultHeader {
|
|
||||||
localVarRequest.Header.Add(header, value)
|
|
||||||
}
|
|
||||||
return localVarRequest, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
|
|
||||||
if len(b) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if s, ok := v.(*string); ok {
|
|
||||||
*s = string(b)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if f, ok := v.(**os.File); ok {
|
|
||||||
*f, err = ioutil.TempFile("", "HttpClientFile")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_, err = (*f).Write(b)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_, err = (*f).Seek(0, io.SeekStart)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if xmlCheck.MatchString(contentType) {
|
|
||||||
if err = xml.Unmarshal(b, v); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if jsonCheck.MatchString(contentType) {
|
|
||||||
if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas
|
|
||||||
if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined
|
|
||||||
if err = unmarshalObj.UnmarshalJSON(b); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
|
|
||||||
}
|
|
||||||
} else if err = json.Unmarshal(b, v); err != nil { // simple model
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return errors.New("undefined response type")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a file to the multipart request
|
|
||||||
func addFile(w *multipart.Writer, fieldName, path string) error {
|
|
||||||
file, err := os.Open(path)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
part, err := w.CreateFormFile(fieldName, filepath.Base(path))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
_, err = io.Copy(part, file)
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent trying to import "fmt"
|
|
||||||
func reportError(format string, a ...interface{}) error {
|
|
||||||
return fmt.Errorf(format, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set request body from an interface{}
|
|
||||||
func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
|
|
||||||
if bodyBuf == nil {
|
|
||||||
bodyBuf = &bytes.Buffer{}
|
|
||||||
}
|
|
||||||
|
|
||||||
if reader, ok := body.(io.Reader); ok {
|
|
||||||
_, err = bodyBuf.ReadFrom(reader)
|
|
||||||
} else if fp, ok := body.(**os.File); ok {
|
|
||||||
_, err = bodyBuf.ReadFrom(*fp)
|
|
||||||
} else if b, ok := body.([]byte); ok {
|
|
||||||
_, err = bodyBuf.Write(b)
|
|
||||||
} else if s, ok := body.(string); ok {
|
|
||||||
_, err = bodyBuf.WriteString(s)
|
|
||||||
} else if s, ok := body.(*string); ok {
|
|
||||||
_, err = bodyBuf.WriteString(*s)
|
|
||||||
} else if jsonCheck.MatchString(contentType) {
|
|
||||||
err = json.NewEncoder(bodyBuf).Encode(body)
|
|
||||||
} else if xmlCheck.MatchString(contentType) {
|
|
||||||
err = xml.NewEncoder(bodyBuf).Encode(body)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if bodyBuf.Len() == 0 {
|
|
||||||
err = fmt.Errorf("Invalid body type %s\n", contentType)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return bodyBuf, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// detectContentType method is used to figure out `Request.Body` content type for request header
|
|
||||||
func detectContentType(body interface{}) string {
|
|
||||||
contentType := "text/plain; charset=utf-8"
|
|
||||||
kind := reflect.TypeOf(body).Kind()
|
|
||||||
|
|
||||||
switch kind {
|
|
||||||
case reflect.Struct, reflect.Map, reflect.Ptr:
|
|
||||||
contentType = "application/json; charset=utf-8"
|
|
||||||
case reflect.String:
|
|
||||||
contentType = "text/plain; charset=utf-8"
|
|
||||||
default:
|
|
||||||
if b, ok := body.([]byte); ok {
|
|
||||||
contentType = http.DetectContentType(b)
|
|
||||||
} else if kind == reflect.Slice {
|
|
||||||
contentType = "application/json; charset=utf-8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return contentType
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
|
|
||||||
type cacheControl map[string]string
|
|
||||||
|
|
||||||
func parseCacheControl(headers http.Header) cacheControl {
|
|
||||||
cc := cacheControl{}
|
|
||||||
ccHeader := headers.Get("Cache-Control")
|
|
||||||
for _, part := range strings.Split(ccHeader, ",") {
|
|
||||||
part = strings.Trim(part, " ")
|
|
||||||
if part == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strings.ContainsRune(part, '=') {
|
|
||||||
keyval := strings.Split(part, "=")
|
|
||||||
cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
|
|
||||||
} else {
|
|
||||||
cc[part] = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cc
|
|
||||||
}
|
|
||||||
|
|
||||||
// CacheExpires helper function to determine remaining time before repeating a request.
|
|
||||||
func CacheExpires(r *http.Response) time.Time {
|
|
||||||
// Figure out when the cache expires.
|
|
||||||
var expires time.Time
|
|
||||||
now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
|
|
||||||
if err != nil {
|
|
||||||
return time.Now()
|
|
||||||
}
|
|
||||||
respCacheControl := parseCacheControl(r.Header)
|
|
||||||
|
|
||||||
if maxAge, ok := respCacheControl["max-age"]; ok {
|
|
||||||
lifetime, err := time.ParseDuration(maxAge + "s")
|
|
||||||
if err != nil {
|
|
||||||
expires = now
|
|
||||||
} else {
|
|
||||||
expires = now.Add(lifetime)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
expiresHeader := r.Header.Get("Expires")
|
|
||||||
if expiresHeader != "" {
|
|
||||||
expires, err = time.Parse(time.RFC1123, expiresHeader)
|
|
||||||
if err != nil {
|
|
||||||
expires = now
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return expires
|
|
||||||
}
|
|
||||||
|
|
||||||
func strlen(s string) int {
|
|
||||||
return utf8.RuneCountInString(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GenericOpenAPIError Provides access to the body, error and model on returned errors.
|
|
||||||
type GenericOpenAPIError struct {
|
|
||||||
body []byte
|
|
||||||
error string
|
|
||||||
model interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error returns non-empty string if there was an error.
|
|
||||||
func (e GenericOpenAPIError) Error() string {
|
|
||||||
return e.error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Body returns the raw bytes of the response
|
|
||||||
func (e GenericOpenAPIError) Body() []byte {
|
|
||||||
return e.body
|
|
||||||
}
|
|
||||||
|
|
||||||
// Model returns the unpacked model of the error
|
|
||||||
func (e GenericOpenAPIError) Model() interface{} {
|
|
||||||
return e.model
|
|
||||||
}
|
|
@ -1,230 +0,0 @@
|
|||||||
/*
|
|
||||||
Multiple Files via form-data
|
|
||||||
|
|
||||||
This is a sample server with a single endpoint that accepts two files via a multipart/form-data POST request.
|
|
||||||
|
|
||||||
API version: 1.0.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
||||||
|
|
||||||
package openapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// contextKeys are used to identify the type of value in the context.
|
|
||||||
// Since these are string, it is possible to get a short description of the
|
|
||||||
// context key for logging and debugging using key.String().
|
|
||||||
|
|
||||||
type contextKey string
|
|
||||||
|
|
||||||
func (c contextKey) String() string {
|
|
||||||
return "auth " + string(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
|
|
||||||
ContextOAuth2 = contextKey("token")
|
|
||||||
|
|
||||||
// ContextBasicAuth takes BasicAuth as authentication for the request.
|
|
||||||
ContextBasicAuth = contextKey("basic")
|
|
||||||
|
|
||||||
// ContextAccessToken takes a string oauth2 access token as authentication for the request.
|
|
||||||
ContextAccessToken = contextKey("accesstoken")
|
|
||||||
|
|
||||||
// ContextAPIKeys takes a string apikey as authentication for the request
|
|
||||||
ContextAPIKeys = contextKey("apiKeys")
|
|
||||||
|
|
||||||
// ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request.
|
|
||||||
ContextHttpSignatureAuth = contextKey("httpsignature")
|
|
||||||
|
|
||||||
// ContextServerIndex uses a server configuration from the index.
|
|
||||||
ContextServerIndex = contextKey("serverIndex")
|
|
||||||
|
|
||||||
// ContextOperationServerIndices uses a server configuration from the index mapping.
|
|
||||||
ContextOperationServerIndices = contextKey("serverOperationIndices")
|
|
||||||
|
|
||||||
// ContextServerVariables overrides a server configuration variables.
|
|
||||||
ContextServerVariables = contextKey("serverVariables")
|
|
||||||
|
|
||||||
// ContextOperationServerVariables overrides a server configuration variables using operation specific values.
|
|
||||||
ContextOperationServerVariables = contextKey("serverOperationVariables")
|
|
||||||
)
|
|
||||||
|
|
||||||
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
|
|
||||||
type BasicAuth struct {
|
|
||||||
UserName string `json:"userName,omitempty"`
|
|
||||||
Password string `json:"password,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey
|
|
||||||
type APIKey struct {
|
|
||||||
Key string
|
|
||||||
Prefix string
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServerVariable stores the information about a server variable
|
|
||||||
type ServerVariable struct {
|
|
||||||
Description string
|
|
||||||
DefaultValue string
|
|
||||||
EnumValues []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServerConfiguration stores the information about a server
|
|
||||||
type ServerConfiguration struct {
|
|
||||||
URL string
|
|
||||||
Description string
|
|
||||||
Variables map[string]ServerVariable
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServerConfigurations stores multiple ServerConfiguration items
|
|
||||||
type ServerConfigurations []ServerConfiguration
|
|
||||||
|
|
||||||
// Configuration stores the configuration of the API client
|
|
||||||
type Configuration struct {
|
|
||||||
Host string `json:"host,omitempty"`
|
|
||||||
Scheme string `json:"scheme,omitempty"`
|
|
||||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
|
||||||
UserAgent string `json:"userAgent,omitempty"`
|
|
||||||
Debug bool `json:"debug,omitempty"`
|
|
||||||
Servers ServerConfigurations
|
|
||||||
OperationServers map[string]ServerConfigurations
|
|
||||||
HTTPClient *http.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewConfiguration returns a new Configuration object
|
|
||||||
func NewConfiguration() *Configuration {
|
|
||||||
cfg := &Configuration{
|
|
||||||
DefaultHeader: make(map[string]string),
|
|
||||||
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
|
||||||
Debug: false,
|
|
||||||
Servers: ServerConfigurations{
|
|
||||||
{
|
|
||||||
URL: "http://example.com",
|
|
||||||
Description: "No description provided",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
OperationServers: map[string]ServerConfigurations{
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return cfg
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddDefaultHeader adds a new HTTP header to the default header in the request
|
|
||||||
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
|
||||||
c.DefaultHeader[key] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
// URL formats template on a index using given variables
|
|
||||||
func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) {
|
|
||||||
if index < 0 || len(sc) <= index {
|
|
||||||
return "", fmt.Errorf("Index %v out of range %v", index, len(sc)-1)
|
|
||||||
}
|
|
||||||
server := sc[index]
|
|
||||||
url := server.URL
|
|
||||||
|
|
||||||
// go through variables and replace placeholders
|
|
||||||
for name, variable := range server.Variables {
|
|
||||||
if value, ok := variables[name]; ok {
|
|
||||||
found := bool(len(variable.EnumValues) == 0)
|
|
||||||
for _, enumValue := range variable.EnumValues {
|
|
||||||
if value == enumValue {
|
|
||||||
found = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return "", fmt.Errorf("The variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
|
|
||||||
}
|
|
||||||
url = strings.Replace(url, "{"+name+"}", value, -1)
|
|
||||||
} else {
|
|
||||||
url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return url, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServerURL returns URL based on server settings
|
|
||||||
func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) {
|
|
||||||
return c.Servers.URL(index, variables)
|
|
||||||
}
|
|
||||||
|
|
||||||
func getServerIndex(ctx context.Context) (int, error) {
|
|
||||||
si := ctx.Value(ContextServerIndex)
|
|
||||||
if si != nil {
|
|
||||||
if index, ok := si.(int); ok {
|
|
||||||
return index, nil
|
|
||||||
}
|
|
||||||
return 0, reportError("Invalid type %T should be int", si)
|
|
||||||
}
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) {
|
|
||||||
osi := ctx.Value(ContextOperationServerIndices)
|
|
||||||
if osi != nil {
|
|
||||||
if operationIndices, ok := osi.(map[string]int); !ok {
|
|
||||||
return 0, reportError("Invalid type %T should be map[string]int", osi)
|
|
||||||
} else {
|
|
||||||
index, ok := operationIndices[endpoint]
|
|
||||||
if ok {
|
|
||||||
return index, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getServerIndex(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func getServerVariables(ctx context.Context) (map[string]string, error) {
|
|
||||||
sv := ctx.Value(ContextServerVariables)
|
|
||||||
if sv != nil {
|
|
||||||
if variables, ok := sv.(map[string]string); ok {
|
|
||||||
return variables, nil
|
|
||||||
}
|
|
||||||
return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv)
|
|
||||||
}
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) {
|
|
||||||
osv := ctx.Value(ContextOperationServerVariables)
|
|
||||||
if osv != nil {
|
|
||||||
if operationVariables, ok := osv.(map[string]map[string]string); !ok {
|
|
||||||
return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv)
|
|
||||||
} else {
|
|
||||||
variables, ok := operationVariables[endpoint]
|
|
||||||
if ok {
|
|
||||||
return variables, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getServerVariables(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServerURLWithContext returns a new server URL given an endpoint
|
|
||||||
func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) {
|
|
||||||
sc, ok := c.OperationServers[endpoint]
|
|
||||||
if !ok {
|
|
||||||
sc = c.Servers
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx == nil {
|
|
||||||
return sc.URL(0, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
index, err := getServerOperationIndex(ctx, endpoint)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
variables, err := getServerOperationVariables(ctx, endpoint)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return sc.URL(index, variables)
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
# ApiResponse
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Code** | Pointer to **int32** | | [optional]
|
|
||||||
**Type** | Pointer to **string** | | [optional]
|
|
||||||
**Message** | Pointer to **string** | | [optional]
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
### NewApiResponse
|
|
||||||
|
|
||||||
`func NewApiResponse() *ApiResponse`
|
|
||||||
|
|
||||||
NewApiResponse instantiates a new ApiResponse object
|
|
||||||
This constructor will assign default values to properties that have it defined,
|
|
||||||
and makes sure properties required by API are set, but the set of arguments
|
|
||||||
will change when the set of required properties is changed
|
|
||||||
|
|
||||||
### NewApiResponseWithDefaults
|
|
||||||
|
|
||||||
`func NewApiResponseWithDefaults() *ApiResponse`
|
|
||||||
|
|
||||||
NewApiResponseWithDefaults instantiates a new ApiResponse object
|
|
||||||
This constructor will only assign default values to properties that have it defined,
|
|
||||||
but it doesn't guarantee that properties required by API are set
|
|
||||||
|
|
||||||
### GetCode
|
|
||||||
|
|
||||||
`func (o *ApiResponse) GetCode() int32`
|
|
||||||
|
|
||||||
GetCode returns the Code field if non-nil, zero value otherwise.
|
|
||||||
|
|
||||||
### GetCodeOk
|
|
||||||
|
|
||||||
`func (o *ApiResponse) GetCodeOk() (*int32, bool)`
|
|
||||||
|
|
||||||
GetCodeOk returns a tuple with the Code field if it's non-nil, zero value otherwise
|
|
||||||
and a boolean to check if the value has been set.
|
|
||||||
|
|
||||||
### SetCode
|
|
||||||
|
|
||||||
`func (o *ApiResponse) SetCode(v int32)`
|
|
||||||
|
|
||||||
SetCode sets Code field to given value.
|
|
||||||
|
|
||||||
### HasCode
|
|
||||||
|
|
||||||
`func (o *ApiResponse) HasCode() bool`
|
|
||||||
|
|
||||||
HasCode returns a boolean if a field has been set.
|
|
||||||
|
|
||||||
### GetType
|
|
||||||
|
|
||||||
`func (o *ApiResponse) GetType() string`
|
|
||||||
|
|
||||||
GetType returns the Type field if non-nil, zero value otherwise.
|
|
||||||
|
|
||||||
### GetTypeOk
|
|
||||||
|
|
||||||
`func (o *ApiResponse) GetTypeOk() (*string, bool)`
|
|
||||||
|
|
||||||
GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise
|
|
||||||
and a boolean to check if the value has been set.
|
|
||||||
|
|
||||||
### SetType
|
|
||||||
|
|
||||||
`func (o *ApiResponse) SetType(v string)`
|
|
||||||
|
|
||||||
SetType sets Type field to given value.
|
|
||||||
|
|
||||||
### HasType
|
|
||||||
|
|
||||||
`func (o *ApiResponse) HasType() bool`
|
|
||||||
|
|
||||||
HasType returns a boolean if a field has been set.
|
|
||||||
|
|
||||||
### GetMessage
|
|
||||||
|
|
||||||
`func (o *ApiResponse) GetMessage() string`
|
|
||||||
|
|
||||||
GetMessage returns the Message field if non-nil, zero value otherwise.
|
|
||||||
|
|
||||||
### GetMessageOk
|
|
||||||
|
|
||||||
`func (o *ApiResponse) GetMessageOk() (*string, bool)`
|
|
||||||
|
|
||||||
GetMessageOk returns a tuple with the Message field if it's non-nil, zero value otherwise
|
|
||||||
and a boolean to check if the value has been set.
|
|
||||||
|
|
||||||
### SetMessage
|
|
||||||
|
|
||||||
`func (o *ApiResponse) SetMessage(v string)`
|
|
||||||
|
|
||||||
SetMessage sets Message field to given value.
|
|
||||||
|
|
||||||
### HasMessage
|
|
||||||
|
|
||||||
`func (o *ApiResponse) HasMessage() bool`
|
|
||||||
|
|
||||||
HasMessage returns a boolean if a field has been set.
|
|
||||||
|
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
|
||||||
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
|||||||
# \DefaultApi
|
|
||||||
|
|
||||||
All URIs are relative to *http://example.com*
|
|
||||||
|
|
||||||
Method | HTTP request | Description
|
|
||||||
------------- | ------------- | -------------
|
|
||||||
[**UploadFiles**](DefaultApi.md#UploadFiles) | **Post** /uploadFiles | uploads two files
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## UploadFiles
|
|
||||||
|
|
||||||
> ApiResponse UploadFiles(ctx).File(file).SecondFile(secondFile).Execute()
|
|
||||||
|
|
||||||
uploads two files
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```go
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
openapiclient "./openapi"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
file := os.NewFile(1234, "some_file") // *os.File | file to upload (optional)
|
|
||||||
secondFile := os.NewFile(1234, "some_file") // *os.File | another file to upload (optional)
|
|
||||||
|
|
||||||
configuration := openapiclient.NewConfiguration()
|
|
||||||
api_client := openapiclient.NewAPIClient(configuration)
|
|
||||||
resp, r, err := api_client.DefaultApi.UploadFiles(context.Background()).File(file).SecondFile(secondFile).Execute()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.UploadFiles``: %v\n", err)
|
|
||||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
|
||||||
}
|
|
||||||
// response from `UploadFiles`: ApiResponse
|
|
||||||
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.UploadFiles`: %v\n", resp)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Path Parameters
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Other Parameters
|
|
||||||
|
|
||||||
Other parameters are passed through a pointer to a apiUploadFilesRequest struct via the builder pattern
|
|
||||||
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------- | ------------- | ------------- | -------------
|
|
||||||
**file** | ***os.File** | file to upload |
|
|
||||||
**secondFile** | ***os.File** | another file to upload |
|
|
||||||
|
|
||||||
### Return type
|
|
||||||
|
|
||||||
[**ApiResponse**](ApiResponse.md)
|
|
||||||
|
|
||||||
### Authorization
|
|
||||||
|
|
||||||
No authorization required
|
|
||||||
|
|
||||||
### 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)
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
|
||||||
#
|
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
|
||||||
|
|
||||||
git_user_id=$1
|
|
||||||
git_repo_id=$2
|
|
||||||
release_note=$3
|
|
||||||
git_host=$4
|
|
||||||
|
|
||||||
if [ "$git_host" = "" ]; then
|
|
||||||
git_host="github.com"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$git_user_id" = "" ]; then
|
|
||||||
git_user_id="GIT_USER_ID"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$git_repo_id" = "" ]; then
|
|
||||||
git_repo_id="GIT_REPO_ID"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$release_note" = "" ]; then
|
|
||||||
release_note="Minor update"
|
|
||||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Initialize the local directory as a Git repository
|
|
||||||
git init
|
|
||||||
|
|
||||||
# Adds the files in the local repository and stages them for commit.
|
|
||||||
git add .
|
|
||||||
|
|
||||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
|
||||||
git commit -m "$release_note"
|
|
||||||
|
|
||||||
# Sets the new remote
|
|
||||||
git_remote=$(git remote)
|
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
|
||||||
else
|
|
||||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
git pull origin master
|
|
||||||
|
|
||||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
|
||||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
|
||||||
git push origin master 2>&1 | grep -v 'To https'
|
|
@ -1,7 +0,0 @@
|
|||||||
module github.com/GIT_USER_ID/GIT_REPO_ID
|
|
||||||
|
|
||||||
go 1.13
|
|
||||||
|
|
||||||
require (
|
|
||||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99
|
|
||||||
)
|
|
@ -1,13 +0,0 @@
|
|||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
|
||||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
|
|
||||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
|
@ -1,187 +0,0 @@
|
|||||||
/*
|
|
||||||
Multiple Files via form-data
|
|
||||||
|
|
||||||
This is a sample server with a single endpoint that accepts two files via a multipart/form-data POST request.
|
|
||||||
|
|
||||||
API version: 1.0.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
||||||
|
|
||||||
package openapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ApiResponse Describes the result of uploading files
|
|
||||||
type ApiResponse struct {
|
|
||||||
Code *int32 `json:"code,omitempty"`
|
|
||||||
Type *string `json:"type,omitempty"`
|
|
||||||
Message *string `json:"message,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewApiResponse instantiates a new ApiResponse object
|
|
||||||
// This constructor will assign default values to properties that have it defined,
|
|
||||||
// and makes sure properties required by API are set, but the set of arguments
|
|
||||||
// will change when the set of required properties is changed
|
|
||||||
func NewApiResponse() *ApiResponse {
|
|
||||||
this := ApiResponse{}
|
|
||||||
return &this
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewApiResponseWithDefaults instantiates a new ApiResponse object
|
|
||||||
// This constructor will only assign default values to properties that have it defined,
|
|
||||||
// but it doesn't guarantee that properties required by API are set
|
|
||||||
func NewApiResponseWithDefaults() *ApiResponse {
|
|
||||||
this := ApiResponse{}
|
|
||||||
return &this
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCode returns the Code field value if set, zero value otherwise.
|
|
||||||
func (o *ApiResponse) GetCode() int32 {
|
|
||||||
if o == nil || o.Code == nil {
|
|
||||||
var ret int32
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
return *o.Code
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCodeOk returns a tuple with the Code field value if set, nil otherwise
|
|
||||||
// and a boolean to check if the value has been set.
|
|
||||||
func (o *ApiResponse) GetCodeOk() (*int32, bool) {
|
|
||||||
if o == nil || o.Code == nil {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
return o.Code, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// HasCode returns a boolean if a field has been set.
|
|
||||||
func (o *ApiResponse) HasCode() bool {
|
|
||||||
if o != nil && o.Code != nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetCode gets a reference to the given int32 and assigns it to the Code field.
|
|
||||||
func (o *ApiResponse) SetCode(v int32) {
|
|
||||||
o.Code = &v
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetType returns the Type field value if set, zero value otherwise.
|
|
||||||
func (o *ApiResponse) GetType() string {
|
|
||||||
if o == nil || o.Type == nil {
|
|
||||||
var ret string
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
return *o.Type
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTypeOk returns a tuple with the Type field value if set, nil otherwise
|
|
||||||
// and a boolean to check if the value has been set.
|
|
||||||
func (o *ApiResponse) GetTypeOk() (*string, bool) {
|
|
||||||
if o == nil || o.Type == nil {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
return o.Type, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// HasType returns a boolean if a field has been set.
|
|
||||||
func (o *ApiResponse) HasType() bool {
|
|
||||||
if o != nil && o.Type != nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetType gets a reference to the given string and assigns it to the Type field.
|
|
||||||
func (o *ApiResponse) SetType(v string) {
|
|
||||||
o.Type = &v
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetMessage returns the Message field value if set, zero value otherwise.
|
|
||||||
func (o *ApiResponse) GetMessage() string {
|
|
||||||
if o == nil || o.Message == nil {
|
|
||||||
var ret string
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
return *o.Message
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetMessageOk returns a tuple with the Message field value if set, nil otherwise
|
|
||||||
// and a boolean to check if the value has been set.
|
|
||||||
func (o *ApiResponse) GetMessageOk() (*string, bool) {
|
|
||||||
if o == nil || o.Message == nil {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
return o.Message, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// HasMessage returns a boolean if a field has been set.
|
|
||||||
func (o *ApiResponse) HasMessage() bool {
|
|
||||||
if o != nil && o.Message != nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMessage gets a reference to the given string and assigns it to the Message field.
|
|
||||||
func (o *ApiResponse) SetMessage(v string) {
|
|
||||||
o.Message = &v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o ApiResponse) MarshalJSON() ([]byte, error) {
|
|
||||||
toSerialize := map[string]interface{}{}
|
|
||||||
if o.Code != nil {
|
|
||||||
toSerialize["code"] = o.Code
|
|
||||||
}
|
|
||||||
if o.Type != nil {
|
|
||||||
toSerialize["type"] = o.Type
|
|
||||||
}
|
|
||||||
if o.Message != nil {
|
|
||||||
toSerialize["message"] = o.Message
|
|
||||||
}
|
|
||||||
return json.Marshal(toSerialize)
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullableApiResponse struct {
|
|
||||||
value *ApiResponse
|
|
||||||
isSet bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableApiResponse) Get() *ApiResponse {
|
|
||||||
return v.value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableApiResponse) Set(val *ApiResponse) {
|
|
||||||
v.value = val
|
|
||||||
v.isSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableApiResponse) IsSet() bool {
|
|
||||||
return v.isSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableApiResponse) Unset() {
|
|
||||||
v.value = nil
|
|
||||||
v.isSet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullableApiResponse(val *ApiResponse) *NullableApiResponse {
|
|
||||||
return &NullableApiResponse{value: val, isSet: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableApiResponse) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableApiResponse) UnmarshalJSON(src []byte) error {
|
|
||||||
v.isSet = true
|
|
||||||
return json.Unmarshal(src, &v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
|||||||
openapi: 3.0.0
|
|
||||||
servers:
|
|
||||||
- url: "http://example.com"
|
|
||||||
info:
|
|
||||||
description: >-
|
|
||||||
This is a sample server with a single endpoint that accepts two files via a multipart/form-data POST request.
|
|
||||||
version: 1.0.0
|
|
||||||
title: Multiple Files via form-data
|
|
||||||
license:
|
|
||||||
name: Apache-2.0
|
|
||||||
url: "https://www.apache.org/licenses/LICENSE-2.0.html"
|
|
||||||
paths:
|
|
||||||
"/uploadFiles":
|
|
||||||
post:
|
|
||||||
summary: uploads two files
|
|
||||||
description: ""
|
|
||||||
operationId: uploadFiles
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: successful operation
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/ApiResponse"
|
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
secondFile:
|
|
||||||
description: another file to upload
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
components:
|
|
||||||
schemas:
|
|
||||||
ApiResponse:
|
|
||||||
title: An uploaded response
|
|
||||||
description: Describes the result of uploading files
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
code:
|
|
||||||
type: integer
|
|
||||||
format: int32
|
|
||||||
type:
|
|
||||||
type: string
|
|
||||||
message:
|
|
||||||
type: string
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
Multiple Files via form-data
|
|
||||||
|
|
||||||
This is a sample server with a single endpoint that accepts two files via a multipart/form-data POST request.
|
|
||||||
|
|
||||||
API version: 1.0.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
||||||
|
|
||||||
package openapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// APIResponse stores the API response returned by the server.
|
|
||||||
type APIResponse struct {
|
|
||||||
*http.Response `json:"-"`
|
|
||||||
Message string `json:"message,omitempty"`
|
|
||||||
// Operation is the name of the OpenAPI operation.
|
|
||||||
Operation string `json:"operation,omitempty"`
|
|
||||||
// RequestURL is the request URL. This value is always available, even if the
|
|
||||||
// embedded *http.Response is nil.
|
|
||||||
RequestURL string `json:"url,omitempty"`
|
|
||||||
// Method is the HTTP method used for the request. This value is always
|
|
||||||
// available, even if the embedded *http.Response is nil.
|
|
||||||
Method string `json:"method,omitempty"`
|
|
||||||
// Payload holds the contents of the response body (which may be nil or empty).
|
|
||||||
// This is provided here as the raw response.Body() reader will have already
|
|
||||||
// been drained.
|
|
||||||
Payload []byte `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAPIResponse returns a new APIResponse object.
|
|
||||||
func NewAPIResponse(r *http.Response) *APIResponse {
|
|
||||||
|
|
||||||
response := &APIResponse{Response: r}
|
|
||||||
return response
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAPIResponseWithError returns a new APIResponse object with the provided error message.
|
|
||||||
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
|
||||||
|
|
||||||
response := &APIResponse{Message: errorMessage}
|
|
||||||
return response
|
|
||||||
}
|
|
@ -1,328 +0,0 @@
|
|||||||
/*
|
|
||||||
Multiple Files via form-data
|
|
||||||
|
|
||||||
This is a sample server with a single endpoint that accepts two files via a multipart/form-data POST request.
|
|
||||||
|
|
||||||
API version: 1.0.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
||||||
|
|
||||||
package openapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PtrBool is a helper routine that returns a pointer to given boolean value.
|
|
||||||
func PtrBool(v bool) *bool { return &v }
|
|
||||||
|
|
||||||
// PtrInt is a helper routine that returns a pointer to given integer value.
|
|
||||||
func PtrInt(v int) *int { return &v }
|
|
||||||
|
|
||||||
// PtrInt32 is a helper routine that returns a pointer to given integer value.
|
|
||||||
func PtrInt32(v int32) *int32 { return &v }
|
|
||||||
|
|
||||||
// PtrInt64 is a helper routine that returns a pointer to given integer value.
|
|
||||||
func PtrInt64(v int64) *int64 { return &v }
|
|
||||||
|
|
||||||
// PtrFloat32 is a helper routine that returns a pointer to given float value.
|
|
||||||
func PtrFloat32(v float32) *float32 { return &v }
|
|
||||||
|
|
||||||
// PtrFloat64 is a helper routine that returns a pointer to given float value.
|
|
||||||
func PtrFloat64(v float64) *float64 { return &v }
|
|
||||||
|
|
||||||
// PtrString is a helper routine that returns a pointer to given string value.
|
|
||||||
func PtrString(v string) *string { return &v }
|
|
||||||
|
|
||||||
// PtrTime is helper routine that returns a pointer to given Time value.
|
|
||||||
func PtrTime(v time.Time) *time.Time { return &v }
|
|
||||||
|
|
||||||
type NullableBool struct {
|
|
||||||
value *bool
|
|
||||||
isSet bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableBool) Get() *bool {
|
|
||||||
return v.value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableBool) Set(val *bool) {
|
|
||||||
v.value = val
|
|
||||||
v.isSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableBool) IsSet() bool {
|
|
||||||
return v.isSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableBool) Unset() {
|
|
||||||
v.value = nil
|
|
||||||
v.isSet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullableBool(val *bool) *NullableBool {
|
|
||||||
return &NullableBool{value: val, isSet: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableBool) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableBool) UnmarshalJSON(src []byte) error {
|
|
||||||
v.isSet = true
|
|
||||||
return json.Unmarshal(src, &v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullableInt struct {
|
|
||||||
value *int
|
|
||||||
isSet bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableInt) Get() *int {
|
|
||||||
return v.value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableInt) Set(val *int) {
|
|
||||||
v.value = val
|
|
||||||
v.isSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableInt) IsSet() bool {
|
|
||||||
return v.isSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableInt) Unset() {
|
|
||||||
v.value = nil
|
|
||||||
v.isSet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullableInt(val *int) *NullableInt {
|
|
||||||
return &NullableInt{value: val, isSet: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableInt) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableInt) UnmarshalJSON(src []byte) error {
|
|
||||||
v.isSet = true
|
|
||||||
return json.Unmarshal(src, &v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullableInt32 struct {
|
|
||||||
value *int32
|
|
||||||
isSet bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableInt32) Get() *int32 {
|
|
||||||
return v.value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableInt32) Set(val *int32) {
|
|
||||||
v.value = val
|
|
||||||
v.isSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableInt32) IsSet() bool {
|
|
||||||
return v.isSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableInt32) Unset() {
|
|
||||||
v.value = nil
|
|
||||||
v.isSet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullableInt32(val *int32) *NullableInt32 {
|
|
||||||
return &NullableInt32{value: val, isSet: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableInt32) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableInt32) UnmarshalJSON(src []byte) error {
|
|
||||||
v.isSet = true
|
|
||||||
return json.Unmarshal(src, &v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullableInt64 struct {
|
|
||||||
value *int64
|
|
||||||
isSet bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableInt64) Get() *int64 {
|
|
||||||
return v.value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableInt64) Set(val *int64) {
|
|
||||||
v.value = val
|
|
||||||
v.isSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableInt64) IsSet() bool {
|
|
||||||
return v.isSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableInt64) Unset() {
|
|
||||||
v.value = nil
|
|
||||||
v.isSet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullableInt64(val *int64) *NullableInt64 {
|
|
||||||
return &NullableInt64{value: val, isSet: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableInt64) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableInt64) UnmarshalJSON(src []byte) error {
|
|
||||||
v.isSet = true
|
|
||||||
return json.Unmarshal(src, &v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullableFloat32 struct {
|
|
||||||
value *float32
|
|
||||||
isSet bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableFloat32) Get() *float32 {
|
|
||||||
return v.value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableFloat32) Set(val *float32) {
|
|
||||||
v.value = val
|
|
||||||
v.isSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableFloat32) IsSet() bool {
|
|
||||||
return v.isSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableFloat32) Unset() {
|
|
||||||
v.value = nil
|
|
||||||
v.isSet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullableFloat32(val *float32) *NullableFloat32 {
|
|
||||||
return &NullableFloat32{value: val, isSet: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableFloat32) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableFloat32) UnmarshalJSON(src []byte) error {
|
|
||||||
v.isSet = true
|
|
||||||
return json.Unmarshal(src, &v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullableFloat64 struct {
|
|
||||||
value *float64
|
|
||||||
isSet bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableFloat64) Get() *float64 {
|
|
||||||
return v.value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableFloat64) Set(val *float64) {
|
|
||||||
v.value = val
|
|
||||||
v.isSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableFloat64) IsSet() bool {
|
|
||||||
return v.isSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableFloat64) Unset() {
|
|
||||||
v.value = nil
|
|
||||||
v.isSet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullableFloat64(val *float64) *NullableFloat64 {
|
|
||||||
return &NullableFloat64{value: val, isSet: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableFloat64) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableFloat64) UnmarshalJSON(src []byte) error {
|
|
||||||
v.isSet = true
|
|
||||||
return json.Unmarshal(src, &v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullableString struct {
|
|
||||||
value *string
|
|
||||||
isSet bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableString) Get() *string {
|
|
||||||
return v.value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableString) Set(val *string) {
|
|
||||||
v.value = val
|
|
||||||
v.isSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableString) IsSet() bool {
|
|
||||||
return v.isSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableString) Unset() {
|
|
||||||
v.value = nil
|
|
||||||
v.isSet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullableString(val *string) *NullableString {
|
|
||||||
return &NullableString{value: val, isSet: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableString) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableString) UnmarshalJSON(src []byte) error {
|
|
||||||
v.isSet = true
|
|
||||||
return json.Unmarshal(src, &v.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullableTime struct {
|
|
||||||
value *time.Time
|
|
||||||
isSet bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableTime) Get() *time.Time {
|
|
||||||
return v.value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableTime) Set(val *time.Time) {
|
|
||||||
v.value = val
|
|
||||||
v.isSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableTime) IsSet() bool {
|
|
||||||
return v.isSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableTime) Unset() {
|
|
||||||
v.value = nil
|
|
||||||
v.isSet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullableTime(val *time.Time) *NullableTime {
|
|
||||||
return &NullableTime{value: val, isSet: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v NullableTime) MarshalJSON() ([]byte, error) {
|
|
||||||
return v.value.MarshalJSON()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *NullableTime) UnmarshalJSON(src []byte) error {
|
|
||||||
v.isSet = true
|
|
||||||
return json.Unmarshal(src, &v.value)
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user