diff --git a/raml/introduction/0.8/api.raml b/raml/introduction/0.8/api.raml new file mode 100644 index 0000000000..29f769ae16 --- /dev/null +++ b/raml/introduction/0.8/api.raml @@ -0,0 +1,102 @@ +#%RAML 0.8 +title: Baeldung Foo REST Services API +version: v1 +protocols: [ HTTPS ] +baseUri: http://rest-api.baeldung.com/api/{version} +mediaType: application/json +securitySchemes: + - basicAuth: + description: Each request must contain the headers necessary for + basic authentication + type: Basic Authentication + describedBy: + headers: + Authorization: + description: Used to send the Base64 encoded "username:password" + credentials + type: string + responses: + 401: + description: | + Unauthorized. Either the provided username and password + combination is invalid, or the user is not allowed to access + the content provided by the requested URL. + +schemas: + - foo: !include foo.json + - foos: !include foos.json + - error: !include error.json + +/foos: + get: + description: List all Foos matching query criteria, if provided; + otherwise list all Foos + queryParameters: + name: + type: string + required: false + ownerName: + type: string + required: false + responses: + 200: + body: + application/json: + schema: foos + example: !include foos-example.json + post: + description: Create a new Foo + body: + application/json: + schema: foo + example: foo-example.json + responses: + 201: + body: + application/json: + schema: foo + example: foo-example.json + /{id}: + get: + description: Get a Foo by id + responses: + 200: + body: + application/json: + schema: foo + 404: + body: + application/json: + schema: error + put: + description: Update a Foo by id + body: + application/json: + schema: foo + example: foo-example.json + responses: + 200: + body: + application/json: + schema: foo + 404: + body: + application/json: + schema: error + delete: + description: Delete a Foo by id + responses: + 204: + 404: + body: + application/json: + schema: error + /name/{name}: + get: + description: List all Foos with a certain name + responses: + 200: + body: + application/json: + schema: foos + example: !include foos-example.json \ No newline at end of file diff --git a/raml/introduction/0.8/error-example.json b/raml/introduction/0.8/error-example.json new file mode 100644 index 0000000000..dca56da7c2 --- /dev/null +++ b/raml/introduction/0.8/error-example.json @@ -0,0 +1,4 @@ +{ + "message" : "Not found", + "code" : 1001 +} \ No newline at end of file diff --git a/raml/introduction/0.8/error.json b/raml/introduction/0.8/error.json new file mode 100644 index 0000000000..f6e25b51d2 --- /dev/null +++ b/raml/introduction/0.8/error.json @@ -0,0 +1,12 @@ +{ "$schema": "http://json-schema.org/schema", + "type": "object", + "description": "Error message", + "properties": { + "message": { "type": "string" }, + "code": { "type": integer } + }, + "required": [ + "message", + "code" + ] +} \ No newline at end of file diff --git a/raml/introduction/0.8/foo-example.json b/raml/introduction/0.8/foo-example.json new file mode 100644 index 0000000000..1b1b8c891e --- /dev/null +++ b/raml/introduction/0.8/foo-example.json @@ -0,0 +1,4 @@ +{ + "id" : 1, + "name" : "First Foo" +} \ No newline at end of file diff --git a/raml/introduction/0.8/foo.json b/raml/introduction/0.8/foo.json new file mode 100644 index 0000000000..c024a8c2d3 --- /dev/null +++ b/raml/introduction/0.8/foo.json @@ -0,0 +1,13 @@ +{ "$schema": "http://json-schema.org/schema", + "type": "object", + "description": "Foo details", + "properties": { + "id": { "type": integer }, + "name": { "type": "string" }, + "ownerName": { "type": "string" } + }, + "required": [ + "id", + "name" + ] +} \ No newline at end of file diff --git a/raml/introduction/0.8/foos-example.json b/raml/introduction/0.8/foos-example.json new file mode 100644 index 0000000000..fe9c89d36a --- /dev/null +++ b/raml/introduction/0.8/foos-example.json @@ -0,0 +1,10 @@ +[ + { + "id" : 1, + "name" : "First Foo" + }, + { + "id" : 2, + "name" : "Second Foo" + } +] \ No newline at end of file diff --git a/raml/introduction/0.8/foos.json b/raml/introduction/0.8/foos.json new file mode 100644 index 0000000000..931deab029 --- /dev/null +++ b/raml/introduction/0.8/foos.json @@ -0,0 +1,5 @@ +{ "$schema": "http://json-schema.org/schema", + "type": "array", + "items": { "$ref": "foo" } + "description": "Collection of Foos" +} \ No newline at end of file diff --git a/raml/introduction/1.0/api.raml b/raml/introduction/1.0/api.raml new file mode 100644 index 0000000000..a54d4f11db --- /dev/null +++ b/raml/introduction/1.0/api.raml @@ -0,0 +1,101 @@ +#%RAML 1.0 +title: Baeldung Foo REST Services API +version: v1 +protocols: [ HTTPS ] +baseUri: http://rest-api.baeldung.com/api/{version} +mediaType: application/json +securedBy: basicAuth +securitySchemes: + - basicAuth: + description: Each request must contain the headers necessary for + basic authentication + type: Basic Authentication + describedBy: + headers: + Authorization: + description: Used to send the Base64 encoded "username:password" + credentials + type: string + responses: + 401: + description: | + Unauthorized. Either the provided username and password + combination is invalid, or the user is not allowed to access + the content provided by the requested URL. +types: + Foo: !include types/Foo.raml + Error: !include types/Error.raml +/foos: + get: + description: List all Foos matching query criteria, if provided; + otherwise list all Foos + queryParameters: + name?: string + ownerName?: string + responses: + 200: + body: + application/json: + type: Foo[] + example: !include examples/Foos.json + post: + description: Create a new Foo + body: + application/json: + type: Foo + example: !include examples/Foo.json + responses: + 201: + body: + application/json: + type: Foo + example: !include examples/Foo.json + /{id}: + get: + description: Get a Foo by id + responses: + 200: + body: + application/json: + type: Foo + example: !include examples/Foo.json + 404: + body: + application/json: + type: Error + example: !include examples/Error.json + put: + description: Update a Foo by id + body: + application/json: + type: Foo + example: !include examples/Foo.json + responses: + 200: + body: + application/json: + type: Foo + example: !include examples/Foo.json + 404: + body: + application/json: + type: Error + example: !include examples/Error.json + delete: + description: Delete a Foo by id + responses: + 204: + 404: + body: + application/json: + type: Error + example: !include examples/Error.json + /name/{name}: + get: + description: List all Foos with a certain name + responses: + 200: + body: + application/json: + type: Foo[] + example: !include examples/Foos.json \ No newline at end of file diff --git a/raml/introduction/1.0/examples/Error.json b/raml/introduction/1.0/examples/Error.json new file mode 100644 index 0000000000..dca56da7c2 --- /dev/null +++ b/raml/introduction/1.0/examples/Error.json @@ -0,0 +1,4 @@ +{ + "message" : "Not found", + "code" : 1001 +} \ No newline at end of file diff --git a/raml/introduction/1.0/examples/Foo.json b/raml/introduction/1.0/examples/Foo.json new file mode 100644 index 0000000000..1b1b8c891e --- /dev/null +++ b/raml/introduction/1.0/examples/Foo.json @@ -0,0 +1,4 @@ +{ + "id" : 1, + "name" : "First Foo" +} \ No newline at end of file diff --git a/raml/introduction/1.0/examples/Foos.json b/raml/introduction/1.0/examples/Foos.json new file mode 100644 index 0000000000..fe9c89d36a --- /dev/null +++ b/raml/introduction/1.0/examples/Foos.json @@ -0,0 +1,10 @@ +[ + { + "id" : 1, + "name" : "First Foo" + }, + { + "id" : 2, + "name" : "Second Foo" + } +] \ No newline at end of file diff --git a/raml/introduction/1.0/types/Error.raml b/raml/introduction/1.0/types/Error.raml new file mode 100644 index 0000000000..8d54b5f181 --- /dev/null +++ b/raml/introduction/1.0/types/Error.raml @@ -0,0 +1,5 @@ +#%RAML 1.0 DataType + + properties: + code: integer + message: string diff --git a/raml/introduction/1.0/types/Foo.raml b/raml/introduction/1.0/types/Foo.raml new file mode 100644 index 0000000000..1702865e05 --- /dev/null +++ b/raml/introduction/1.0/types/Foo.raml @@ -0,0 +1,6 @@ +#%RAML 1.0 DataType + +properties: + id: integer + name: string + ownerName?: string diff --git a/raml/resource-types-and-traits/api-before-resource-types-and-traits.raml b/raml/resource-types-and-traits/api-before-resource-types-and-traits.raml new file mode 100644 index 0000000000..652a3d10f7 --- /dev/null +++ b/raml/resource-types-and-traits/api-before-resource-types-and-traits.raml @@ -0,0 +1,177 @@ +#%RAML 1.0 +title: Baeldung Foo REST Services API +version: v1 +protocols: [ HTTPS ] +baseUri: http://rest-api.baeldung.com/api/{version} +mediaType: application/json +securedBy: basicAuth +securitySchemes: + - basicAuth: + description: Each request must contain the headers necessary for + basic authentication + type: Basic Authentication + describedBy: + headers: + Authorization: + description: Used to send the Base64 encoded "username:password" + credentials + type: string + responses: + 401: + description: | + Unauthorized. Either the provided username and password + combination is invalid, or the user is not allowed to access + the content provided by the requested URL. +types: + Foo: !include types/Foo.raml + Bar: !include types/Bar.raml + Error: !include types/Error.raml +traits: +/foos: + get: + description: List all foos matching query criteria, if provided; + otherwise list all foos + queryParameters: + name?: string + ownerName?: string + responses: + 200: + body: + application/json: + type: Foo[] + example: !include examples/Foos.json + post: + description: Create a new foo + body: + application/json: + type: Foo + example: !include examples/Foo.json + responses: + 201: + body: + application/json: + type: Foo + example: !include examples/Foo.json + /{fooId}: + get: + description: Get a foo by fooId + responses: + 200: + body: + application/json: + type: Foo + example: !include examples/Foo.json + 404: + body: + application/json: + type: Error + example: !include examples/Error.json + put: + description: Update a foo by fooId + body: + application/json: + type: Foo + example: !include examples/Foo.json + responses: + 200: + body: + application/json: + type: Foo + example: !include examples/Foo.json + 404: + body: + application/json: + type: Error + example: !include examples/Error.json + delete: + description: Delete a foo by fooId + responses: + 204: + 404: + body: + application/json: + type: Error + example: !include examples/Error.json + /name/{name}: + get: + description: List all foos with a certain name + responses: + 200: + body: + application/json: + type: Foo[] + example: !include examples/Foos.json +/bars: + get: + description: List all bars matching query criteria, if provided; + otherwise list all bars + queryParameters: + name?: string + ownerName?: string + responses: + 200: + body: + application/json: + type: Bar[] + example: !include examples/Bars.json + post: + description: Create a new bar + body: + application/json: + type: Bar + example: !include examples/Bar.json + responses: + 201: + body: + application/json: + type: Bar + example: !include examples/Bar.json + /{barId}: + get: + description: Get a bar by barId + responses: + 200: + body: + application/json: + type: Bar + example: !include examples/Bar.json + 404: + body: + application/json: + type: Error + example: !include examples/Error.json + put: + description: Update a bar by barId + body: + application/json: + type: Bar + example: !include examples/Bar.json + responses: + 200: + body: + application/json: + type: Bar + example: !include examples/Bar.json + 404: + body: + application/json: + type: Error + example: !include examples/Error.json + delete: + description: Delete a bar by barId + responses: + 204: + 404: + body: + application/json: + type: Error + example: !include examples/Error.json + /fooId/{fooId}: + get: + description: Get all bars for the matching fooId + responses: + 200: + body: + application/json: + type: Bar[] + example: !include examples/Bars.json \ No newline at end of file diff --git a/raml/resource-types-and-traits/api.raml b/raml/resource-types-and-traits/api.raml new file mode 100644 index 0000000000..c07f0cba28 --- /dev/null +++ b/raml/resource-types-and-traits/api.raml @@ -0,0 +1,108 @@ +#%RAML 1.0 +title: Baeldung Foo REST Services API +version: v1 +protocols: [ HTTPS ] +baseUri: http://rest-api.baeldung.com/api/{version} +mediaType: application/json +securedBy: basicAuth +securitySchemes: + - basicAuth: + description: Each request must contain the headers necessary for + basic authentication + type: Basic Authentication + describedBy: + headers: + Authorization: + description: | + Used to send the Base64 encoded "username:password" + credentials + type: string + responses: + 401: + description: | + Unauthorized. Either the provided username and password + combination is invalid, or the user is not allowed to + access the content provided by the requested URL. +types: + Foo: !include types/Foo.raml + Bar: !include types/Bar.raml + Error: !include types/Error.raml +resourceTypes: + - collection: + usage: Use this resourceType to represent a collection of items + description: A collection of <> + get: + description: | + Get all <>, + optionally filtered + is: [ hasResponseCollection ] + post: + description: | + Create a new <> + is: [ hasRequestItem ] + - item: + usage: Use this resourceType to represent any single item + description: A single <> + get: + description: Get a <> by <> + is: [ hasResponseItem, hasNotFound ] + put: + description: Update a <> by <> + is: [ hasRequestItem, hasResponseItem, hasNotFound ] + delete: + description: Delete a <> by <> + is: [ hasNotFound ] + responses: + 204: +traits: + - hasRequestItem: + body: + application/json: + type: <> + - hasResponseItem: + responses: + 200: + body: + application/json: + type: <> + example: !include examples/<>.json + - hasResponseCollection: + responses: + 200: + body: + application/json: + type: <>[] + example: !include examples/<>.json + - hasNotFound: + responses: + 404: + body: + application/json: + type: Error + example: !include examples/Error.json +/foos: + type: collection + typeName: Foo + get: + queryParameters: + name?: string + ownerName?: string + /{fooId}: + type: item + typeName: Foo + /name/{name}: + get: + description: List all foos with a certain name + typeName: Foo + is: [ hasResponseCollection ] +/bars: + type: collection + typeName: Bar + /{barId}: + type: item + typeName: Bar + /fooId/{fooId}: + get: + description: Get all bars for the matching fooId + typeName: Bar + is: [ hasResponseCollection ] \ No newline at end of file diff --git a/raml/resource-types-and-traits/examples/Bar.json b/raml/resource-types-and-traits/examples/Bar.json new file mode 100644 index 0000000000..0ee1b34edb --- /dev/null +++ b/raml/resource-types-and-traits/examples/Bar.json @@ -0,0 +1,6 @@ +{ + "id" : 1, + "name" : "First Bar", + "city" : "Austin", + "fooId" : 2 +} \ No newline at end of file diff --git a/raml/resource-types-and-traits/examples/Bars.json b/raml/resource-types-and-traits/examples/Bars.json new file mode 100644 index 0000000000..89ea875432 --- /dev/null +++ b/raml/resource-types-and-traits/examples/Bars.json @@ -0,0 +1,19 @@ +[ + { + "id" : 1, + "name" : "First Bar", + "city" : "Austin", + "fooId" : 2 + }, + { + "id" : 2, + "name" : "Second Bar", + "city" : "Dallas", + "fooId" : 1 + }, + { + "id" : 3, + "name" : "Third Bar", + "fooId" : 2 + } +] \ No newline at end of file diff --git a/raml/resource-types-and-traits/examples/Error.json b/raml/resource-types-and-traits/examples/Error.json new file mode 100644 index 0000000000..dca56da7c2 --- /dev/null +++ b/raml/resource-types-and-traits/examples/Error.json @@ -0,0 +1,4 @@ +{ + "message" : "Not found", + "code" : 1001 +} \ No newline at end of file diff --git a/raml/resource-types-and-traits/examples/Foo.json b/raml/resource-types-and-traits/examples/Foo.json new file mode 100644 index 0000000000..1b1b8c891e --- /dev/null +++ b/raml/resource-types-and-traits/examples/Foo.json @@ -0,0 +1,4 @@ +{ + "id" : 1, + "name" : "First Foo" +} \ No newline at end of file diff --git a/raml/resource-types-and-traits/examples/Foos.json b/raml/resource-types-and-traits/examples/Foos.json new file mode 100644 index 0000000000..74f64689f0 --- /dev/null +++ b/raml/resource-types-and-traits/examples/Foos.json @@ -0,0 +1,16 @@ +[ + { + "id" : 1, + "name" : "First Foo", + "ownerName" : "Jack Robinson" + }, + { + "id" : 2, + "name" : "Second Foo" + }, + { + "id" : 3, + "name" : "Third Foo", + "ownerName" : "Chuck Norris" + } +] \ No newline at end of file diff --git a/raml/resource-types-and-traits/types/Bar.raml b/raml/resource-types-and-traits/types/Bar.raml new file mode 100644 index 0000000000..92255a75fe --- /dev/null +++ b/raml/resource-types-and-traits/types/Bar.raml @@ -0,0 +1,7 @@ +#%RAML 1.0 DataType + +properties: + id: integer + name: string + city?: string + fooId: integer diff --git a/raml/resource-types-and-traits/types/Error.raml b/raml/resource-types-and-traits/types/Error.raml new file mode 100644 index 0000000000..8d54b5f181 --- /dev/null +++ b/raml/resource-types-and-traits/types/Error.raml @@ -0,0 +1,5 @@ +#%RAML 1.0 DataType + + properties: + code: integer + message: string diff --git a/raml/resource-types-and-traits/types/Foo.raml b/raml/resource-types-and-traits/types/Foo.raml new file mode 100644 index 0000000000..1702865e05 --- /dev/null +++ b/raml/resource-types-and-traits/types/Foo.raml @@ -0,0 +1,6 @@ +#%RAML 1.0 DataType + +properties: + id: integer + name: string + ownerName?: string