JAVA-14176 Rename raml to raml-modules (#12673)
* JAVA-14176 Rename raml to raml-modules * JAVA-14176 Remove failing module * JAVA-14176 Revert commenting spring-cloud-openfeign-2 module
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
## RAML
|
||||
|
||||
This module contains articles about the RESTful API Modeling Language (RAML).
|
||||
@@ -0,0 +1,7 @@
|
||||
=========
|
||||
|
||||
## Define Custom RAML
|
||||
|
||||
|
||||
### Relevant Articles:
|
||||
- [Define Custom RAML Properties Using Annotations](http://www.baeldung.com/raml-custom-properties-with-annotations)
|
||||
@@ -0,0 +1,126 @@
|
||||
#%RAML 1.0
|
||||
title: API for REST Services used in the RAML tutorials on Baeldung.com
|
||||
documentation:
|
||||
- title: Overview
|
||||
content: |
|
||||
This document defines the interface for the REST services
|
||||
used in the popular RAML Tutorial series at Baeldung.com.
|
||||
- title: Disclaimer
|
||||
content: |
|
||||
All names used in this definition are purely fictional.
|
||||
Any similarities between the names used in this tutorial and those of real persons, whether living or dead, are merely coincidental.
|
||||
- title: Copyright
|
||||
content: Copyright 2016 by Baeldung.com. All rights reserved.
|
||||
uses:
|
||||
mySecuritySchemes: !include libraries/securitySchemes.raml
|
||||
myDataTypes: !include libraries/dataTypes.raml
|
||||
myTraits: !include libraries/traits.raml
|
||||
myResourceTypes: !include libraries/resourceTypes.raml
|
||||
version: v1
|
||||
protocols: [ HTTPS ]
|
||||
baseUri: http://rest-api.baeldung.com/api/{version}
|
||||
mediaType: application/json
|
||||
securedBy: [ mySecuritySchemes.basicAuth ]
|
||||
annotationTypes:
|
||||
testCase:
|
||||
allowedTargets: [ Method ]
|
||||
allowMultiple: true
|
||||
usage: |
|
||||
Use this annotation to declare a test case
|
||||
within a testSuite declaration.
|
||||
You may apply this annotation multiple times
|
||||
within the target testSuite.
|
||||
properties:
|
||||
scenario: string
|
||||
setupScript?: string[]
|
||||
testScript: string[]
|
||||
expectedOutput?: string
|
||||
cleanupScript?: string[]
|
||||
/foos:
|
||||
type: myResourceTypes.collection
|
||||
get:
|
||||
queryParameters:
|
||||
name?: string
|
||||
ownerName?: string
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
example: !include examples/Foos.json
|
||||
(testCase):
|
||||
scenario: No Foos
|
||||
setupScript: deleteAllFoosIfAny
|
||||
testScript: getAllFoos
|
||||
expectedOutput: ""
|
||||
(testCase):
|
||||
scenario: One Foo
|
||||
setupScript: [ deleteAllFoosIfAny, addInputFoos ]
|
||||
testScript: getAllFoos
|
||||
expectedOutput: '[ { "id": 999, "name": Joe } ]'
|
||||
cleanupScript: deleteInputFoos
|
||||
(testCase):
|
||||
scenario: Multiple Foos
|
||||
setupScript: [ deleteAllFoosIfAny, addInputFoos ]
|
||||
testScript: getAllFoos
|
||||
expectedOutput: '[ { "id": 998, "name": "Bob" }, { "id": 999, "name": "Joe", "ownerName": "Bob" } ]'
|
||||
cleanupScript: deleteInputFoos
|
||||
post:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
example: !include examples/Foo.json
|
||||
/{fooId}:
|
||||
type: myResourceTypes.item
|
||||
get:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
example: !include examples/Foo.json
|
||||
put:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
example: !include examples/Foo.json
|
||||
/foos/name/{name}:
|
||||
get:
|
||||
description: Get all Foos with the name {name}
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
type: myDataTypes.Foo
|
||||
404:
|
||||
body:
|
||||
type: myDataTypes.Error
|
||||
/foos/bar/{barId}:
|
||||
get:
|
||||
description: Get the Foo for the Bar with barId = {barId}
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
example: !include examples/Foo.json
|
||||
/bars:
|
||||
type: myResourceTypes.collection
|
||||
get:
|
||||
queryParameters:
|
||||
name?: string
|
||||
ownerName?: string
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
example: !include examples/Bars.json
|
||||
post:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
example: !include examples/Bar.json
|
||||
/{barId}:
|
||||
type: myResourceTypes.item
|
||||
get:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
example: !include examples/Bar.json
|
||||
put:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
example: !include examples/Bars.json
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Bar",
|
||||
"city" : "Austin",
|
||||
"fooId" : 2
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"message" : "Not found",
|
||||
"code" : 1001
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Foo"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,13 @@
|
||||
#%RAML 1.0 Extension
|
||||
# File located at:
|
||||
# /extensions/en_US/additionalResources.raml
|
||||
masterRef: ../../api.raml
|
||||
usage: This extension defines additional resources for version 2 of the API.
|
||||
version: v2
|
||||
/foos:
|
||||
/bar/{barId}:
|
||||
get:
|
||||
description: |
|
||||
Get the foo that is related to the bar having barId = {barId}
|
||||
queryParameters:
|
||||
barId?: integer
|
||||
@@ -0,0 +1,19 @@
|
||||
#%RAML 1.0 Library
|
||||
# This is the file /libraries/dataTypes.raml
|
||||
usage: This library defines the data types for the API
|
||||
types:
|
||||
Foo:
|
||||
properties:
|
||||
id: integer
|
||||
name: string
|
||||
ownerName?: string
|
||||
Bar:
|
||||
properties:
|
||||
id: integer
|
||||
name: string
|
||||
city?: string
|
||||
fooId: integer
|
||||
Error:
|
||||
properties:
|
||||
code: integer
|
||||
message: string
|
||||
@@ -0,0 +1,38 @@
|
||||
#%RAML 1.0 Library
|
||||
# This is the file /libraries/resourceTypes.raml
|
||||
usage: This library defines the resource types for the API
|
||||
uses:
|
||||
myTraits: !include traits.raml
|
||||
resourceTypes:
|
||||
collection:
|
||||
usage: Use this resourceType to represent a collection of items
|
||||
description: A collection of <<resourcePathName|!uppercamelcase>>
|
||||
get:
|
||||
description: |
|
||||
Get all <<resourcePathName|!uppercamelcase>>,
|
||||
optionally filtered
|
||||
is: [ myTraits.hasResponseCollection ]
|
||||
post:
|
||||
description: |
|
||||
Create a new <<resourcePathName|!uppercamelcase|!singularize>>
|
||||
is: [ myTraits.hasRequestItem ]
|
||||
item:
|
||||
usage: Use this resourceType to represent any single item
|
||||
description: A single <<resourcePathName|!uppercamelcase|!singularize>>
|
||||
get:
|
||||
description: |
|
||||
Get a <<resourcePathName|!uppercamelcase|!singularize>>
|
||||
by <<resourcePathName|!uppercamelcase|!singularize>>Id
|
||||
is: [ myTraits.hasResponseItem, myTraits.hasNotFound ]
|
||||
put:
|
||||
description: |
|
||||
Update a <<resourcePathName|!uppercamelcase|!singularize>>
|
||||
by <<resourcePathName|!singularize>>Id
|
||||
is: [ myTraits.hasRequestItem, myTraits.hasResponseItem, myTraits.hasNotFound ]
|
||||
delete:
|
||||
description: |
|
||||
Delete a <<resourcePathName|!uppercamelcase|!singularize>>
|
||||
by <<resourcePathName|!singularize>>Id
|
||||
is: [ myTraits.hasNotFound ]
|
||||
responses:
|
||||
204:
|
||||
@@ -0,0 +1,20 @@
|
||||
#%RAML 1.0 Library
|
||||
# This is the file /libraries/securitySchemes.raml
|
||||
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.
|
||||
@@ -0,0 +1,32 @@
|
||||
#%RAML 1.0 Library
|
||||
# This is the file /libraries/traits.raml
|
||||
usage: This library defines some basic traits
|
||||
uses:
|
||||
myDataTypes: !include dataTypes.raml
|
||||
traits:
|
||||
hasRequestItem:
|
||||
usage: Use this trait for resources whose request body is a single item
|
||||
body:
|
||||
application/json:
|
||||
type: <<resourcePathName|!singularize>>
|
||||
hasResponseItem:
|
||||
usage: Use this trait for resources whose response body is a single item
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<resourcePathName|!singularize>>
|
||||
hasResponseCollection:
|
||||
usage: Use this trait for resources whose response body is a collection of items
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<resourcePathName|!singularize>>[]
|
||||
hasNotFound:
|
||||
usage: Use this trait for resources that could respond with a 404 status
|
||||
responses:
|
||||
404:
|
||||
body:
|
||||
application/json:
|
||||
type: myDataTypes.Error
|
||||
@@ -0,0 +1,11 @@
|
||||
#%RAML 1.0 Overlay
|
||||
# Archivo situado en:
|
||||
# /overlays/es_ES/additionalResources.raml
|
||||
masterRef: ../../api.raml
|
||||
usage: |
|
||||
Se trata de un español demasiado que describe los recursos adicionales
|
||||
para la versión 1 del API.
|
||||
/foos/bar/{barId}:
|
||||
get:
|
||||
description: |
|
||||
Obtener el foo que se relaciona con el bar tomando barId = {barId}
|
||||
@@ -0,0 +1,22 @@
|
||||
#%RAML 1.0 Overlay
|
||||
# File located at (archivo situado en):
|
||||
# /overlays/es_ES/documentationItems.raml
|
||||
masterRef: ../../api.raml
|
||||
usage: |
|
||||
To provide user documentation and other descriptive text in Spanish
|
||||
(Para proporcionar la documentación del usuario y otro texto descriptivo en español)
|
||||
title: API para servicios REST utilizados en los tutoriales RAML en Baeldung.com
|
||||
documentation:
|
||||
- title: Descripción general
|
||||
content: |
|
||||
Este documento define la interfaz para los servicios REST
|
||||
utilizados en la popular serie de RAML Tutorial en Baeldung.com
|
||||
- title: Renuncia
|
||||
content: |
|
||||
Todos los nombres usados en esta definición son pura ficción.
|
||||
Cualquier similitud entre los nombres utilizados en este tutorial
|
||||
y los de las personas reales, ya sea vivo o muerto,
|
||||
no son más que coincidenta.
|
||||
- title: Derechos de autor
|
||||
content: |
|
||||
Derechos de autor 2016 por Baeldung.com. Todos los derechos reservados.
|
||||
@@ -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
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"message" : "Not found",
|
||||
"code" : 1001
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Foo"
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Foo"
|
||||
},
|
||||
{
|
||||
"id" : 2,
|
||||
"name" : "Second Foo"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
{ "$schema": "http://json-schema.org/schema",
|
||||
"type": "array",
|
||||
"items": { "$ref": "foo" }
|
||||
"description": "Collection of Foos"
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"message" : "Not found",
|
||||
"code" : 1001
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Foo"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Foo"
|
||||
},
|
||||
{
|
||||
"id" : 2,
|
||||
"name" : "Second Foo"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
#%RAML 1.0 DataType
|
||||
|
||||
properties:
|
||||
code: integer
|
||||
message: string
|
||||
@@ -0,0 +1,6 @@
|
||||
#%RAML 1.0 DataType
|
||||
|
||||
properties:
|
||||
id: integer
|
||||
name: string
|
||||
ownerName?: string
|
||||
@@ -0,0 +1,6 @@
|
||||
=========
|
||||
|
||||
## Modular RESTful API Modeling Language
|
||||
|
||||
### Relevant Articles:
|
||||
- [Modular RAML Using Includes, Libraries, Overlays and Extensions](http://www.baeldung.com/modular-raml-includes-overlays-libraries-extensions)
|
||||
@@ -0,0 +1,119 @@
|
||||
#%RAML 1.0
|
||||
title: API for REST Services used in the RAML tutorials on Baeldung.com
|
||||
documentation:
|
||||
- title: Overview
|
||||
- content: |
|
||||
This document defines the interface for the REST services
|
||||
used in the popular RAML Tutorial series at Baeldung.com.
|
||||
- title: Disclaimer:
|
||||
- content: |
|
||||
All names used in this definition are purely fictional.
|
||||
Any similarities between the names used in this tutorial and those of real persons, whether living or dead, are merely coincidental.
|
||||
- title: Copyright
|
||||
- content: Copyright 2016 by Baeldung.com. All rights reserved.
|
||||
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 <<resourcePathName|!uppercamelcase>>
|
||||
get:
|
||||
description: |
|
||||
Get all <<resourcePathName|!uppercamelcase>>,
|
||||
optionally filtered
|
||||
is: [ hasResponseCollection ]
|
||||
post:
|
||||
description: |
|
||||
Create a new <<resourcePathName|!uppercamelcase|!singularize>>
|
||||
is: [ hasRequestItem ]
|
||||
- item:
|
||||
usage: Use this resourceType to represent any single item
|
||||
description: A single <<typeName>>
|
||||
get:
|
||||
description: Get a <<typeName>> by <<resourcePathName>>
|
||||
is: [ hasResponseItem, hasNotFound ]
|
||||
put:
|
||||
description: Update a <<typeName>> by <<resourcePathName>>
|
||||
is: [ hasRequestItem, hasResponseItem, hasNotFound ]
|
||||
delete:
|
||||
description: Delete a <<typeName>> by <<resourcePathName>>
|
||||
is: [ hasNotFound ]
|
||||
responses:
|
||||
204:
|
||||
traits:
|
||||
- hasRequestItem:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>
|
||||
- hasResponseItem:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>
|
||||
example: !include examples/<<typeName>>.json
|
||||
- hasResponseCollection:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>[]
|
||||
example: !include examples/<<typeName|!pluralize>>.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 ]
|
||||
@@ -0,0 +1,50 @@
|
||||
#%RAML 1.0
|
||||
title: API for REST Services used in the RAML tutorials on Baeldung.com
|
||||
documentation:
|
||||
- title: Overview
|
||||
- content: |
|
||||
This document defines the interface for the REST services
|
||||
used in the popular RAML Tutorial series at Baeldung.com.
|
||||
- title: Disclaimer:
|
||||
- content: |
|
||||
All names used in this definition are purely fictional.
|
||||
Any similarities between the names used in this tutorial and those of real persons, whether living or dead, are merely coincidental.
|
||||
- title: Copyright
|
||||
- content: Copyright 2016 by Baeldung.com. All rights reserved.
|
||||
uses:
|
||||
mySecuritySchemes: !include libraries/security.raml
|
||||
myDataTypes: !include libraries/dataTypes.raml
|
||||
myResourceTypes: !include libraries/resourceTypes.raml
|
||||
myTraits: !include libraries/traits.raml
|
||||
version: v1
|
||||
protocols: [ HTTPS ]
|
||||
baseUri: http://rest-api.baeldung.com/api/{version}
|
||||
mediaType: application/json
|
||||
securedBy: [ mySecuritySchemes.basicAuth ]
|
||||
/foos:
|
||||
type: myResourceTypes.collection
|
||||
typeName: myDataTypes.Foo
|
||||
get:
|
||||
queryParameters:
|
||||
name?: string
|
||||
ownerName?: string
|
||||
/{fooId}:
|
||||
type: myResourceTypes.item
|
||||
typeName: myDataTypes.Foo
|
||||
/name/{name}:
|
||||
get:
|
||||
description: List all foos with a certain name
|
||||
typeName: myDataTypes.Foo
|
||||
is: [ myTraits.hasResponseCollection ]
|
||||
/bars:
|
||||
type: myResourceTypes.collection
|
||||
typeName: myDataTypes.Bar
|
||||
/{barId}:
|
||||
type: myResourceTypes.item
|
||||
typeName: myDataTypes.Bar
|
||||
/fooId/{fooId}:
|
||||
get:
|
||||
description: Get all bars for the matching fooId
|
||||
type: myResourceTypes.item
|
||||
typeName: myDataTypes.Bar
|
||||
is: [ myTraits.hasResponseCollection ]
|
||||
@@ -0,0 +1,74 @@
|
||||
#%RAML 1.0
|
||||
title: API for REST Services used in the RAML tutorials on Baeldung.com
|
||||
documentation:
|
||||
- title: Overview
|
||||
- content: |
|
||||
This document defines the interface for the REST services
|
||||
used in the popular RAML Tutorial series at Baeldung.com.
|
||||
- title: Disclaimer:
|
||||
- content: |
|
||||
All names used in this definition are purely fictional.
|
||||
Any similarities between the names used in this tutorial and those of real persons, whether living or dead, are merely coincidental.
|
||||
- title: Copyright
|
||||
- content: Copyright 2016 by Baeldung.com. All rights reserved.
|
||||
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: !include resourceTypes/collection.raml
|
||||
- item: !include resourceTypes/item.raml
|
||||
traits:
|
||||
- hasRequestItem: !include traits/hasRequestItem.raml
|
||||
- hasResponseItem: !include traits/hasResponseItem.raml
|
||||
- hasResponseCollection: !include traits/hasResponseCollection.raml
|
||||
- hasNotFound: !include traits/hasNotFound.raml
|
||||
/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 ]
|
||||
@@ -0,0 +1,47 @@
|
||||
#%RAML 1.0
|
||||
title: Baeldung Foo REST Services API
|
||||
uses:
|
||||
security: !include libraries/security.raml
|
||||
version: v1
|
||||
protocols: [ HTTPS ]
|
||||
baseUri: http://rest-api.baeldung.com/api/{version}
|
||||
mediaType: application/json
|
||||
securedBy: [ security.basicAuth ]
|
||||
types:
|
||||
Foo: !include types/Foo.raml
|
||||
Bar: !include types/Bar.raml
|
||||
Error: !include types/Error.raml
|
||||
resourceTypes:
|
||||
- collection: !include resourceTypes/collection.raml
|
||||
- item: !include resourceTypes/item.raml
|
||||
traits:
|
||||
- hasRequestItem: !include traits/hasRequestItem.raml
|
||||
- hasResponseItem: !include traits/hasResponseItem.raml
|
||||
- hasResponseCollection: !include traits/hasResponseCollection.raml
|
||||
- hasNotFound: !include traits/hasNotFound.raml
|
||||
/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 ]
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Bar",
|
||||
"city" : "Austin",
|
||||
"fooId" : 2
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"message" : "Not found",
|
||||
"code" : 1001
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Foo"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,16 @@
|
||||
#%RAML 1.0 Extension
|
||||
# File located at:
|
||||
# /extensions/en_US/additionalResources.raml
|
||||
masterRef: /api.raml
|
||||
usage: This extension defines additional resources for version 2 of the API.
|
||||
version: v2
|
||||
/foos:
|
||||
/bar/{barId}:
|
||||
get:
|
||||
description: |
|
||||
Get the foo that is related to the bar having barId = {barId}
|
||||
typeName: Foo
|
||||
queryParameters:
|
||||
barId?: integer
|
||||
typeName: Foo
|
||||
is: [ hasResponseItem ]
|
||||
@@ -0,0 +1,19 @@
|
||||
#%RAML 1.0 Library
|
||||
# This is the file /libraries/dataTypes.raml
|
||||
usage: This library defines the data types for the API
|
||||
types:
|
||||
Foo:
|
||||
properties:
|
||||
id: integer
|
||||
name: string
|
||||
ownerName?: string
|
||||
Bar:
|
||||
properties:
|
||||
id: integer
|
||||
name: string
|
||||
city?: string
|
||||
fooId: integer
|
||||
Error:
|
||||
properties:
|
||||
code: integer
|
||||
message: string
|
||||
@@ -0,0 +1,32 @@
|
||||
#%RAML 1.0 Library
|
||||
# This is the file /libraries/resourceTypes.raml
|
||||
usage: This library defines the resource types for the API
|
||||
uses:
|
||||
myTraits: !include traits.raml
|
||||
resourceTypes:
|
||||
collection:
|
||||
usage: Use this resourceType to represent a collection of items
|
||||
description: A collection of <<resourcePathName|!uppercamelcase>>
|
||||
get:
|
||||
description: |
|
||||
Get all <<resourcePathName|!uppercamelcase>>,
|
||||
optionally filtered
|
||||
is: [ myTraits.hasResponseCollection ]
|
||||
post:
|
||||
description: |
|
||||
Create a new <<resourcePathName|!uppercamelcase|!singularize>>
|
||||
is: [ myTraits.hasRequestItem ]
|
||||
item:
|
||||
usage: Use this resourceType to represent any single item
|
||||
description: A single <<typeName>>
|
||||
get:
|
||||
description: Get a <<typeName>> by <<resourcePathName>>
|
||||
is: [ myTraits.hasResponseItem, myTraits.hasNotFound ]
|
||||
put:
|
||||
description: Update a <<typeName>> by <<resourcePathName>>
|
||||
is: [ myTraits.hasRequestItem, myTraits.hasResponseItem, myTraits.hasNotFound ]
|
||||
delete:
|
||||
description: Delete a <<typeName>> by <<resourcePathName>>
|
||||
is: [ myTraits.hasNotFound ]
|
||||
responses:
|
||||
204:
|
||||
@@ -0,0 +1,20 @@
|
||||
#%RAML 1.0 Library
|
||||
# This is the file /libraries/securitySchemes.raml
|
||||
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.
|
||||
@@ -0,0 +1,33 @@
|
||||
#%RAML 1.0 Library
|
||||
# This is the file /libraries/traits.raml
|
||||
usage: This library defines some basic traits
|
||||
traits:
|
||||
hasRequestItem:
|
||||
usage: Use this trait for resources whose request body is a single item
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>
|
||||
hasResponseItem:
|
||||
usage: Use this trait for resources whose response body is a single item
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>
|
||||
example: !include /examples/<<typeName>>.json
|
||||
hasResponseCollection:
|
||||
usage: Use this trait for resources whose response body is a collection of items
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>[]
|
||||
example: !include /examples/<<typeName|!pluralize>>.json
|
||||
hasNotFound:
|
||||
usage: Use this trait for resources that could respond with a 404 status
|
||||
responses:
|
||||
404:
|
||||
body:
|
||||
application/json:
|
||||
type: Error
|
||||
example: !include /examples/Error.json
|
||||
@@ -0,0 +1,13 @@
|
||||
#%RAML 1.0 Overlay
|
||||
# Archivo situado en:
|
||||
# /overlays/es_ES/additionalResources.raml
|
||||
masterRef: /api.raml
|
||||
usage: |
|
||||
Se trata de un español demasiado que describe los recursos adicionales
|
||||
para la versión 2 del API.
|
||||
version: v2
|
||||
/foos:
|
||||
/bar/{barId}:
|
||||
get:
|
||||
description: |
|
||||
Obtener el foo que se relaciona con el bar tomando barId = {barId}
|
||||
@@ -0,0 +1,23 @@
|
||||
#%RAML 1.0 Overlay
|
||||
# File located at (archivo situado en):
|
||||
# /overlays/es_ES/documentationItems.raml
|
||||
masterRef: /api.raml
|
||||
usage: |
|
||||
To provide user documentation and other descriptive text in Spanish
|
||||
(Para proporcionar la documentación del usuario y otro texto descriptivo en español)
|
||||
title: API para servicios REST utilizados en los tutoriales RAML en Baeldung.com
|
||||
documentation:
|
||||
- title: Descripción general
|
||||
- content: |
|
||||
Este documento define la interfaz para los servicios REST
|
||||
utilizados en la popular serie de RAML Tutorial en Baeldung.com
|
||||
- title: Renuncia
|
||||
- content: |
|
||||
Todos los nombres usados en esta definición son pura ficción.
|
||||
Cualquier similitud entre los nombres utilizados en este tutorial
|
||||
y los de las personas reales, ya sea vivo o muerto,
|
||||
no son más que coincidenta.
|
||||
|
||||
- title: Derechos de autor
|
||||
- content: |
|
||||
Derechos de autor 2016 por Baeldung.com. Todos los derechos reservados.
|
||||
@@ -0,0 +1,12 @@
|
||||
#%RAML 1.0 ResourceType
|
||||
usage: Use this resourceType to represent a collection of items
|
||||
description: A collection of <<resourcePathName|!uppercamelcase>>
|
||||
get:
|
||||
description: |
|
||||
Get all <<resourcePathName|!uppercamelcase>>,
|
||||
optionally filtered
|
||||
is: [ hasResponseCollection ]
|
||||
post:
|
||||
description: |
|
||||
Create a new <<resourcePathName|!uppercamelcase|!singularize>>
|
||||
is: [ hasRequestItem ]
|
||||
@@ -0,0 +1,14 @@
|
||||
#%RAML 1.0 ResourceType
|
||||
usage: Use this resourceType to represent any single item
|
||||
description: A single <<typeName>>
|
||||
get:
|
||||
description: Get a <<typeName>> by <<resourcePathName>>
|
||||
is: [ hasResponseItem, hasNotFound ]
|
||||
put:
|
||||
description: Update a <<typeName>> by <<resourcePathName>>
|
||||
is: [ hasRequestItem, hasResponseItem, hasNotFound ]
|
||||
delete:
|
||||
description: Delete a <<typeName>> by <<resourcePathName>>
|
||||
is: [ hasNotFound ]
|
||||
responses:
|
||||
204:
|
||||
@@ -0,0 +1,8 @@
|
||||
#%RAML 1.0 Trait
|
||||
usage: Use this trait for resources that could respond with a 404 status
|
||||
responses:
|
||||
404:
|
||||
body:
|
||||
application/json:
|
||||
type: Error
|
||||
example: !include /examples/Error.json
|
||||
@@ -0,0 +1,5 @@
|
||||
#%RAML 1.0 Trait
|
||||
usage: Use this trait for resources whose request body is a single item
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>
|
||||
@@ -0,0 +1,8 @@
|
||||
#%RAML 1.0 Trait
|
||||
usage: Use this trait for resources whose response body is a collection of items
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>[]
|
||||
example: !include /examples/<<typeName|!pluralize>>.json
|
||||
@@ -0,0 +1,8 @@
|
||||
#%RAML 1.0 Trait
|
||||
usage: Use this trait for resources whose response body is a single item
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>
|
||||
example: !include /examples/<<typeName>>.json
|
||||
@@ -0,0 +1,7 @@
|
||||
#%RAML 1.0 DataType
|
||||
|
||||
properties:
|
||||
id: integer
|
||||
name: string
|
||||
city?: string
|
||||
fooId: integer
|
||||
@@ -0,0 +1,5 @@
|
||||
#%RAML 1.0 DataType
|
||||
|
||||
properties:
|
||||
code: integer
|
||||
message: string
|
||||
@@ -0,0 +1,6 @@
|
||||
#%RAML 1.0 DataType
|
||||
|
||||
properties:
|
||||
id: integer
|
||||
name: string
|
||||
ownerName?: string
|
||||
@@ -0,0 +1,2 @@
|
||||
### Relevant Articles:
|
||||
- [Eliminate Redundancies in RAML with Resource Types and Traits](http://www.baeldung.com/simple-raml-with-resource-types-and-traits)
|
||||
+177
@@ -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
|
||||
@@ -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 <<resourcePathName|!uppercamelcase>>
|
||||
get:
|
||||
description: |
|
||||
Get all <<resourcePathName|!uppercamelcase>>,
|
||||
optionally filtered
|
||||
is: [ hasResponseCollection ]
|
||||
post:
|
||||
description: |
|
||||
Create a new <<resourcePathName|!uppercamelcase|!singularize>>
|
||||
is: [ hasRequestItem ]
|
||||
- item:
|
||||
usage: Use this resourceType to represent any single item
|
||||
description: A single <<typeName>>
|
||||
get:
|
||||
description: Get a <<typeName>> by <<resourcePathName>>
|
||||
is: [ hasResponseItem, hasNotFound ]
|
||||
put:
|
||||
description: Update a <<typeName>> by <<resourcePathName>>
|
||||
is: [ hasRequestItem, hasResponseItem, hasNotFound ]
|
||||
delete:
|
||||
description: Delete a <<typeName>> by <<resourcePathName>>
|
||||
is: [ hasNotFound ]
|
||||
responses:
|
||||
204:
|
||||
traits:
|
||||
- hasRequestItem:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>
|
||||
- hasResponseItem:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>
|
||||
example: !include examples/<<typeName>>.json
|
||||
- hasResponseCollection:
|
||||
responses:
|
||||
200:
|
||||
body:
|
||||
application/json:
|
||||
type: <<typeName>>[]
|
||||
example: !include examples/<<typeName|!pluralize>>.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 ]
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Bar",
|
||||
"city" : "Austin",
|
||||
"fooId" : 2
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"message" : "Not found",
|
||||
"code" : 1001
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "First Foo"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,7 @@
|
||||
#%RAML 1.0 DataType
|
||||
|
||||
properties:
|
||||
id: integer
|
||||
name: string
|
||||
city?: string
|
||||
fooId: integer
|
||||
@@ -0,0 +1,5 @@
|
||||
#%RAML 1.0 DataType
|
||||
|
||||
properties:
|
||||
code: integer
|
||||
message: string
|
||||
@@ -0,0 +1,6 @@
|
||||
#%RAML 1.0 DataType
|
||||
|
||||
properties:
|
||||
id: integer
|
||||
name: string
|
||||
ownerName?: string
|
||||
Reference in New Issue
Block a user