Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb committed Apr 15, 2022
1 parent f443e7c commit 1111b4d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 62 deletions.
122 changes: 61 additions & 61 deletions tests/test_docs/tutorial/routing/test_tutorial002.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,109 +6,109 @@

def test_openapi() -> None:
expected_openapi: Dict[str, Any] = {
"openapi": "3.0.3",
"components": {
"schemas": {
"HTTPValidationError": {
"properties": {
"detail": {
"items": {"$ref": "#/components/schemas/ValidationError"},
"title": "Detail",
"type": "array",
}
},
"title": "HTTPValidationError",
"type": "object",
},
"Item": {
"properties": {
"name": {"title": "Name", "type": "string"},
"price": {"title": "Price", "type": "number"},
},
"required": ["name", "price"],
"title": "Item",
"type": "object",
},
"ValidationError": {
"properties": {
"loc": {
"items": {
"oneOf": [{"type": "string"}, {"type": "integer"}]
},
"title": "Location",
"type": "array",
},
"msg": {"title": "Message", "type": "string"},
"type": {"title": "Error Type", "type": "string"},
},
"required": ["loc", "msg", "type"],
"title": "ValidationError",
"type": "object",
},
}
},
"info": {"title": "API", "version": "0.1.0"},
"openapi": "3.0.3",
"paths": {
"/v1/items": {
"get": {
"deprecated": True,
"description": "The **items** operation",
"responses": {
"404": {"description": "Item not found"},
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/Item"
},
"type": "object",
}
}
},
"description": "OK",
},
"404": {"description": "Item not found"},
},
"tags": ["v1", "items", "read"],
"summary": "List all items",
"description": "The **items** operation",
"deprecated": True,
"tags": ["v1", "items", "read"],
},
"post": {
"description": "Documentation from docstrings!\nYou can use any valid markdown, for example lists:\n\n- Point 1\n- Point 2",
"requestBody": {
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Item"}
}
},
"required": True,
},
"responses": {
"404": {"description": "Item not found"},
"204": {"description": "Success"},
"200": {
"description": "OK",
"content": {"application/json": {}},
"description": "OK",
},
"204": {"description": "Success"},
"404": {"description": "Item not found"},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
"description": "Validation Error",
},
},
"tags": ["v1", "items", "write"],
"description": "Documentation from docstrings!\n You can use any valid markdown, for example lists:\n\n - Point 1\n - Point 2\n ",
"requestBody": {
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Item"}
}
},
"required": True,
},
"servers": [
{"url": "https://us-east-1.example.com"},
{"url": "http://127.0.0.1:8000"},
],
"tags": ["v1", "items", "write"],
},
"servers": [{"url": "http://127.0.0.1:8000"}],
}
},
"components": {
"schemas": {
"Item": {
"title": "Item",
"required": ["name", "price"],
"type": "object",
"properties": {
"name": {"title": "Name", "type": "string"},
"price": {"title": "Price", "type": "number"},
},
},
"ValidationError": {
"title": "ValidationError",
"required": ["loc", "msg", "type"],
"type": "object",
"properties": {
"loc": {
"title": "Location",
"type": "array",
"items": {
"oneOf": [{"type": "string"}, {"type": "integer"}]
},
},
"msg": {"title": "Message", "type": "string"},
"type": {"title": "Error Type", "type": "string"},
},
},
"HTTPValidationError": {
"title": "HTTPValidationError",
"type": "object",
"properties": {
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
}
},
},
}
},
}

client = TestClient(app)
Expand Down
2 changes: 1 addition & 1 deletion xpresso/openapi/_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def get_operation(
"externalDocs": route.external_docs,
"operationId": route.operation_id,
}
docstring = inspect.cleandoc(getattr(route.endpoint, "__doc__", ""))
docstring = inspect.cleandoc(getattr(route.endpoint, "__doc__", None) or "") or None
if docstring and not data["description"]:
data["description"] = docstring
route_dependant = route.dependant
Expand Down

0 comments on commit 1111b4d

Please sign in to comment.