MCPcopy
hub / github.com/encode/starlette / test_schema_generation

Function test_schema_generation

tests/test_schemas.py:133–188  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131
132
133def test_schema_generation() -> None:
134 schema = schemas.get_schema(routes=app.routes)
135 assert schema == {
136 "openapi": "3.0.0",
137 "info": {"title": "Example API", "version": "1.0"},
138 "paths": {
139 "/orgs": {
140 "get": {
141 "responses": {
142 200: {
143 "description": "A list of organisations.",
144 "examples": [{"name": "Foo Corp."}, {"name": "Acme Ltd."}],
145 }
146 }
147 },
148 "post": {
149 "responses": {
150 200: {
151 "description": "An organisation.",
152 "examples": {"name": "Foo Corp."},
153 }
154 }
155 },
156 },
157 "/regular-docstring-and-schema": {
158 "get": {"responses": {200: {"description": "This is included in the schema."}}}
159 },
160 "/subapp/subapp-endpoint": {
161 "get": {"responses": {200: {"description": "This endpoint is part of a subapp."}}}
162 },
163 "/subapp2/subapp-endpoint": {
164 "get": {"responses": {200: {"description": "This endpoint is part of a subapp."}}}
165 },
166 "/users": {
167 "get": {
168 "responses": {
169 200: {
170 "description": "A list of users.",
171 "examples": [{"username": "tom"}, {"username": "lucy"}],
172 }
173 }
174 },
175 "post": {"responses": {200: {"description": "A user.", "examples": {"username": "tom"}}}},
176 },
177 "/users/{id}": {
178 "get": {
179 "responses": {
180 200: {
181 "description": "A user.",
182 "examples": {"username": "tom"},
183 }
184 }
185 },
186 },
187 },
188 }
189
190

Callers

nothing calls this directly

Calls 1

get_schemaMethod · 0.45

Tested by

no test coverage detected