Option --config - file operation¶
Here focus on a small part --- a feature of one specific option --config under sub-command run.
UML¶
- Object
MockHTTPServeruses functionload_configto get all detail settings. - Data object
APIConfigprovides function to read and deserialize the configuration file content. - Currently, it only supports parsing YAML file by object
YAML.
Extension¶
Here demonstrate how to extend this feature to parse other file formatter.
- File operation
If you want to use other file formatter, e.g., JSON, you could extend the base class of file operation _BaseFileOperation
to implement needed features.
| fake_api_server._utils.file.operation | |
|---|---|
Because currently it won't have option in command line to control which way it should use to serialize or deserialize configuration file, so we need to manually modify the code to use it.
Finally, we could use JSON type file as our configuration formatter.