Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
eeafb265
Commit
eeafb265
authored
Nov 27, 2023
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_action_information_api: support for OpenAPI hyperdocument
parent
cff390ef
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
127 additions
and
104 deletions
+127
-104
bt5/erp5_action_information_api/ActionTemplateItem/portal_types/Action%20Information%20API/api_openapi.xml
...m/portal_types/Action%20Information%20API/api_openapi.xml
+0
-81
bt5/erp5_action_information_api/DocumentTemplateItem/portal_components/document.erp5.ActionInformationAPI.py
...m/portal_components/document.erp5.ActionInformationAPI.py
+1
-2
bt5/erp5_action_information_api/SkinTemplateItem/portal_skins/erp5_action_information_api/ActionInformationAPI_api_openapi.py
...ction_information_api/ActionInformationAPI_api_openapi.py
+12
-0
bt5/erp5_action_information_api/SkinTemplateItem/portal_skins/erp5_action_information_api/ActionInformationAPI_api_openapi.xml
...tion_information_api/ActionInformationAPI_api_openapi.xml
+62
-0
bt5/erp5_action_information_api/SkinTemplateItem/portal_skins/erp5_action_information_api/ActionInformationAPI_api_slap.py
...5_action_information_api/ActionInformationAPI_api_slap.py
+2
-0
bt5/erp5_action_information_api/SkinTemplateItem/portal_skins/erp5_action_information_api/ActionInformationAPI_api_slap.xml
..._action_information_api/ActionInformationAPI_api_slap.xml
+1
-1
bt5/erp5_action_information_api/TestTemplateItem/portal_components/test.erp5.testActionInformationAPI.py
...m/portal_components/test.erp5.testActionInformationAPI.py
+47
-18
bt5/erp5_action_information_api/bt/template_action_path_list
bt5/erp5_action_information_api/bt/template_action_path_list
+0
-1
bt5/erp5_action_information_api/bt/test_dependency_list
bt5/erp5_action_information_api/bt/test_dependency_list
+2
-1
No files found.
bt5/erp5_action_information_api/ActionTemplateItem/portal_types/Action%20Information%20API/api_openapi.xml
deleted
100644 → 0
View file @
cff390ef
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ActionInformation"
module=
"Products.CMFCore.ActionInformation"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
action_type/object_api_type
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
category
</string>
</key>
<value>
<string>
object_api_type
</string>
</value>
</item>
<item>
<key>
<string>
condition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
icon
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
api_openapi
</string>
</value>
</item>
<item>
<key>
<string>
permissions
</string>
</key>
<value>
<tuple>
<string>
View
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
priority
</string>
</key>
<value>
<float>
1.0
</float>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
OpenAPI
</string>
</value>
</item>
<item>
<key>
<string>
visible
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Expression"
module=
"Products.CMFCore.Expression"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
text
</string>
</key>
<value>
<string>
string:${object_url}/ActionInformationAPI_api_openapi
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_action_information_api/DocumentTemplateItem/portal_components/document.erp5.ActionInformationAPI.py
View file @
eeafb265
...
...
@@ -120,8 +120,7 @@ class ActionInformationAPI(XMLObject):
def
handleRequest
(
self
,
request
):
portal
=
self
.
getPortalObject
()
action_filter
=
self
.
getActionReferenceValue
()
(
hyperdocument
,
actions
)
=
self
.
getTypeInfo
().
getDefaultViewFor
(
self
,
view
=
self
.
getApiTypeReference
())(
portal
,
action_filter
,
request
.
getURL
())
(
hyperdocument
,
actions
)
=
self
.
getTypeInfo
().
getDefaultViewFor
(
self
,
view
=
self
.
getApiTypeReference
())(
self
,
portal
,
request
)
response
=
request
.
RESPONSE
request_content_type
=
request
.
getHeader
(
"content-type"
)
...
...
bt5/erp5_action_information_api/SkinTemplateItem/portal_skins/erp5_action_information_api/ActionInformationAPI_api_openapi.py
0 → 100644
View file @
eeafb265
import
json
schema
=
caller
.
getTypeInfo
().
getSchema
()
schema
.
setdefault
(
"servers"
,
[]).
insert
(
0
,
{
"url"
:
caller
.
absolute_url
(),
"description"
:
caller
.
getDescription
()
})
hyperdocument
=
json
.
dumps
(
schema
)
return
(
hyperdocument
,
{})
bt5/erp5_action_information_api/SkinTemplateItem/portal_skins/erp5_action_information_api/ActionInformationAPI_api_openapi.xml
0 → 100644
View file @
eeafb265
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
caller, portal, request
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ActionInformationAPI_api_openapi
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_action_information_api/SkinTemplateItem/portal_skins/erp5_action_information_api/ActionInformationAPI_api_slap.py
View file @
eeafb265
import
json
url
=
request
.
getURL
()
base_url_absolute
=
portal
.
portal_callables
.
absolute_url
().
strip
()
base_url_relative
=
portal
.
portal_callables
.
getPath
().
strip
()
action_filter
=
caller
.
getActionReferenceValue
()
raw_action_list
=
portal
.
portal_catalog
(
portal_type
=
"Action Information"
,
action_type__uid
=
action_filter
.
getUid
()
...
...
bt5/erp5_action_information_api/SkinTemplateItem/portal_skins/erp5_action_information_api/ActionInformationAPI_api_slap.xml
View file @
eeafb265
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
portal, action_filter, url
</string>
</value>
<value>
<string>
caller, portal, request
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
bt5/erp5_action_information_api/TestTemplateItem/portal_components/test.erp5.testActionInformationAPI.py
View file @
eeafb265
...
...
@@ -58,22 +58,6 @@ class TestActionInformationAPI(ERP5TypeTestCase):
self
.
tic
()
self
.
commit
()
ai_type
=
self
.
portal
.
portal_catalog
(
portal_type
=
"Action Information"
,
action_type__uid
=
self
.
portal
.
portal_categories
.
action_type
.
object_api_type
.
getUid
(),
reference
=
"api_slap"
,
)[
0
]
self
.
web_service
=
self
.
portal
.
portal_web_services
.
newContent
(
portal_type
=
"Action Information API"
,
)
self
.
web_service
.
edit
(
api_type
=
ai_type
.
getRelativeUrl
(),
action_reference
=
self
.
object_api_value
.
getRelativeUrl
(),
)
self
.
tic
()
self
.
commit
()
portal_type_name
=
"Person"
portal_type
=
self
.
portal
.
portal_types
[
portal_type_name
]
action_id
=
"Person_updateEmail"
...
...
@@ -113,6 +97,39 @@ return {"status": 200}""")
self
.
tic
()
self
.
commit
()
def
setupAiApi
(
self
):
ai_type
=
self
.
portal
.
portal_catalog
(
portal_type
=
"Action Information"
,
action_type__uid
=
self
.
portal
.
portal_categories
.
action_type
.
object_api_type
.
getUid
(),
reference
=
"api_slap"
,
)[
0
]
self
.
web_service
=
self
.
portal
.
portal_web_services
.
newContent
(
portal_type
=
"Action Information API"
,
)
self
.
web_service
.
edit
(
api_type
=
ai_type
.
getRelativeUrl
(),
action_reference
=
self
.
object_api_value
.
getRelativeUrl
(),
)
self
.
tic
()
self
.
commit
()
def
setupOpenApi
(
self
):
ai_type
=
self
.
portal
.
portal_catalog
(
portal_type
=
"Action Information"
,
action_type__uid
=
self
.
portal
.
portal_categories
.
action_type
.
object_api_type
.
getUid
(),
reference
=
"api_openapi"
,
)[
0
]
self
.
web_service
=
self
.
portal
.
portal_web_services
.
newContent
(
portal_type
=
"Pet Store Open API"
,
)
self
.
web_service
.
edit
(
api_type
=
ai_type
.
getRelativeUrl
(),
)
self
.
tic
()
self
.
commit
()
def
loggedInRequest
(
self
,
path
,
method
,
content
):
return
self
.
publish
(
self
.
web_service
.
getPath
()
+
path
,
...
...
@@ -124,7 +141,9 @@ return {"status": 200}""")
user
=
"ERP5TypeTestCase"
)
def
test_hyperdocument
(
self
):
def
test_hyperdocument_script
(
self
):
self
.
setupAiApi
()
response
=
self
.
loggedInRequest
(
"/api"
,
"GET"
,
{})
response_json
=
json
.
loads
(
response
.
getBody
())
...
...
@@ -133,7 +152,9 @@ return {"status": 200}""")
self
.
assertTrue
(
"Person_updateEmail/getInputJSONSchema"
in
response_json
[
"links"
][
0
][
"$schemaRequest"
])
self
.
assertTrue
(
"Person_updateEmail/getOutputJSONSchema"
in
response_json
[
"links"
][
0
][
"$schemaResponse"
])
def
test_update
(
self
):
def
test_update_script
(
self
):
self
.
setupAiApi
()
person
=
self
.
portal
.
person_module
.
newContent
(
id
=
"%s_person"
%
self
.
current_id
,
portal_type
=
"Person"
,
...
...
@@ -152,3 +173,11 @@ return {"status": 200}""")
self
.
assertEqual
(
response
.
getBody
(),
json
.
dumps
({
"status"
:
200
},
indent
=
2
))
self
.
assertEqual
(
response
.
getStatus
(),
200
)
self
.
assertEqual
(
person
.
getDefaultEmailUrlString
(),
"alice@looking.glass"
)
def
test_hyperdocument_openapi
(
self
):
self
.
setupOpenApi
()
response
=
self
.
loggedInRequest
(
"/api"
,
"GET"
,
{})
response_json
=
json
.
loads
(
response
.
getBody
())
self
.
assertEqual
(
response_json
[
"openapi"
],
"3.0.2"
)
bt5/erp5_action_information_api/bt/template_action_path_list
View file @
eeafb265
Action Information API | api_openapi
Action Information API | api_slap
Action Information API | view
\ No newline at end of file
bt5/erp5_action_information_api/bt/test_dependency_list
View file @
eeafb265
erp5_full_text_mroonga_catalog
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_open_api_ui_test
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment