diff --git a/fastapi_code_generator/parser.py b/fastapi_code_generator/parser.py index e299b01..3a9d60c 100644 --- a/fastapi_code_generator/parser.py +++ b/fastapi_code_generator/parser.py @@ -238,8 +238,12 @@ def __init__( self.imports_for_fastapi: Imports = Imports() self.data_types: List[DataType] = [] - def parse_info(self) -> Optional[List[Dict[str, List[str]]]]: - return self.raw_obj.get('info') + def parse_info(self) -> Optional[Dict[str, Any]]: + result = self.raw_obj.get('info', {}).copy() + servers = self.raw_obj.get('servers') + if servers: + result['servers'] = servers + return result or None def parse_parameters(self, parameters: ParameterObject, path: List[str]) -> None: super().parse_parameters(parameters, path) diff --git a/tests/data/expected/openapi/default_template/body_and_parameters/main.py b/tests/data/expected/openapi/default_template/body_and_parameters/main.py index 27ae9db..9e46dec 100644 --- a/tests/data/expected/openapi/default_template/body_and_parameters/main.py +++ b/tests/data/expected/openapi/default_template/body_and_parameters/main.py @@ -24,6 +24,7 @@ title='Swagger Petstore', license={'name': 'MIT'}, description='This description is for testing\nmulti-line\ndescription\n', + servers=[{'url': 'http://petstore.swagger.io/v1'}], ) diff --git a/tests/data/expected/openapi/default_template/content_in_parameters/main.py b/tests/data/expected/openapi/default_template/content_in_parameters/main.py index b691f35..e08f554 100644 --- a/tests/data/expected/openapi/default_template/content_in_parameters/main.py +++ b/tests/data/expected/openapi/default_template/content_in_parameters/main.py @@ -15,6 +15,7 @@ title='Swagger Petstore', license={'name': 'MIT'}, description='This description is for testing\nmulti-line\ndescription\n', + servers=[{'url': 'http://petstore.swagger.io/v1'}], ) diff --git a/tests/data/expected/openapi/default_template/oas_response_reference/main.py b/tests/data/expected/openapi/default_template/oas_response_reference/main.py index f8f8d8d..9bc5ffe 100644 --- a/tests/data/expected/openapi/default_template/oas_response_reference/main.py +++ b/tests/data/expected/openapi/default_template/oas_response_reference/main.py @@ -15,6 +15,7 @@ title='Swagger Petstore', license={'name': 'MIT'}, description='This description is for testing\nmulti-line\ndescription\n', + servers=[{'url': 'http://petstore.swagger.io/v1'}], ) diff --git a/tests/data/expected/openapi/default_template/simple/main.py b/tests/data/expected/openapi/default_template/simple/main.py index ee4b3ba..c1b992d 100644 --- a/tests/data/expected/openapi/default_template/simple/main.py +++ b/tests/data/expected/openapi/default_template/simple/main.py @@ -15,6 +15,7 @@ title='Swagger Petstore', license={'name': 'MIT'}, description='This description is for testing\nmulti-line\ndescription\n', + servers=[{'url': 'http://petstore.swagger.io/v1'}], ) diff --git a/tests/data/expected/openapi/remote_ref/body_and_parameters/main.py b/tests/data/expected/openapi/remote_ref/body_and_parameters/main.py index 7050211..3e6be4f 100644 --- a/tests/data/expected/openapi/remote_ref/body_and_parameters/main.py +++ b/tests/data/expected/openapi/remote_ref/body_and_parameters/main.py @@ -15,6 +15,7 @@ title='Swagger Petstore', license={'name': 'MIT'}, description='This description is for testing\nmulti-line\ndescription\n', + servers=[{'url': 'http://petstore.swagger.io/v1'}], )