Drop role assignment schema hardcode
Those are now present in keystone. Change-Id: I1f0b74c64d2e877ef23eeee6ddb59c53e5c85cea
This commit is contained in:
parent
8995fa42b2
commit
8bfc8967d3
@ -256,6 +256,17 @@ class JsonSchemaParser:
|
||||
if type_ == "null":
|
||||
obj = PrimitiveNull()
|
||||
return obj
|
||||
if not type_ and "properties" in schema:
|
||||
# Sometimes services forget to set "type=object"
|
||||
return self.parse_object(
|
||||
schema,
|
||||
results,
|
||||
name=name,
|
||||
parent=parent,
|
||||
min_ver=min_ver,
|
||||
max_ver=max_ver,
|
||||
ignore_read_only=ignore_read_only,
|
||||
)
|
||||
if "oneOf" in schema:
|
||||
return self.parse_oneOf(
|
||||
schema,
|
||||
@ -280,17 +291,6 @@ class JsonSchemaParser:
|
||||
parent=parent,
|
||||
ignore_read_only=ignore_read_only,
|
||||
)
|
||||
if not type_ and "properties" in schema:
|
||||
# Sometimes services forget to set "type=object"
|
||||
return self.parse_object(
|
||||
schema,
|
||||
results,
|
||||
name=name,
|
||||
parent=parent,
|
||||
min_ver=min_ver,
|
||||
max_ver=max_ver,
|
||||
ignore_read_only=ignore_read_only,
|
||||
)
|
||||
if schema == {}:
|
||||
# `{}` is `Any` according to jsonschema
|
||||
return PrimitiveAny()
|
||||
@ -506,7 +506,6 @@ class JsonSchemaParser:
|
||||
# object present few times
|
||||
pass
|
||||
else:
|
||||
logging.error(f"replace {obj.reference.name}")
|
||||
# Structure with the same name is already present. Prefix the
|
||||
# new one with the parent name
|
||||
if parent and name:
|
||||
@ -518,6 +517,9 @@ class JsonSchemaParser:
|
||||
raise NotImplementedError
|
||||
else:
|
||||
obj.reference.name = new_name
|
||||
logging.info(
|
||||
f"rename {obj.reference.name} to {new_name}"
|
||||
)
|
||||
results.append(obj)
|
||||
|
||||
return obj
|
||||
|
@ -219,31 +219,31 @@ ROLE_ASSIGNMENTS_SCHEMA: dict[str, Any] = {
|
||||
|
||||
#: Role assignment query parameters common for LIST and HEAD
|
||||
ROLE_ASSIGNMENTS_QUERY_PARAMETERS: dict[str, Any] = {
|
||||
"role_assignments_group_id": {
|
||||
"role_assignments_group.id": {
|
||||
"in": "query",
|
||||
"name": "group.id",
|
||||
"description": "Filters the response by a group ID.",
|
||||
"schema": {"type": "string", "format": "uuid"},
|
||||
},
|
||||
"role_assignments_role_id": {
|
||||
"role_assignments_role.id": {
|
||||
"in": "query",
|
||||
"name": "role.id",
|
||||
"description": "Filters the response by a role ID.",
|
||||
"schema": {"type": "string", "format": "uuid"},
|
||||
},
|
||||
"role_assignments_user_id": {
|
||||
"role_assignments_user.id": {
|
||||
"in": "query",
|
||||
"name": "user.id",
|
||||
"description": "Filters the response by a user ID.",
|
||||
"schema": {"type": "string", "format": "uuid"},
|
||||
},
|
||||
"role_assignments_scope_domain_id": {
|
||||
"role_assignments_scope.domain.id": {
|
||||
"in": "query",
|
||||
"name": "scope.domain.id",
|
||||
"description": "Filters the response by a domain ID.",
|
||||
"schema": {"type": "string", "format": "uuid"},
|
||||
},
|
||||
"role_assignments_scope_project_id": {
|
||||
"role_assignments_scope.project.id": {
|
||||
"in": "query",
|
||||
"name": "scope.project.id",
|
||||
"description": "Filters the response by a project ID.",
|
||||
@ -301,28 +301,6 @@ def _post_process_operation_hook(
|
||||
|
||||
if ref not in [x.ref for x in operation_spec.parameters]:
|
||||
operation_spec.parameters.append(ParameterSchema(ref=ref))
|
||||
elif operationId == "role_assignments:get":
|
||||
for map in [
|
||||
ROLE_ASSIGNMENTS_QUERY_PARAMETERS,
|
||||
ROLE_ASSIGNMENT_LIST_PARAMETERS,
|
||||
]:
|
||||
for key, val in map.items():
|
||||
openapi_spec.components.parameters.setdefault(
|
||||
key, ParameterSchema(**val)
|
||||
)
|
||||
ref = f"#/components/parameters/{key}"
|
||||
|
||||
if ref not in [x.ref for x in operation_spec.parameters]:
|
||||
operation_spec.parameters.append(ParameterSchema(ref=ref))
|
||||
elif operationId == "role_assignments:head":
|
||||
for key, val in ROLE_ASSIGNMENTS_QUERY_PARAMETERS.items():
|
||||
openapi_spec.components.parameters.setdefault(
|
||||
key, ParameterSchema(**val)
|
||||
)
|
||||
ref = f"#/components/parameters/{key}"
|
||||
|
||||
if ref not in [x.ref for x in operation_spec.parameters]:
|
||||
operation_spec.parameters.append(ParameterSchema(ref=ref))
|
||||
|
||||
|
||||
def _get_schema_ref(
|
||||
@ -365,11 +343,6 @@ def _get_schema_ref(
|
||||
)
|
||||
ref = f"#/components/schemas/{name}"
|
||||
|
||||
elif name == "Role_AssignmentsGetResponse":
|
||||
openapi_spec.components.schemas.setdefault(
|
||||
name, TypeSchema(**ROLE_ASSIGNMENTS_SCHEMA)
|
||||
)
|
||||
ref = f"#/components/schemas/{name}"
|
||||
# Role Inferences
|
||||
elif name == "Role_InferencesGetResponse":
|
||||
openapi_spec.components.schemas.setdefault(
|
||||
|
Loading…
x
Reference in New Issue
Block a user