Skip to content

Commit

Permalink
Fix OpenAPI return value inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlycoconuts committed Mar 9, 2022
1 parent 60d5e04 commit 07b73e9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 198 deletions.
14 changes: 10 additions & 4 deletions api/api/openapi.bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/IdObject_1'
$ref: '#/components/schemas/RouterIdObject'
description: OK
"400":
description: Invalid project_id or router_id
Expand Down Expand Up @@ -682,7 +682,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/IdObject_1'
$ref: '#/components/schemas/RouterIdObject'
description: OK
"400":
description: Invalid project_id or router_id
Expand Down Expand Up @@ -2520,8 +2520,14 @@ components:
- environment_name
- name
type: object
IdObject_1:
$ref: '#/components/schemas/IdObject'
RouterIdObject:
example:
router_id: 0
properties:
router_id:
format: int32
type: integer
type: object
RouterIdAndVersion:
example:
router_id: 0
Expand Down
11 changes: 7 additions & 4 deletions api/api/specs/routers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/IdObject"
$ref: "#/components/schemas/RouterIdObject"
400:
description: "Invalid project_id or router_id"
404:
Expand Down Expand Up @@ -212,7 +212,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/IdObject"
$ref: "#/components/schemas/RouterIdObject"
400:
description: "Invalid project_id or router_id"
404:
Expand Down Expand Up @@ -390,8 +390,11 @@ paths:

components:
schemas:
IdObject:
$ref: "common.yaml#/components/schemas/IdObject"
RouterIdObject:
type: object
properties:
router_id:
$ref: "common.yaml#/components/schemas/Id"

RouterIdAndVersion:
type: object
Expand Down
8 changes: 4 additions & 4 deletions sdk/tests/router/router_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_create_router(turing_api, active_project, actual, expected, use_google_
"actual,expected", [
pytest.param(
1,
turing.generated.models.IdObject(id=1)
turing.generated.models.RouterIdObject(router_id=1)
)
]
)
Expand Down Expand Up @@ -223,8 +223,8 @@ def test_undeploy_router(turing_api, active_project, generic_router, generic_rou

base_router = turing.Router.from_open_api(generic_router)

expected = turing.generated.models.IdObject(
id=1,
expected = turing.generated.models.RouterIdObject(
router_id=1,
)

responses.add(
Expand All @@ -236,7 +236,7 @@ def test_undeploy_router(turing_api, active_project, generic_router, generic_rou
)

response = base_router.undeploy()
assert base_router.id == response['id']
assert base_router.id == response['router_id']


@responses.activate
Expand Down
10 changes: 5 additions & 5 deletions sdk/turing/generated/api/router_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
validate_and_convert_types
)
from turing.generated.model.event import Event
from turing.generated.model.id_object import IdObject
from turing.generated.model.router_config import RouterConfig
from turing.generated.model.router_details import RouterDetails
from turing.generated.model.router_id_and_version import RouterIdAndVersion
from turing.generated.model.router_id_object import RouterIdObject
from turing.generated.model.router_version import RouterVersion


Expand Down Expand Up @@ -324,7 +324,7 @@ def __projects_project_id_routers_router_id_delete(
async_req (bool): execute request asynchronously
Returns:
IdObject
RouterIdObject
If the method is called asynchronously, returns the request
thread.
"""
Expand Down Expand Up @@ -355,7 +355,7 @@ def __projects_project_id_routers_router_id_delete(

self.projects_project_id_routers_router_id_delete = _Endpoint(
settings={
'response_type': (IdObject,),
'response_type': (RouterIdObject,),
'auth': [],
'endpoint_path': '/projects/{project_id}/routers/{router_id}',
'operation_id': 'projects_project_id_routers_router_id_delete',
Expand Down Expand Up @@ -965,7 +965,7 @@ def __projects_project_id_routers_router_id_undeploy_post(
async_req (bool): execute request asynchronously
Returns:
IdObject
RouterIdObject
If the method is called asynchronously, returns the request
thread.
"""
Expand Down Expand Up @@ -996,7 +996,7 @@ def __projects_project_id_routers_router_id_undeploy_post(

self.projects_project_id_routers_router_id_undeploy_post = _Endpoint(
settings={
'response_type': (IdObject,),
'response_type': (RouterIdObject,),
'auth': [],
'endpoint_path': '/projects/{project_id}/routers/{router_id}/undeploy',
'operation_id': 'projects_project_id_routers_router_id_undeploy_post',
Expand Down
179 changes: 0 additions & 179 deletions sdk/turing/generated/model/id_object1.py

This file was deleted.

2 changes: 1 addition & 1 deletion sdk/turing/generated/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from turing.generated.model.generic_ensembler import GenericEnsembler
from turing.generated.model.generic_sink import GenericSink
from turing.generated.model.id_object import IdObject
from turing.generated.model.id_object1 import IdObject1
from turing.generated.model.kafka_config import KafkaConfig
from turing.generated.model.label import Label
from turing.generated.model.log_level import LogLevel
Expand All @@ -71,6 +70,7 @@
from turing.generated.model.router_details_all_of import RouterDetailsAllOf
from turing.generated.model.router_ensembler_config import RouterEnsemblerConfig
from turing.generated.model.router_id_and_version import RouterIdAndVersion
from turing.generated.model.router_id_object import RouterIdObject
from turing.generated.model.router_status import RouterStatus
from turing.generated.model.router_version import RouterVersion
from turing.generated.model.router_version_log_config import RouterVersionLogConfig
Expand Down
2 changes: 1 addition & 1 deletion sdk/turing/router/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def delete(cls, router_id: int) -> int:
:param router_id: router_id of the router to be deleted
:return: router_id of the deleted router
"""
return turing.active_session.delete_router(router_id=router_id).id
return turing.active_session.delete_router(router_id=router_id).router_id

@classmethod
def get(cls, router_id: int) -> 'Router':
Expand Down

0 comments on commit 07b73e9

Please sign in to comment.