Skip to content

Commit

Permalink
alignment, reverted spec-kw generation
Browse files Browse the repository at this point in the history
  • Loading branch information
invaliduser committed Jul 18, 2024
1 parent baebef3 commit 139e10c
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 65 deletions.
109 changes: 53 additions & 56 deletions src/main/com/yetanalytics/lrs/pedestal/openapi.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
:type {}
:moreinfo {}
:extensions {}}}}}
:Agent ;maybe important
:Agent
{:allOf [{:type :object
:properties {:name :t#string
:objectType :t#string}}
Expand All @@ -41,14 +41,14 @@
:r#IFI]}]}
:Actor {:oneOf [:r#Group
:r#Agent]}

:Error (gs/o {:error :t#string})

:IFI {:oneOf [(gs/o {:mbox :r#MailToIRI})
(gs/o {:mbox_sha1sum :t#string})
(gs/o {:openid :r#URI})
(gs/o {:account :r#Account})]}

:IRI {:type :string :format :iri}
:IRL :t#string
:MailToIRI {:type :string :format :email}
Expand Down Expand Up @@ -89,28 +89,27 @@
:operationId :get-activity-profile
:description "Fetches the specified Profile document in the context of the specified Activity. The semantics of the request are driven by the \"profileId\" parameter. If it is included, the GET method will act upon a single defined document identified by \"profileId\". Otherwise, GET will return the available ids."}


:xapi.activities.profile.PUT.request/params
{:params {:activityId :r#IRI :profileId :t#string}
:requestBody (g/request :t#object)
:responses {204 (g/response "No content")}
:operationId :put-activity-profile
:description "Stores or changes the specified Profile document in the context of the specified Activity."}

:xapi.activities.profile.POST.request/params
{:params {:activityId :r#IRI :profileId :t#string}
:requestBody(g/request :t#object)
:requestBody (g/request :t#object)
:responses {204 (g/response "No content")}
:operationId :post-activity-profile
:description "Stores or changes the specified Profile document in the context of the specified Activity."}

:xapi.activities.profile.DELETE.request/params
{:params {:activityId :r#IRI
:profileId :t#string}
:responses {204 (g/response "No content")}
:operationId :delete-activity-profile
:description "Deletes the specified Profile document in the context of the specified Activity."}

:xapi.activities.state.GET.request/params
{:params {:activityId :r#IRI
:agent :r#Agent
Expand All @@ -129,7 +128,7 @@
:?#registration :r#UUID
:stateId :t#string}
:requestBody (g/request :t#object)
:responses {204 (g/response "No content" )}
:responses {204 (g/response "No content")}
:operationId :put-state
:description "Stores or changes the document specified by the given stateId that exists in the context of the specified Activity, Agent, and registration (if specified)."}
:xapi.activities.state.POST.request/params
Expand All @@ -138,15 +137,15 @@
:?#registration :r#UUID
:stateId :t#string}
:requestBody (g/request :t#object)
:responses {204 (g/response "No content" )}
:responses {204 (g/response "No content")}
:operationId :post-state
:description "Stores or changes the document specified by the given stateId that exists in the context of the specified Activity, Agent, and registration (if specified)."}
:xapi.activities.state.DELETE.request/params
{:params {:activityId :r#IRI
:agent :r#Agent
:?#registration :r#UUID
:?#stateId :t#string}
:responses {204 (g/response "No content" )}
:responses {204 (g/response "No content")}
:operationId :delete-state
:description "Deletes all documents associated with the specified Activity, Agent, and registration (if specified), or just the document specified by stateId"}
:xapi.agents.profile.GET.request/params
Expand Down Expand Up @@ -178,56 +177,54 @@
:operationId :delete-agents-profile
:description "Deletes the specified Profile document in the context of the specified Agent."}))

(def annotations
{:health {:operationId :health
:responses {200 (gc/response "Empty body---a 200 indicates server is alive")}
:description "Simple heartbeat"}
:about {:operationId :get-about
:description "About info"
:responses
{200 (gc/response "Object containing body text and optional etag"
(gc/o {:body :t#string
:#?etag :t#string}))}}
:statements-get {:params {:?#statementId :t#string
:?#voidedStatementId :t#string
:?#agent :r#Actor
:?#verb :r#IRI
:?#activity :r#IRI
:?#registration :r#UUID
:?#related_activities :t#boolean
:?#related_agents :t#boolean
:?#since :r#Timestamp
:?#limit :t#integer
:?#format :t#string
:?#attachments :t#boolean
:?#ascending :t#boolean}

:responses {200 (gc/response "Requested Statement or Results"
{:oneOf [:r#Statement
:r#StatementResult]})}
:operationId :get-statement
:description "https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Communication.md#21-statement-resource"}

(def annotations
{:health {:operationId :health
:responses {200 (gc/response "Empty body---a 200 indicates server is alive")}
:description "Simple heartbeat"}
:about {:operationId :get-about
:description "About info"
:responses
{200 (gc/response "Object containing body text and optional etag"
(gc/o {:body :t#string
:#?etag :t#string}))}}
:statements-get {:params {:?#statementId :t#string
:?#voidedStatementId :t#string
:?#agent :r#Actor
:?#verb :r#IRI
:?#activity :r#IRI
:?#registration :r#UUID
:?#related_activities :t#boolean
:?#related_agents :t#boolean
:?#since :r#Timestamp
:?#limit :t#integer
:?#format :t#string
:?#attachments :t#boolean
:?#ascending :t#boolean}

:responses {200 (gc/response "Requested Statement or Results"
{:oneOf [:r#Statement
:r#StatementResult]})}
:operationId :get-statement
:description "https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Communication.md#21-statement-resource"}

:statements-put {:params {:statementId :t#string}
:requestBody (gc/request :r#Statement)
:responses {204 (gc/response "No content")}
:operationId :put-statement
:description ""}
:statements-put {:params {:statementId :t#string}
:requestBody (gc/request :r#Statement)
:responses {204 (gc/response "No content")}
:operationId :put-statement
:description ""}
:statements-post {:requestBody (gc/request {:oneOf [(gc/a :r#statementId)
:r#statementId]})
:responses {200 (gc/response "Array of Statement id(s) (UUID) in the same order as the corresponding stored Statements."
(gc/a :r#statementId))}
:responses {200 (gc/response "Array of Statement id(s) (UUID) in the same order as the corresponding stored Statements."
(gc/a :r#statementId))}
:operationId :post-statement
:description "Stores a Statement, or a set of Statements."}
:agents-post {:params {:agent :r#Agent}
:responses {200 (gc/response "Return a special, Person Object for a specified Agent. The Person Object is very similar to an Agent Object, but instead of each attribute having a single value, each attribute has an array value, and it is legal to include multiple identifying properties."
:r#Person)}
:operationId :get-agent
:description "Gets a specified agent"}
:activities-post {:params {:activityId :r#IRI}
:responses {200 (gc/response "The requested Activity object"
:r#Activity)}
:agents-post {:params {:agent :r#Agent}
:responses {200 (gc/response "Return a special, Person Object for a specified Agent. The Person Object is very similar to an Agent Object, but instead of each attribute having a single value, each attribute has an array value, and it is legal to include multiple identifying properties."
:r#Person)}
:operationId :get-agent
:description "Gets a specified agent"}
:activities-post {:params {:activityId :r#IRI}
:responses {200 (gc/response "The requested Activity object"
:r#Activity)}
:operationId :get-activity
:description "Gets the Activity with the specified activityId"}})
33 changes: 24 additions & 9 deletions src/main/com/yetanalytics/lrs/pedestal/routes.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,31 @@
method
method-not-allowed
:route-name (keyword route-name-ns (name method))]
(let [method-kw (case method
:head :get
method)
method-str (-> method-kw name clojure.string/upper-case)
token-vec ["xapi" resource doc-type method-str "request/params"]
spec-kw (-> (clojure.string/join \. token-vec)
keyword)
(let [spec-kw
(case resource-tuple
["activities" "state"]
(case method
:put :xapi.activities.state.PUT.request/params
:post :xapi.activities.state.POST.request/params
:get :xapi.activities.state.GET.request/params
:head :xapi.activities.state.GET.request/params
:delete :xapi.activities.state.DELETE.request/params)
["activities" "profile"]
(case method
:put :xapi.activities.profile.PUT.request/params
:post :xapi.activities.profile.POST.request/params
:get :xapi.activities.profile.GET.request/params
:head :xapi.activities.profile.GET.request/params
:delete :xapi.activities.profile.DELETE.request/params)
["agents" "profile"]
(case method
:put :xapi.agents.profile.PUT.request/params
:post :xapi.agents.profile.POST.request/params
:get :xapi.agents.profile.GET.request/params
:head :xapi.agents.profile.GET.request/params
:delete :xapi.agents.profile.DELETE.request/params))
doc-params-interceptor
(xapi-i/params-interceptor spec-kw)

(xapi-i/params-interceptor spec-kw)
params-interceptors
(cond-> [doc-params-interceptor]
;; Scan files if scanner is present on PUT/POST
Expand Down

0 comments on commit 139e10c

Please sign in to comment.