|
1 |
| -from typing import Any, Dict, List, Optional |
| 1 | +from typing import Any, Dict |
2 | 2 |
|
3 | 3 |
|
4 | 4 | def get_single_param_type_from_schema(param_schema: Dict[str, Any]) -> str:
|
@@ -100,47 +100,12 @@ def clean_schema_for_display(schema: Dict[str, Any]) -> Dict[str, Any]:
|
100 | 100 | return schema
|
101 | 101 |
|
102 | 102 |
|
103 |
| -def extract_model_examples_from_components( |
104 |
| - model_name: str, openapi_schema: Dict[str, Any] |
105 |
| -) -> Optional[List[Dict[str, Any]]]: |
106 |
| - """ |
107 |
| - Extract examples from a model definition in the OpenAPI components. |
108 |
| -
|
109 |
| - Args: |
110 |
| - model_name: The name of the model to extract examples from |
111 |
| - openapi_schema: The full OpenAPI schema |
112 |
| -
|
113 |
| - Returns: |
114 |
| - List of example dictionaries if found, None otherwise |
115 |
| - """ |
116 |
| - if "components" not in openapi_schema or "schemas" not in openapi_schema["components"]: |
117 |
| - return None |
118 |
| - |
119 |
| - if model_name not in openapi_schema["components"]["schemas"]: |
120 |
| - return None |
121 |
| - |
122 |
| - schema = openapi_schema["components"]["schemas"][model_name] |
123 |
| - |
124 |
| - # Look for examples in the schema |
125 |
| - examples = None |
126 |
| - |
127 |
| - # Check for examples field directly (OpenAPI 3.1.0+) |
128 |
| - if "examples" in schema: |
129 |
| - examples = schema["examples"] |
130 |
| - # Check for example field (older OpenAPI versions) |
131 |
| - elif "example" in schema: |
132 |
| - examples = [schema["example"]] |
133 |
| - |
134 |
| - return examples |
135 |
| - |
136 |
| - |
137 | 103 | def generate_example_from_schema(schema: Dict[str, Any]) -> Any:
|
138 | 104 | """
|
139 | 105 | Generate a simple example response from a JSON schema.
|
140 | 106 |
|
141 | 107 | Args:
|
142 | 108 | schema: The JSON schema to generate an example from
|
143 |
| - model_name: Optional model name for special handling |
144 | 109 |
|
145 | 110 | Returns:
|
146 | 111 | An example object based on the schema
|
|
0 commit comments