mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-02 21:50:55 +00:00
updated to 1.2 spec
This commit is contained in:
parent
73a70a65ff
commit
feb5a2ff3b
@ -6,13 +6,13 @@
|
||||
"path": "/pet",
|
||||
"description": "Operations about pets"
|
||||
},
|
||||
{
|
||||
"path": "/user",
|
||||
"description": "Operations about user"
|
||||
},
|
||||
{
|
||||
"path": "/store",
|
||||
"description": "Operations about store"
|
||||
},
|
||||
{
|
||||
"path": "/user",
|
||||
"description": "Operations about user"
|
||||
}
|
||||
],
|
||||
"authorizations": {
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"apiVersion": "1.0.0",
|
||||
"swaggerVersion": "1.2",
|
||||
"basePath": "http://petstore.swagger.wordnik.com/api",
|
||||
"basePath": "http://localhost:8002/api",
|
||||
"resourcePath": "/pet",
|
||||
"produces": [
|
||||
"application/json",
|
||||
@ -32,7 +32,7 @@
|
||||
"description": "ID of pet that needs to be fetched",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "string",
|
||||
"type": "string",
|
||||
"paramType": "path"
|
||||
}
|
||||
],
|
||||
@ -59,7 +59,7 @@
|
||||
"description": "Pet id to delete",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "string",
|
||||
"type": "string",
|
||||
"paramType": "path"
|
||||
}
|
||||
],
|
||||
@ -75,29 +75,6 @@
|
||||
{
|
||||
"path": "/pet",
|
||||
"operations": [
|
||||
{
|
||||
"method": "POST",
|
||||
"summary": "Add a new pet to the store",
|
||||
"notes": "",
|
||||
"responseClass": "void",
|
||||
"nickname": "addPet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"description": "Pet object that needs to be added to the store",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "Pet",
|
||||
"paramType": "body"
|
||||
}
|
||||
],
|
||||
"responseMessages": [
|
||||
{
|
||||
"code": 405,
|
||||
"message": "Invalid input"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "PUT",
|
||||
"summary": "Update an existing pet",
|
||||
@ -110,7 +87,7 @@
|
||||
"description": "Pet object that needs to be updated in the store",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "Pet",
|
||||
"type": "Pet",
|
||||
"paramType": "body"
|
||||
}
|
||||
],
|
||||
@ -128,6 +105,29 @@
|
||||
"message": "Validation exception"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"summary": "Add a new pet to the store",
|
||||
"notes": "",
|
||||
"responseClass": "void",
|
||||
"nickname": "addPet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"description": "Pet object that needs to be added to the store",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"type": "Pet",
|
||||
"paramType": "body"
|
||||
}
|
||||
],
|
||||
"responseMessages": [
|
||||
{
|
||||
"code": 405,
|
||||
"message": "Invalid input"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -151,16 +151,13 @@
|
||||
"defaultValue": "available",
|
||||
"required": true,
|
||||
"allowMultiple": true,
|
||||
"dataType": "string",
|
||||
"allowableValues": {
|
||||
"valueType": "LIST",
|
||||
"values": [
|
||||
"available",
|
||||
"pending",
|
||||
"sold"
|
||||
]
|
||||
},
|
||||
"paramType": "query"
|
||||
"type": "string",
|
||||
"paramType": "query",
|
||||
"enum": [
|
||||
"available",
|
||||
"pending",
|
||||
"sold"
|
||||
]
|
||||
}
|
||||
],
|
||||
"responseMessages": [
|
||||
@ -191,7 +188,7 @@
|
||||
"description": "Tags to filter by",
|
||||
"required": true,
|
||||
"allowMultiple": true,
|
||||
"dataType": "string",
|
||||
"type": "string",
|
||||
"paramType": "query"
|
||||
}
|
||||
],
|
||||
@ -209,74 +206,66 @@
|
||||
"models": {
|
||||
"Tag": {
|
||||
"id": "Tag",
|
||||
"name": "Tag",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "long",
|
||||
"required": false
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Pet": {
|
||||
"id": "Pet",
|
||||
"name": "Pet",
|
||||
"description": "A pet is a person's best friend",
|
||||
"required": [
|
||||
"name",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "long",
|
||||
"required": false
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"tags": {
|
||||
"type": "List",
|
||||
"required": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "Tag"
|
||||
}
|
||||
},
|
||||
"photoUrls": {
|
||||
"type": "List",
|
||||
"required": false,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "pet status in the store",
|
||||
"allowableValues": {
|
||||
"valueType": "LIST",
|
||||
"values": [
|
||||
"available",
|
||||
"pending",
|
||||
"sold"
|
||||
]
|
||||
}
|
||||
"enum": [
|
||||
"available",
|
||||
"pending",
|
||||
"sold"
|
||||
]
|
||||
},
|
||||
"category": {
|
||||
"type": "Category",
|
||||
"required": false
|
||||
"$ref": "Category"
|
||||
},
|
||||
"photoUrls": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Category": {
|
||||
"id": "Category",
|
||||
"name": "Category",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "long",
|
||||
"required": false
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"apiVersion": "1.0.0",
|
||||
"swaggerVersion": "1.2",
|
||||
"basePath": "http://petstore.swagger.wordnik.com/api",
|
||||
"basePath": "http://localhost:8002/api",
|
||||
"resourcePath": "/store",
|
||||
"produces": [
|
||||
"application/json",
|
||||
@ -27,7 +27,7 @@
|
||||
"description": "ID of pet that needs to be fetched",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "string",
|
||||
"type": "string",
|
||||
"paramType": "path"
|
||||
}
|
||||
],
|
||||
@ -54,7 +54,7 @@
|
||||
"description": "ID of the order that needs to be deleted",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "string",
|
||||
"type": "string",
|
||||
"paramType": "path"
|
||||
}
|
||||
],
|
||||
@ -86,7 +86,7 @@
|
||||
"description": "order placed for purchasing the pet",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "Order",
|
||||
"type": "Order",
|
||||
"paramType": "body"
|
||||
}
|
||||
],
|
||||
@ -103,36 +103,31 @@
|
||||
"models": {
|
||||
"Order": {
|
||||
"id": "Order",
|
||||
"name": "Order",
|
||||
"properties": {
|
||||
"shipDate": {
|
||||
"type": "Date",
|
||||
"required": false
|
||||
},
|
||||
"quantity": {
|
||||
"type": "int",
|
||||
"required": false
|
||||
},
|
||||
"petId": {
|
||||
"type": "long",
|
||||
"required": false
|
||||
},
|
||||
"id": {
|
||||
"type": "long",
|
||||
"required": false
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Order Status",
|
||||
"allowableValues": {
|
||||
"valueType": "LIST",
|
||||
"values": [
|
||||
"placed",
|
||||
"approved",
|
||||
"delivered"
|
||||
]
|
||||
}
|
||||
"enum": [
|
||||
"placed",
|
||||
"approved",
|
||||
"delivered"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"shipDate": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"petId": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,82 +1,47 @@
|
||||
{
|
||||
"apiVersion": "1.0.0",
|
||||
"swaggerVersion": "1.2",
|
||||
"basePath": "http://petstore.swagger.wordnik.com/api",
|
||||
"basePath": "http://localhost:8002/api",
|
||||
"resourcePath": "/user",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"apis": [
|
||||
{
|
||||
"path": "/user",
|
||||
"operations": [
|
||||
{
|
||||
"method": "POST",
|
||||
"summary": "Create user",
|
||||
"notes": "This can only be done by the logged in user.",
|
||||
"responseClass": "void",
|
||||
"nickname": "createUser",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"description": "Created user object",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "User",
|
||||
"paramType": "body"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/user/createWithArray",
|
||||
"operations": [
|
||||
{
|
||||
"method": "POST",
|
||||
"summary": "Creates list of users with given input array",
|
||||
"notes": "",
|
||||
"responseClass": "void",
|
||||
"nickname": "createUsersWithArrayInput",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"description": "List of user object",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "Array[User]",
|
||||
"paramType": "body"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/user/createWithList",
|
||||
"operations": [
|
||||
{
|
||||
"method": "POST",
|
||||
"summary": "Creates list of users with given list input",
|
||||
"notes": "",
|
||||
"responseClass": "void",
|
||||
"nickname": "createUsersWithListInput",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"description": "List of user object",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "List[User]",
|
||||
"paramType": "body"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/user/{username}",
|
||||
"operations": [
|
||||
{
|
||||
"method": "GET",
|
||||
"summary": "Get user by user name",
|
||||
"notes": "",
|
||||
"responseClass": "User",
|
||||
"nickname": "getUserByName",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"description": "The name that needs to be fetched. Use user1 for testing.",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"type": "string",
|
||||
"paramType": "path"
|
||||
}
|
||||
],
|
||||
"responseMessages": [
|
||||
{
|
||||
"code": 400,
|
||||
"message": "Invalid username supplied"
|
||||
},
|
||||
{
|
||||
"code": 404,
|
||||
"message": "User not found"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "PUT",
|
||||
"summary": "Updated user",
|
||||
@ -89,7 +54,7 @@
|
||||
"description": "name that need to be deleted",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "string",
|
||||
"type": "string",
|
||||
"paramType": "path"
|
||||
},
|
||||
{
|
||||
@ -97,7 +62,7 @@
|
||||
"description": "Updated user object",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "User",
|
||||
"type": "User",
|
||||
"paramType": "body"
|
||||
}
|
||||
],
|
||||
@ -124,38 +89,7 @@
|
||||
"description": "The name that needs to be deleted",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "string",
|
||||
"paramType": "path"
|
||||
}
|
||||
],
|
||||
"responseMessages": [
|
||||
{
|
||||
"code": 400,
|
||||
"message": "Invalid username supplied"
|
||||
},
|
||||
{
|
||||
"code": 404,
|
||||
"message": "User not found"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"summary": "Get user by user name",
|
||||
"notes": "",
|
||||
"responseClass": "User",
|
||||
"nickname": "getUserByName",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"description": "The name that needs to be fetched. Use user1 for testing.",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "string",
|
||||
"type": "string",
|
||||
"paramType": "path"
|
||||
}
|
||||
],
|
||||
@ -190,7 +124,7 @@
|
||||
"description": "The user name for login",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "string",
|
||||
"type": "string",
|
||||
"paramType": "query"
|
||||
},
|
||||
{
|
||||
@ -198,7 +132,7 @@
|
||||
"description": "The password for login in clear text",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"dataType": "string",
|
||||
"type": "string",
|
||||
"paramType": "query"
|
||||
}
|
||||
],
|
||||
@ -226,53 +160,115 @@
|
||||
"parameters": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/user",
|
||||
"operations": [
|
||||
{
|
||||
"method": "POST",
|
||||
"summary": "Create user",
|
||||
"notes": "This can only be done by the logged in user.",
|
||||
"responseClass": "void",
|
||||
"nickname": "createUser",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"description": "Created user object",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"type": "User",
|
||||
"paramType": "body"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/user/createWithArray",
|
||||
"operations": [
|
||||
{
|
||||
"method": "POST",
|
||||
"summary": "Creates list of users with given input array",
|
||||
"notes": "",
|
||||
"responseClass": "void",
|
||||
"nickname": "createUsersWithArrayInput",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"description": "List of user object",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "User"
|
||||
},
|
||||
"paramType": "body"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/user/createWithList",
|
||||
"operations": [
|
||||
{
|
||||
"method": "POST",
|
||||
"summary": "Creates list of users with given list input",
|
||||
"notes": "",
|
||||
"responseClass": "void",
|
||||
"nickname": "createUsersWithListInput",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"description": "List of user object",
|
||||
"required": true,
|
||||
"allowMultiple": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "User"
|
||||
},
|
||||
"paramType": "body"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"models": {
|
||||
"User": {
|
||||
"id": "User",
|
||||
"name": "User",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"userStatus": {
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"description": "User Status",
|
||||
"allowableValues": {
|
||||
"valueType": "LIST",
|
||||
"values": [
|
||||
"1-registered",
|
||||
"2-active",
|
||||
"3-closed"
|
||||
]
|
||||
}
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"firstName": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"id": {
|
||||
"type": "long",
|
||||
"required": false
|
||||
},
|
||||
"phone": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"userStatus": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"description": "User Status",
|
||||
"enum": [
|
||||
"1-registered",
|
||||
"2-active",
|
||||
"3-closed"
|
||||
]
|
||||
},
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class BasicGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
it should "get operations" in {
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json")
|
||||
|
||||
val subDocs = ApiExtractor.fetchApiListings("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val subDocs = ApiExtractor.fetchApiListings(resourceListing.swaggerVersion, "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val allModels = new HashMap[String, Model]
|
||||
|
||||
implicit val basePath = "http://localhost:8080/api"
|
||||
@ -74,7 +74,7 @@ class BasicGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
it should "verify ops are grouped by path correctly" in {
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json")
|
||||
val subDocs = ApiExtractor.fetchApiListings("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val subDocs = ApiExtractor.fetchApiListings(resourceListing.swaggerVersion, "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val allModels = new HashMap[String, Model]()
|
||||
|
||||
implicit val basePath = "http://localhost:8080/api"
|
||||
|
@ -187,7 +187,7 @@ class BasicObjcGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
it should "verify an api map with path param" in {
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json", None)
|
||||
val apis = ApiExtractor.extractApiOperations("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val apis = ApiExtractor.extractApiOperations("1.1", "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val codegen = new Codegen(config)
|
||||
val petApi = apis.filter(doc => doc.resourcePath == "/pet").head
|
||||
|
||||
@ -216,7 +216,7 @@ class BasicObjcGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
it should "verify an api map with query params" in {
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json", None)
|
||||
val apis = ApiExtractor.extractApiOperations("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val apis = ApiExtractor.extractApiOperations("1.1", "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val codegen = new Codegen(config)
|
||||
val petApi = apis.filter(doc => doc.resourcePath == "/pet").head
|
||||
|
||||
@ -253,7 +253,7 @@ class BasicObjcGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
val codegen = new Codegen(config)
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json", None)
|
||||
|
||||
val apis = ApiExtractor.extractApiOperations("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val apis = ApiExtractor.extractApiOperations("1.1", "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val petApi = apis.filter(doc => doc.resourcePath == "/pet").head
|
||||
|
||||
val endpoint = petApi.apis.filter(api => api.path == "/pet.{format}/findByTags").head
|
||||
|
@ -187,7 +187,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
it should "verify an api map with query params" in {
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json", None)
|
||||
val apis = ApiExtractor.extractApiOperations("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val apis = ApiExtractor.extractApiOperations(resourceListing.swaggerVersion, "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val codegen = new Codegen(config)
|
||||
val petApi = apis.filter(doc => doc.resourcePath == "/pet").head
|
||||
|
||||
@ -222,7 +222,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
it should "verify an api map with query params with default values" in {
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json", None)
|
||||
val apis = ApiExtractor.extractApiOperations("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val apis = ApiExtractor.extractApiOperations(resourceListing.swaggerVersion, "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val codegen = new Codegen(config)
|
||||
val petApi = apis.filter(doc => doc.resourcePath == "/pet").head
|
||||
|
||||
@ -263,7 +263,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
val codegen = new Codegen(config)
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json", None)
|
||||
|
||||
val apis = ApiExtractor.extractApiOperations("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val apis = ApiExtractor.extractApiOperations(resourceListing.swaggerVersion, "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val petApi = apis.filter(doc => doc.resourcePath == "/pet").head
|
||||
|
||||
val endpoint = petApi.apis.filter(api => api.path == "/pet.{format}/findByTags").head
|
||||
|
@ -23,7 +23,7 @@ class CoreUtilsTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
it should "verify models are extracted" in {
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json")
|
||||
val apis = ApiExtractor.extractApiOperations("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val apis = ApiExtractor.extractApiOperations(resourceListing.swaggerVersion, "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
|
||||
val cu = CoreUtils.extractAllModels(apis)
|
||||
cu.size should be (5)
|
||||
@ -33,7 +33,7 @@ class CoreUtilsTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
it should "verify operation names" in {
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json")
|
||||
val apis = ApiExtractor.extractApiOperations("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val apis = ApiExtractor.extractApiOperations(resourceListing.swaggerVersion, "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
|
||||
val petApi = apis.filter(api => api.resourcePath == "/pet").head
|
||||
val eps = petApi.apis.map(api => (api.path, api)).toMap
|
||||
@ -58,7 +58,7 @@ class CoreUtilsTest extends FlatSpec with ShouldMatchers {
|
||||
}
|
||||
|
||||
object CoreUtilsTest {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
def sampleApis1 = {
|
||||
parse("""
|
||||
|
@ -16,7 +16,7 @@ import scala.collection.mutable.LinkedHashMap
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ResourceListingValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "fail resource listing without base path" in {
|
||||
SwaggerSerializers.validationMessages.clear
|
||||
@ -71,7 +71,7 @@ class ResourceListingValidationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ApiListingReferenceValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
|
||||
it should "deserialize an ApiListingReference" in {
|
||||
@ -98,7 +98,7 @@ class ApiListingReferenceValidationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ApiDescriptionValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "fail to deserialize an ApiDescription with path, method, return type" in {
|
||||
SwaggerSerializers.validationMessages.clear
|
||||
@ -140,7 +140,7 @@ class ApiDescriptionValidationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class OperationValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "fail to deserialize an Operation with missing param type" in {
|
||||
SwaggerSerializers.validationMessages.clear
|
||||
@ -196,7 +196,7 @@ class OperationValidationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ResponseMessageValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize an ResponseMessage" in {
|
||||
val jsonString = """
|
||||
@ -223,7 +223,7 @@ class ResponseMessageValidationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ParameterValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize another param" in {
|
||||
val jsonString = """
|
||||
@ -294,7 +294,7 @@ class ParameterValidationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ModelValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize a model" in {
|
||||
val jsonString = """
|
||||
@ -371,7 +371,7 @@ class ModelValidationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ModelRefValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize a model ref" in {
|
||||
val jsonString = """
|
||||
@ -398,7 +398,7 @@ class ModelRefValidationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ModelPropertyValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize a model property with allowable values and ref" in {
|
||||
val jsonString = """
|
||||
@ -502,7 +502,7 @@ class ModelPropertyValidationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class AllowableValuesValidationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize allowable value list" in {
|
||||
val allowableValuesListString = """
|
||||
|
@ -16,7 +16,7 @@ import scala.collection.mutable.LinkedHashMap
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ResourceListingSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize an ResourceListing with no apis" in {
|
||||
val jsonString = """
|
||||
@ -80,7 +80,7 @@ class ResourceListingSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ApiListingReferenceSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize an ApiListingReference" in {
|
||||
val jsonString = """
|
||||
@ -107,7 +107,7 @@ class ApiListingReferenceSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ApiDescriptionSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize an ApiDescription with no ops" in {
|
||||
val jsonString = """
|
||||
@ -216,7 +216,7 @@ class ApiDescriptionSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class OperationSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize an Operation" in {
|
||||
val jsonString = """
|
||||
@ -287,20 +287,20 @@ class OperationSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ErrorResponseSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize an ResponseResponse" in {
|
||||
val jsonString = """
|
||||
{
|
||||
"code":101,
|
||||
"message":"the message"
|
||||
"reason":"the reason"
|
||||
}
|
||||
"""
|
||||
val json = parse(jsonString)
|
||||
json.extract[ResponseMessage] match {
|
||||
case p: ResponseMessage => {
|
||||
p.code should be (101)
|
||||
p.message should be ("the message")
|
||||
p.message should be ("the reason")
|
||||
}
|
||||
case _ => fail("wrong type returned, should be ResponseMessage")
|
||||
}
|
||||
@ -314,7 +314,7 @@ class ErrorResponseSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ParameterSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize another param" in {
|
||||
val jsonString = """
|
||||
@ -385,7 +385,7 @@ class ParameterSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ModelSerializationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize a model" in {
|
||||
val jsonString = """
|
||||
@ -462,7 +462,7 @@ class ModelSerializationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ModelRefSerializationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize a model ref" in {
|
||||
val jsonString = """
|
||||
@ -489,7 +489,7 @@ class ModelRefSerializationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ModelPropertySerializationTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize a model property with allowable values and ref" in {
|
||||
val jsonString = """
|
||||
@ -593,7 +593,7 @@ class ModelPropertySerializationTest extends FlatSpec with ShouldMatchers {
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class AllowableValuesSerializersTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
it should "deserialize allowable value list" in {
|
||||
val allowableValuesListString = """
|
||||
|
@ -29,7 +29,7 @@ import scala.io._
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class SwaggerModelTest extends FlatSpec with ShouldMatchers {
|
||||
implicit val formats = SwaggerSerializers.formats
|
||||
implicit val formats = SwaggerSerializers.formats("1.1")
|
||||
|
||||
behavior of "Swagger Model"
|
||||
|
||||
|
@ -41,7 +41,7 @@ class ApiExtractorTest extends FlatSpec with ShouldMatchers {
|
||||
behavior of "ApiExtractor"
|
||||
it should "verify the deserialization of the store api" in {
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json")
|
||||
val docs = ApiExtractor.extractApiOperations("src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
val docs = ApiExtractor.extractApiOperations(resourceListing.swaggerVersion, "src/test/resources/petstore-1.1", resourceListing.apis)
|
||||
|
||||
val m = docs.map(t => (t.resourcePath, t)).toMap
|
||||
val storeApi = m("/store")
|
||||
|
Loading…
x
Reference in New Issue
Block a user