Skip to content

Commit fb87f94

Browse files
committed
docs: Update Pydantic schema docstrings to use links instead of copied strings.
1 parent 4072c47 commit fb87f94

31 files changed

+228
-1181
lines changed

openapi_python_client/schema/openapi_schema_pydantic/components.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,22 @@ class Components(BaseModel):
1818
Holds a set of reusable objects for different aspects of the OAS.
1919
All objects defined within the components object will have no effect on the API
2020
unless they are explicitly referenced from properties outside the components object.
21+
22+
References:
23+
- https://swagger.io/docs/specification/components/
24+
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#componentsObject
2125
"""
2226

2327
schemas: Optional[Dict[str, Union[Reference, Schema]]] = None
24-
"""An object to hold reusable [Schema Objects](#schemaObject)."""
25-
2628
responses: Optional[Dict[str, Union[Response, Reference]]] = None
27-
"""An object to hold reusable [Response Objects](#responseObject)."""
28-
2929
parameters: Optional[Dict[str, Union[Parameter, Reference]]] = None
30-
"""An object to hold reusable [Parameter Objects](#parameterObject)."""
31-
3230
examples: Optional[Dict[str, Union[Example, Reference]]] = None
33-
"""An object to hold reusable [Example Objects](#exampleObject)."""
34-
3531
requestBodies: Optional[Dict[str, Union[RequestBody, Reference]]] = None
36-
"""An object to hold reusable [Request Body Objects](#requestBodyObject)."""
37-
3832
headers: Optional[Dict[str, Union[Header, Reference]]] = None
39-
"""An object to hold reusable [Header Objects](#headerObject)."""
40-
4133
securitySchemes: Optional[Dict[str, Union[SecurityScheme, Reference]]] = None
42-
"""An object to hold reusable [Security Scheme Objects](#securitySchemeObject)."""
43-
4434
links: Optional[Dict[str, Union[Link, Reference]]] = None
45-
"""An object to hold reusable [Link Objects](#linkObject)."""
4635

47-
class Config:
36+
class Config: # pylint: disable=missing-class-docstring
4837
schema_extra = {
4938
"examples": [
5039
{

openapi_python_client/schema/openapi_schema_pydantic/contact.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,16 @@
66
class Contact(BaseModel):
77
"""
88
Contact information for the exposed API.
9-
"""
109
11-
name: Optional[str] = None
12-
"""
13-
The identifying name of the contact person/organization.
10+
See Also:
11+
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#contactObject
1412
"""
1513

14+
name: Optional[str] = None
1615
url: Optional[AnyUrl] = None
17-
"""
18-
The URL pointing to the contact information.
19-
MUST be in the format of a URL.
20-
"""
21-
2216
email: Optional[str] = None
23-
"""
24-
The email address of the contact person/organization.
25-
MUST be in the format of an email address.
26-
"""
2717

28-
class Config:
18+
class Config: # pylint: disable=missing-class-docstring
2919
schema_extra = {
3020
"examples": [
3121
{"name": "API Support", "url": "http://www.example.com/support", "email": "[email protected]"}

openapi_python_client/schema/openapi_schema_pydantic/discriminator.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ class Discriminator(BaseModel):
1212
of an alternative schema based on the value associated with it.
1313
1414
When using the discriminator, _inline_ schemas will not be considered.
15-
"""
1615
17-
propertyName: str
18-
"""
19-
**REQUIRED**. The name of the property in the payload that will hold the discriminator value.
16+
References:
17+
- https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/
18+
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#discriminatorObject
2019
"""
2120

21+
propertyName: str
2222
mapping: Optional[Dict[str, str]] = None
23-
"""
24-
An object to hold mappings between payload values and schema names or references.
25-
"""
2623

27-
class Config:
24+
class Config: # pylint: disable=missing-class-docstring
2825
schema_extra = {
2926
"examples": [
3027
{

openapi_python_client/schema/openapi_schema_pydantic/encoding.py

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,20 @@
66

77

88
class Encoding(BaseModel):
9-
"""A single encoding definition applied to a single schema property."""
9+
"""A single encoding definition applied to a single schema property.
1010
11-
contentType: Optional[str] = None
12-
"""
13-
The Content-Type for encoding a specific property.
14-
Default value depends on the property type:
15-
16-
- for `string` with `format` being `binary` – `application/octet-stream`;
17-
- for other primitive types – `text/plain`;
18-
- for `object` - `application/json`;
19-
- for `array` – the default is defined based on the inner type.
20-
21-
The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`),
22-
or a comma-separated list of the two types.
11+
References:
12+
- https://swagger.io/docs/specification/describing-request-body/
13+
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#encodingObject
2314
"""
2415

16+
contentType: Optional[str] = None
2517
headers: Optional[Dict[str, Reference]] = None
26-
"""
27-
A map allowing additional information to be provided as headers, for example `Content-Disposition`.
28-
29-
`Content-Type` is described separately and SHALL be ignored in this section.
30-
This property SHALL be ignored if the request body media type is not a `multipart`.
31-
"""
32-
3318
style: Optional[str] = None
34-
"""
35-
Describes how a specific property value will be serialized depending on its type.
36-
37-
See [Parameter Object](#parameterObject) for details on the [`style`](#parameterStyle) property.
38-
The behavior follows the same values as `query` parameters, including default values.
39-
This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`.
40-
"""
41-
4219
explode: bool = False
43-
"""
44-
When this is true, property values of type `array` or `object` generate separate parameters
45-
for each value of the array, or key-value-pair of the map.
46-
47-
For other types of properties this property has no effect.
48-
When [`style`](#encodingStyle) is `form`, the default value is `true`.
49-
For all other styles, the default value is `false`.
50-
This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`.
51-
"""
52-
5320
allowReserved: bool = False
54-
"""
55-
Determines whether the parameter value SHOULD allow reserved characters,
56-
as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2)
57-
`:/?#[]@!$&'()*+,;=` to be included without percent-encoding.
58-
The default value is `false`.
59-
This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`.
60-
"""
6121

62-
class Config:
22+
class Config: # pylint: disable=missing-class-docstring
6323
schema_extra = {
6424
"examples": [
6525
{

openapi_python_client/schema/openapi_schema_pydantic/example.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,19 @@
44

55

66
class Example(BaseModel):
7+
""" Examples added to parameters / components to help clarify usage.
78
8-
summary: Optional[str] = None
9-
"""
10-
Short description for the example.
9+
References:
10+
- https://swagger.io/docs/specification/adding-examples/
11+
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#exampleObject
1112
"""
1213

14+
summary: Optional[str] = None
1315
description: Optional[str] = None
14-
"""
15-
Long description for the example.
16-
[CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
17-
"""
18-
1916
value: Optional[Any] = None
20-
"""
21-
Embedded literal example.
22-
The `value` field and `externalValue` field are mutually exclusive.
23-
To represent examples of media types that cannot naturally represented in JSON or YAML,
24-
use a string value to contain the example, escaping where necessary.
25-
"""
26-
2717
externalValue: Optional[str] = None
28-
"""
29-
A URL that points to the literal example.
30-
This provides the capability to reference examples that cannot easily be included in JSON or YAML documents.
31-
32-
The `value` field and `externalValue` field are mutually exclusive.
33-
"""
3418

35-
class Config:
19+
class Config: # pylint: disable=missing-class-docstring
3620
schema_extra = {
3721
"examples": [
3822
{"summary": "A foo example", "value": {"foo": "bar"}},

openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@
44

55

66
class ExternalDocumentation(BaseModel):
7-
"""Allows referencing an external resource for extended documentation."""
7+
"""Allows referencing an external resource for extended documentation.
88
9-
description: Optional[str] = None
10-
"""
11-
A short description of the target documentation.
12-
[CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
9+
References:
10+
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#externalDocumentationObject
1311
"""
1412

13+
description: Optional[str] = None
1514
url: AnyUrl
16-
"""
17-
**REQUIRED**. The URL for the target documentation.
18-
Value MUST be in the format of a URL.
19-
"""
2015

21-
class Config:
16+
class Config: # pylint: disable=missing-class-docstring
2217
schema_extra = {"examples": [{"description": "Find more info here", "url": "https://example.com"}]}

openapi_python_client/schema/openapi_schema_pydantic/header.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ class Header(Parameter):
1212
2. `in` MUST NOT be specified, it is implicitly in `header`.
1313
3. All traits that are affected by the location MUST be applicable to a location of `header`
1414
(for example, [`style`](#parameterStyle)).
15+
16+
References:
17+
- https://swagger.io/docs/specification/describing-parameters/#header-parameters
18+
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#headerObject
1519
"""
1620

1721
name = Field(default="", const=True)
1822
param_in = Field(default=ParameterLocation.HEADER, const=True, alias="in")
1923

20-
class Config:
24+
class Config: # pylint: disable=missing-class-docstring
2125
allow_population_by_field_name = True
2226
schema_extra = {
2327
"examples": [

openapi_python_client/schema/openapi_schema_pydantic/info.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,20 @@ class Info(BaseModel):
1111
The object provides metadata about the API.
1212
The metadata MAY be used by the clients if needed,
1313
and MAY be presented in editing or documentation generation tools for convenience.
14-
"""
1514
16-
title: str
17-
"""
18-
**REQUIRED**. The title of the API.
15+
References:
16+
- https://swagger.io/docs/specification/api-general-info/
17+
-https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#infoObject
1918
"""
2019

20+
title: str
2121
description: Optional[str] = None
22-
"""
23-
A short description of the API.
24-
[CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
25-
"""
26-
2722
termsOfService: Optional[AnyUrl] = None
28-
"""
29-
A URL to the Terms of Service for the API.
30-
MUST be in the format of a URL.
31-
"""
32-
3323
contact: Optional[Contact] = None
34-
"""
35-
The contact information for the exposed API.
36-
"""
37-
3824
license: Optional[License] = None
39-
"""
40-
The license information for the exposed API.
41-
"""
42-
4325
version: str
44-
"""
45-
**REQUIRED**. The version of the OpenAPI document
46-
(which is distinct from the [OpenAPI Specification version](#oasVersion) or the API implementation version).
47-
"""
4826

49-
class Config:
27+
class Config: # pylint: disable=missing-class-docstring
5028
schema_extra = {
5129
"examples": [
5230
{

openapi_python_client/schema/openapi_schema_pydantic/license.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@
66
class License(BaseModel):
77
"""
88
License information for the exposed API.
9-
"""
109
11-
name: str
12-
"""
13-
**REQUIRED**. The license name used for the API.
10+
References:
11+
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#licenseObject
1412
"""
1513

14+
name: str
1615
url: Optional[AnyUrl] = None
17-
"""
18-
A URL to the license used for the API.
19-
MUST be in the format of a URL.
20-
"""
2116

22-
class Config:
17+
class Config: # pylint: disable=missing-class-docstring
2318
schema_extra = {"examples": [{"name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html"}]}

openapi_python_client/schema/openapi_schema_pydantic/link.py

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,20 @@ class Link(BaseModel):
1717
For computing links, and providing instructions to execute them,
1818
a [runtime expression](#runtimeExpression) is used for accessing values in an operation
1919
and using them as parameters while invoking the linked operation.
20-
"""
2120
22-
operationRef: Optional[str] = None
23-
"""
24-
A relative or absolute URI reference to an OAS operation.
25-
This field is mutually exclusive of the `operationId` field,
26-
and MUST point to an [Operation Object](#operationObject).
27-
Relative `operationRef` values MAY be used to locate an existing [Operation Object](#operationObject)
28-
in the OpenAPI definition.
21+
References:
22+
- https://swagger.io/docs/specification/links/
23+
- https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#linkObject
2924
"""
3025

26+
operationRef: Optional[str] = None
3127
operationId: Optional[str] = None
32-
"""
33-
The name of an _existing_, resolvable OAS operation, as defined with a unique `operationId`.
34-
35-
This field is mutually exclusive of the `operationRef` field.
36-
"""
37-
3828
parameters: Optional[Dict[str, Any]] = None
39-
"""
40-
A map representing parameters to pass to an operation
41-
as specified with `operationId` or identified via `operationRef`.
42-
The key is the parameter name to be used,
43-
whereas the value can be a constant or an expression to be evaluated and passed to the linked operation.
44-
45-
The parameter name can be qualified using the [parameter location](#parameterIn) `[{in}.]{name}`
46-
for operations that use the same parameter name in different locations (e.g. path.id).
47-
"""
48-
4929
requestBody: Optional[Any] = None
50-
"""
51-
A literal value or [{expression}](#runtimeExpression) to use as a request body when calling the target operation.
52-
"""
53-
5430
description: Optional[str] = None
55-
"""
56-
A description of the link.
57-
[CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
58-
"""
59-
6031
server: Optional[Server] = None
61-
"""
62-
A server object to be used by the target operation.
63-
"""
6432

65-
class Config:
33+
class Config: # pylint: disable=missing-class-docstring
6634
schema_extra = {
6735
"examples": [
6836
{"operationId": "getUserAddressByUUID", "parameters": {"userUuid": "$response.body#/uuid"}},

0 commit comments

Comments
 (0)