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
Carlos Ramos Carreño
erp5
Commits
7c2284d4
Commit
7c2284d4
authored
Jan 28, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
open_api: py3
parent
1c44edc1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
bt5/erp5_open_api/DocumentTemplateItem/portal_components/document.erp5.OpenAPITypeInformation.py
...portal_components/document.erp5.OpenAPITypeInformation.py
+5
-2
bt5/erp5_open_api/TestTemplateItem/portal_components/test.erp5.testOpenAPIService.py
...ateItem/portal_components/test.erp5.testOpenAPIService.py
+12
-12
No files found.
bt5/erp5_open_api/DocumentTemplateItem/portal_components/document.erp5.OpenAPITypeInformation.py
View file @
7c2284d4
...
...
@@ -90,7 +90,7 @@ ModuleSecurityInfo(__name__).declarePublic(
)
# On python2, make sure we use UTF-8 strings for the json schemas, so that we don't
# have
ugly u' prefix
s in the reprs. This also transforms the collections.OrderedDict
# have
ugly u' prefixe
s in the reprs. This also transforms the collections.OrderedDict
# to simple dicts, because the former also have an ugly representation.
# http://stackoverflow.com/a/13105359
if
six
.
PY2
:
...
...
@@ -340,7 +340,10 @@ class OpenAPITypeInformation(ERP5TypeInformation):
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
def
getSchema
(
self
):
stream
=
io
.
BytesIO
(
self
.
getTextContent
()
or
b'{}'
)
text_content
=
self
.
getTextContent
()
or
'{}'
if
six
.
PY3
:
text_content
=
text_content
.
encode
()
stream
=
io
.
BytesIO
(
text_content
)
if
self
.
getContentType
()
==
'application/x-yaml'
:
try
:
import
yaml
# pylint:disable=import-error
...
...
bt5/erp5_open_api/TestTemplateItem/portal_components/test.erp5.testOpenAPIService.py
View file @
7c2284d4
...
...
@@ -39,7 +39,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class
OpenAPITestCase
(
ERP5TypeTestCase
):
_type_id
=
NotImplemented
# type: str
_open_api_schema
=
NotImplemented
# type:
bytes
_open_api_schema
=
NotImplemented
# type:
str
_open_api_schema_content_type
=
'application/json'
_public_api
=
True
...
...
@@ -375,7 +375,7 @@ class TestOpenAPIServicePetController(OpenAPIPetStoreTestCase):
class
TestOpenAPIServiceYaml
(
OpenAPITestCase
):
_type_id
=
'Test Open API YAML'
_open_api_schema_content_type
=
'application/x-yaml'
_open_api_schema
=
b
'''
_open_api_schema
=
'''
openapi: 3.0.3
info:
title: TestOpenAPIServiceYaml
...
...
@@ -456,7 +456,7 @@ class TestPathParameterSerialization(OpenAPITestCase):
}
}
}
})
.
encode
()
})
def
test_primitive_parameter_serialization
(
self
):
self
.
addPythonScript
(
...
...
@@ -532,7 +532,7 @@ class TestQueryParameterSerialization(OpenAPITestCase):
}
}
}
})
.
encode
()
})
def
test_array_parameter_serialization
(
self
):
self
.
addPythonScript
(
...
...
@@ -707,7 +707,7 @@ class TestOpenAPINonAsciiParameters(OpenAPIPetStoreTestCase):
class
TestOpenAPICommonParameters
(
OpenAPIPetStoreTestCase
):
_type_id
=
'Test Open API Common Parameters'
_open_api_schema
=
(
b
'''
'''
{
"openapi": "3.0.3",
"info": {
...
...
@@ -718,7 +718,7 @@ class TestOpenAPICommonParameters(OpenAPIPetStoreTestCase):
'''
# https://swagger.io/docs/specification/describing-parameters/#common-for-path
b
'''
'''
"/common-for-path": {
"parameters": [
{
...
...
@@ -749,7 +749,7 @@ class TestOpenAPICommonParameters(OpenAPIPetStoreTestCase):
},'''
# https://swagger.io/docs/specification/describing-parameters/#common-for-various-paths
b
'''
'''
"/common-for-various-paths": {
"get": {
"operationId": "testGET2",
...
...
@@ -761,7 +761,7 @@ class TestOpenAPICommonParameters(OpenAPIPetStoreTestCase):
'''
# here we also excercice $refs in parameter schemas
b
'''
'''
"$ref": "#/components/schemas/custom-number"
}
},
...
...
@@ -781,7 +781,7 @@ class TestOpenAPICommonParameters(OpenAPIPetStoreTestCase):
# https://spec.openapis.org/oas/v3.1.0#fixed-fields-6
# $refs: Allows for a referenced definition of this path item.
# The referenced structure MUST be in the form of a Path Item Object.
b
'''
'''
"/alias": {
"$ref": "#/paths/~1common-for-path"
}
...
...
@@ -895,7 +895,7 @@ class TestOpenAPIMissingParameters(OpenAPIPetStoreTestCase):
}
}
}
})
.
encode
()
})
def
test_required_query
(
self
):
self
.
addPythonScript
(
...
...
@@ -980,7 +980,7 @@ class TestOpenAPIErrorHandling(OpenAPIPetStoreTestCase):
self
.
addPythonScript
(
'TestPetStoreOpenAPI_findPetsByStatus'
,
'status'
,
'1/0'
,
'1/
/
0'
,
)
response
=
self
.
publish
(
self
.
connector
.
getPath
()
+
'/pet/findByStatus?status=available'
)
...
...
@@ -1097,7 +1097,7 @@ class TestPathParameterAndAcquisition(OpenAPIPetStoreTestCase):
"""
def
afterSetUp
(
self
):
super
(
TestPathParameterAndAcquisition
,
self
).
afterSetUp
()
if
not
'789'
in
self
.
portal
.
portal_web_services
.
objectIds
():
if
'789'
not
in
self
.
portal
.
portal_web_services
.
objectIds
():
self
.
portal
.
portal_web_services
.
newContent
(
id
=
'789'
,
portal_type
=
self
.
portal
.
portal_web_services
.
allowedContentTypes
()
...
...
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