mirror of
https://github.com/hoshikawa2/OCI_API_Gateway_Automation2.git
synced 2026-03-03 16:09:36 +00:00
Correção. Não estava ocorrendo a validação de schema_body_validation para open api 3, pois estava validando somente quando a especificação estava configurada para propriedades diretamente. Caso as validações fossem declaradas em schema (requestBody/Content/application/json/schema/$ref/#components/schemas) a validação em authAPI não executava (simplesmente ignora a validação).
É necessário re-executar o applyValidationAPI para reimplantar as APIs pois precisa acertar o schema_body_validation dos headers.
This commit is contained in:
Binary file not shown.
@@ -516,7 +516,12 @@ def process_api_spec(api_id, compartmentId, environment, swagger, functionId, ho
|
||||
API_NAME = fullSpec["info"]["title"]
|
||||
if (version == "3"):
|
||||
try:
|
||||
SCHEMA_BODY_VALIDATION = str(fullSpec["paths"][spec["path"]][str(spec["methods"][0]).lower()]["requestBody"]["content"]["application/json"])
|
||||
try:
|
||||
reference = str(fullSpec["paths"][spec["path"]][str(spec["methods"][0]).lower()]["requestBody"]["content"]["application/json"]["schema"]["$ref"]).replace("#/components/schemas/", "")
|
||||
SCHEMA_BODY_VALIDATION = reference + "," + api_id
|
||||
except:
|
||||
reference = str(fullSpec["paths"][spec["path"]][str(spec["methods"][0]).lower()]["requestBody"]["content"]["application/json"])
|
||||
SCHEMA_BODY_VALIDATION = reference
|
||||
CONTENT_TYPE = "application/json"
|
||||
except:
|
||||
SCHEMA_BODY_VALIDATION = ""
|
||||
|
||||
@@ -124,7 +124,7 @@ def handler(ctx, data: io.BytesIO = None):
|
||||
# Validate API spec
|
||||
if (body_schema_validation != None):
|
||||
if (".apigatewayapi." not in header["body_schema_validation"]):
|
||||
# Version OpenAPI 3
|
||||
# Com validacao direto por propriedades (sem schemas e referencias)
|
||||
try:
|
||||
validate(body, body_schema_validation["schema"])
|
||||
return response.Response(
|
||||
@@ -162,7 +162,7 @@ def handler(ctx, data: io.BytesIO = None):
|
||||
response_data=rdata
|
||||
)
|
||||
else:
|
||||
# Version Swagger 2
|
||||
# Com schema de validação - Tanto swagger como Open API 3
|
||||
try:
|
||||
bravado_config = {
|
||||
'validate_swagger_spec': False,
|
||||
@@ -175,7 +175,10 @@ def handler(ctx, data: io.BytesIO = None):
|
||||
api_spec = apigateway_client.get_api_content(contents[1])
|
||||
spec_dict = json.loads(api_spec.data.content)
|
||||
spec = Spec.from_dict(spec_dict, config=bravado_config)
|
||||
schema = spec_dict["definitions"][contents[0]]
|
||||
try:
|
||||
schema = spec_dict["definitions"][contents[0]]
|
||||
except:
|
||||
schema = spec_dict["components"]["schemas"][contents[0]]
|
||||
validate_object(spec, schema, body)
|
||||
except (Exception) as ex3:
|
||||
error_msg = beautify_str(str(ex3))
|
||||
|
||||
Reference in New Issue
Block a user