kytos-ng / kytos

Kytos SDN Platform. Kytos is designed to be easy to install, use, develop and share Network Apps (NApps).
https://kytos-ng.github.io/
MIT License
3 stars 8 forks source link

feat: moved `@validate` decorator from `mef_eline` to core as `@validate_openapi` #352

Closed viniarck closed 1 year ago

viniarck commented 1 year ago

Closes #261 Closes #346

Summary

See updated changelog file.

Notice also that FlaskOpenAPIRequest is still being used since this change is being rolled out gradually. In the future, it'll be replaced by a starlette request instance. From this point forward any napps can use the @validate_openapi to o validate OpenAPI routes.

Local Tests

{
    "circuit_id": "f5c649b0c2964e"
}
+from kytos.core.helpers import listen_to, load_spec, validate_openapi

-    @validate(spec)
+    @validate_openapi(spec)
{
    "code": 400,
    "description": "The request body contains invalid API data. 1 is not of type 'string' for field uni_a/interface_id.",
    "name": "Bad Request"
}

End-to-End Tests

I've explored it locally, I'll rerun this e2e tests here https://github.com/kytos-ng/kytos-end-to-end-tests/pull/218, once I open a new PR on mef_eline soon.