Stoobly / stoobly-agent

Record, mock, and test HTTP/HTTPS requests. CLI agent for Stoobly.
Other
6 stars 0 forks source link

OAS Import Command for Stoobly CLI #212 #213

Closed tylerbhadra closed 3 months ago

tylerbhadra commented 3 months ago

Changes Made:

Extended OAS adapter to handle parsing of static and aliased path segments + response bodies in OpenAPI description files and generation of response_header_name and response_param_name resources. Additionally, added new resource classes for component names (header_names, body_param_names, query_param_names, response_param_names, response_header_names), a new endpoint importer service (endpoints_import_service.py), and the endpoint import cli command in endpoint_cli.py.

Expected Benefits:

Allows users to more easily create and maintain mocks by importing OAS directly into Stoobly using the endpoint import cli command #212

Additional Notes:

The endpoint import command currently does not work with OpenAPI files that include HEAD, PATCH and TRACE operations since those do not seem to be supported/allowed values for the method parameter in the request body for the POST /endpoints api route.

tylerbhadra commented 3 months ago

Changes Made:

Extended OAS adapter to handle parsing of static and aliased path segments as well as response_header_name and response_param_name resources from response bodies in OpenAPI description files + fixed bug in __dereference() function related to incomplete param extraction from nested references in array type schema objects. Additionally, added new resource classes for component names (header_names, body_param_names, query_param_names, response_param_names, response_header_names), a new endpoint importer service (endpoints_import_service.py), and the endpoint import cli command in endpoint_cli.py.

Expected Benefits:

Allows users to more easily create and maintain mocks by importing OAS directly into Stoobly using the endpoint import cli command [#212]

Testing:

Modified the openapi_endpoint_adapter_additional_props_test.py , openapi_endpoint_adapter_missing_info_test.py , openapi_endpoint_adapter_missing_oauth2_scopes_test.py , openapi_endpoint_adapter_missing_servers_test.py , and openapi_endpoint_adapter_test.py to expect updated output that reflects the changes made to the default port and host values when there is a missing servers list, as well as the newly added response_header_names and response_param_names values.

Additional Notes:

The endpoint import command currently does not work with OpenAPI files that include HEAD, PATCH and TRACE operations since those do not seem to be supported/allowed values for the method parameter in the request body for the POST /endpoints api route. Also, the OAS adapter does not currently support OpenAPI v2.0 which means endpoint import only works with versions 3.0 and 3.1 of OpenAPI.

Jvlythical commented 3 months ago

So far looks great!

tylerbhadra commented 3 months ago

Made suggested changes

tylerbhadra commented 3 months ago

Made suggested changes/fixes in OAS adapter and endpoints_import_service