Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ baselinerest: spec
spec requires: #('Seaside-REST-Core' 'Seaside-Tests-Core') ].
spec
group: 'REST' with: #('Seaside-REST-Core');
group: 'REST Tests' with: #('REST' 'Seaside-Tests-REST-Core')
].

group: 'REST Tests' with: #('REST' 'Seaside-Tests-REST-Core');
group: 'Examples' with: #('Seaside-REST-Examples') ].

spec for: #'squeakCommon' do: [
spec
Expand All @@ -24,8 +23,7 @@ baselinerest: spec
spec
group: 'REST' with: #('Seaside-REST-Core');
group: 'Swagger' with: #('REST' 'Seaside-Swagger-Core');
group: 'Swagger Tests' with: #('Swagger' 'Seaside-Tests-Swagger-Core')
].
group: 'Swagger Tests' with: #('Swagger' 'Seaside-Tests-Swagger-Core') ].

spec for: #(squeak) do:[
spec
Expand All @@ -35,8 +33,7 @@ baselinerest: spec
package: 'Seaside-Squeak-Swagger-Core';
package: 'Seaside-Pharo-Swagger-Core';
package: 'Seaside-Swagger-Core' with: [
spec includes: #('Seaside-Pharo-Swagger-Core' 'Seaside-Squeak-Swagger-Core') ]
].
spec includes: #('Seaside-Pharo-Swagger-Core' 'Seaside-Squeak-Swagger-Core') ] ].

spec
for: #(#'pharo4.x' #'pharo5.x' #'pharo6.x' #'pharo7.x' #'pharo8.x')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ encodeOn: aDocument
nextPut: Character space;
nextPutAll: key.
value == true ifFalse: [
aDocument nextPutAll: '="';
print: value;
nextPut: $" ] ] ]
aDocument
nextPutAll: '="';
print: value;
nextPut: $" ] ] ]
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
testing
matchesParameters: aDictionary
parameterMatches size = aDictionary size
ifFalse: [ ^ false ].

optionalQueryParameters ifNil:[
parameterMatches size = aDictionary size
ifFalse: [ ^ false ] ].
parameterMatches keysAndValuesDo: [ :name :match |
| value |
value := aDictionary at: name ifAbsent: [ ^ false ].
(match matchesName: name value: value)
ifFalse: [ ^ false ] ].
optionalQueryParameters ifNotNil:[
| allPossibleParameters |
allPossibleParameters := parameterMatches keys, optionalQueryParameters.
(aDictionary keys allSatisfy: [ :k | allPossibleParameters includes: k ]) ifFalse: [ ^ false ] ].

^ true
20 changes: 4 additions & 16 deletions repository/Seaside-REST-Core.package/WARoute.class/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
I am a message that can be sent if I match a request. Message arguments can be taken from the request.

Instance Variables:
method <String>
selector <Symbol>
produces <WAMatch>
consumes <WAMatch>

method
- The HTTP method on which to follow this route, eg. 'GET'

selector
- The selector to perform, eg. #index

produces
- The MIME type this route produces (Content-Type HTTP header)

consumes
- The MIME type this route accepts (Accept HTTP header)
method <String>: The HTTP method on which to follow this route, eg. 'GET'
selector <Symbol>: The selector to perform, eg. #index
produces <WAMatch>: The MIME type this route produces (Content-Type HTTP header)
consumes <WAMatch>: The MIME type this route accepts (Accept HTTP header)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialization
initializeOptionalQueryFieldParametersFrom: aString

optionalQueryParameters := OrderedCollection new.
aString splitOn: $, do: [ :s | optionalQueryParameters add: s ]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commentStamp" : "pmm 7/28/2011 20:33",
"commentStamp" : "2025-07-20T15:37:39.685139+03:00",
"super" : "WAObject",
"category" : "Seaside-REST-Core-Route",
"classinstvars" : [ ],
Expand All @@ -9,7 +9,8 @@
"method",
"selector",
"produces",
"consumes"
"consumes",
"optionalQueryParameters"
],
"name" : "WARoute",
"type" : "normal"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
private
create
^ path isNil
| route |
route := path isNil
ifTrue: [ self createSimpleRoute ]
ifFalse: [ self createComplexRoute ]
ifFalse: [ self createComplexRoute ].
optionalQueryParameters ifNotNil:[
route initializeOptionalQueryFieldParametersFrom: optionalQueryParameters ].
^ route
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
configuration
optionalQueryParameters: aString
<configuration>

optionalQueryParameters := aString
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"method",
"path",
"produces",
"consumes"
"consumes",
"optionalQueryParameters"
],
"name" : "WARouteBuilder",
"type" : "normal"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
A WARouteContainer is a collection of routes that all accept the same number of path elements ordered by priority.

Instance Variables
pathElementCount: <Integer>
routes: <SortedCollection<WARoute>>

pathElementCount
- the number of path elements that any of the routes in this container accepts

routes
- the routes ordered by priority
pathElementCount <Integer>: the number of path elements that any of the routes in this container accepts
routes <SortedCollection<WARoute>>: the routes ordered by priority
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ routeForElements: aCollection parameters: aDictionary contentType: aMimeType acc
result := (routes select: [ :each |
(each matchesPath: aCollection)
and: [ (each matchesParameters: aDictionary)
and: [ (aMimeType isNil or: [ each consumes: aMimeType ])
and: [ aCollectionOfAccept isNil or: [ each produces: aCollectionOfAccept ] ] ] ] ]) asArray.
and: [ (aMimeType isNil or: [ each consumes: aMimeType ])
and: [ aCollectionOfAccept isNil or: [ each produces: aCollectionOfAccept ] ] ] ] ]) asArray.
result isEmpty
ifTrue: [ ^ anAbsentBlock value ].
result size = 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commentStamp" : "pmm 9/14/2013 16:04",
"commentStamp" : "2025-07-23T11:12:55.002952+03:00",
"super" : "WAObject",
"category" : "Seaside-REST-Core-Route",
"classinstvars" : [ ],
Expand Down
15 changes: 3 additions & 12 deletions repository/Seaside-REST-Core.package/WARouteResult.class/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
I am the result of a route look up. I contain all the information required to "execute" the result.

Instance Variables:
route <WARoute>
elements <Collection<String>>
parameters <WARequestFields>

route
the found route

elements
the unconsumed path elements of the request

parameters
the query fields of the request
route <WARoute>: the found route
elements <Collection<String>>: the unconsumed path elements of the request
parameters <WARequestFields>: the query fields of the request
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commentStamp" : "pmm 9/14/2013 16:03",
"commentStamp" : "2025-07-23T11:13:39.03153+03:00",
"super" : "WAObject",
"category" : "Seaside-REST-Core-Route",
"classinstvars" : [ ],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
I match only on an exact number of path elements and no URL parameters. The path elements are turned into message arguments.

Instance Variables:
count <Integer>

count
- The exact number of path elements that have to be present.
count <Integer>: The exact number of path elements that have to be present.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
testing
matchesParameters: aDictionary
^ aDictionary isEmpty

optionalQueryParameters isNil
ifTrue:[ aDictionary isEmpty ifFalse: [ ^ false ]]
ifFalse:[ (aDictionary keys allSatisfy: [ :k | optionalQueryParameters includes: k ]) ifFalse: [ ^ false ] ].
^ true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commentStamp" : "DamienPollet 6/27/2011 16:35",
"commentStamp" : "2025-07-20T16:19:41.001956+03:00",
"super" : "WARoute",
"category" : "Seaside-REST-Core-Route",
"classinstvars" : [ ],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
registration
register

WAAdmin register: self at: 'examples/jsonapi'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
json api
getClasses

<get>
<path: '/classes/'>
<produces: 'application/json'>

^ WAJsonCanvas builder render: [ :json |
json array: [
Smalltalk allClasses do:[ :class |
json object: [
json
key: 'name' value: class name;
key: 'instvars' value: [ json array: [ class instVarNames do: [ :iv | json string: iv ] ] ] ] ] ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
json api
getClassesMatching: classNameSubstring

<get>
<path: '/classes?substring={classNameSubstring}'>
<produces: 'application/json'>

^ WAJsonCanvas builder render: [ :json |
json array: [
(Smalltalk allClasses select: [ :class | (class name indexOfSubCollection: classNameSubstring startingAt: 0) ~= 0 ])
do: [ :class |
json object: [
json
key: 'name' value: class name;
key: 'instvars' value: [ json array: [ class instVarNames do: [ :iv | json string: iv ] ] ] ] ] ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
json api
getMethodsOf: className

<get>
<path: '/class/{className}/methods'>
<produces: 'application/json'>

| theClass |
theClass := Smalltalk at: className asSymbol ifAbsent: [ self respondNotFound ].

^ WAJsonCanvas builder render: [ :json |
json array: [
theClass methodsDo: [ :method |
json object: [
json
key: 'selector' value: method selector;
key: 'source' value: (GRPlatform current sourceCodeStringOf: method) ] ] ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
helpers
respondNotFound

self requestContext responseGenerator
notFound;
respond
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "WARestfulHandler",
"category" : "Seaside-REST-Examples",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "WAJsonAPIExample",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: #'Seaside-REST-Examples'!
self packageOrganizer ensurePackage: #'Seaside-REST-Examples' withTags: #()!

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests
testParameterMatchingOptionalParameters
| route |
route := WARoute get: '/{1}/_all_docs?required={2}' selector: #a:required:.
route initializeOptionalQueryFieldParametersFrom: 'sorted,filter'.
self assert: (route matchesParameters: (Dictionary new add: 'required' -> 'true';yourself)).
self assert: (route matchesParameters: (Dictionary new add: 'required' -> 'true'; add: 'sorted' -> 'true'; yourself)).
self assert: (route matchesParameters: (Dictionary new add: 'required' -> 'true'; add: 'sorted' -> 'true'; add: 'filter' -> 'none'; yourself)).

self deny: (route matchesParameters: (Dictionary new add: 'required' -> 'true'; add: 'key' -> 'value'; yourself)).
self deny: (route matchesParameters: (Dictionary new add: 'required' -> 'true'; add: 'sorted' -> 'true'; add: 'filter' -> 'none'; add: 'key' -> 'value'; yourself)).
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ public-documents
getAllDocuments: databaseName
<get>
<path: '/{databaseName}/_all_docs'>
<optionalQueryParameters: 'sorted,filter'>

Loading