Skip to content

Commit 537328e

Browse files
authored
Merge pull request #29 from boxdot/docs-and-more-fields
Fix links in docs and add title, default and minimum to schema
2 parents fdec32a + d5d0488 commit 537328e

File tree

2 files changed

+54
-57
lines changed

2 files changed

+54
-57
lines changed

src/v3_0/components.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ pub enum ObjectOrReference<T> {
1515
}
1616

1717
/// Holds a set of reusable objects for different aspects of the OAS.
18+
///
1819
/// All objects defined within the components object will have no effect on the API unless
1920
/// they are explicitly referenced from properties outside the components object.
20-
/// See [link]
21-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#componentsObject]
21+
///
22+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#componentsObject>.
2223
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
2324
pub struct Components {
2425
/// An object to hold reusable Schema Objects.

src/v3_0/schema.rs

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ pub struct Spec {
8585

8686
/// General information about the API.
8787
///
88-
/// See [link]
89-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#infoObject]
88+
///
89+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#infoObject>.
9090
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
9191
// #[serde(rename_all = "lowercase")]
9292
pub struct Info {
@@ -98,7 +98,8 @@ pub struct Info {
9898
/// A URL to the Terms of Service for the API. MUST be in the format of a URL.
9999
#[serde(rename = "termsOfService", skip_serializing_if = "Option::is_none")]
100100
pub terms_of_service: Option<Url>,
101-
/// REQUIRED. The version of the OpenAPI document (which is distinct from the [OpenAPI Specification version](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oasVersion)
101+
/// The version of the OpenAPI document (which is distinct from the [OpenAPI Specification
102+
/// version](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oasVersion)
102103
/// or the API implementation version).
103104
pub version: String,
104105
/// The contact information for the exposed API.
@@ -114,8 +115,8 @@ pub struct Info {
114115
pub struct Url(#[serde(with = "url_serde")] url::Url);
115116

116117
/// Contact information for the exposed API.
117-
/// See [link]
118-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#contactObject]
118+
///
119+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#contactObject>.
119120
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
120121
pub struct Contact {
121122
#[serde(skip_serializing_if = "Option::is_none")]
@@ -131,8 +132,8 @@ pub struct Contact {
131132
}
132133

133134
/// License information for the exposed API.
134-
/// See [link]
135-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#licenseObject]
135+
///
136+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#licenseObject>.
136137
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
137138
pub struct License {
138139
/// The license name used for the API.
@@ -144,8 +145,8 @@ pub struct License {
144145
}
145146

146147
/// An object representing a Server.
147-
/// See [link]
148-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#serverObject]
148+
///
149+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#serverObject>.
149150
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
150151
pub struct Server {
151152
/// A URL to the target host. This URL supports Server Variables and MAY be relative, to
@@ -164,8 +165,7 @@ pub struct Server {
164165

165166
/// An object representing a Server Variable for server URL template substitution.
166167
///
167-
/// See [link]
168-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#serverVariableObject]
168+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#serverVariableObject>.
169169
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
170170
pub struct ServerVariable {
171171
/// The default value to use for substitution, and to send, if an alternate value is not
@@ -184,10 +184,11 @@ pub struct ServerVariable {
184184
}
185185

186186
/// Describes the operations available on a single path.
187-
/// A Path Item MAY be empty, due to
188-
/// [ACL constraints](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securityFiltering).
189-
/// The path itself is still exposed to the documentation viewer but they will
190-
/// not know which operations and parameters are available.
187+
///
188+
/// A Path Item MAY be empty, due to [ACL
189+
/// constraints](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securityFiltering).
190+
/// The path itself is still exposed to the documentation viewer but they will not know which
191+
/// operations and parameters are available.
191192
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
192193
pub struct PathItem {
193194
/// Allows for an external definition of this path item. The referenced structure MUST be
@@ -253,8 +254,8 @@ pub struct PathItem {
253254
}
254255

255256
/// Describes a single API operation on a path.
256-
/// See [link]
257-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#operationObject]
257+
///
258+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#operationObject>.
258259
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
259260
// #[serde(rename_all = "lowercase")]
260261
pub struct Operation {
@@ -312,8 +313,7 @@ pub struct Operation {
312313
/// The `Responses Object` MUST contain at least one response code, and it SHOULD be the
313314
/// response for a successful operation call.
314315
///
315-
/// See [link]
316-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#responsesObject]
316+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#responsesObject>.
317317
pub responses: BTreeMap<String, Response>,
318318

319319
/// A map of possible out-of band callbacks related to the parent operation. The key is
@@ -351,8 +351,8 @@ pub struct Operation {
351351
/// A unique parameter is defined by a combination of a
352352
/// [name](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterName)
353353
/// and [location](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterIn).
354-
/// See [link]
355-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterObject]
354+
///
355+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterObject>.
356356
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
357357
pub struct Parameter {
358358
/// The name of the parameter.
@@ -416,8 +416,7 @@ enum ParameterStyle {
416416
/// [JSON Schema Validation](https://tools.ietf.org/html/draft-wright-json-schema-validation-00).
417417
/// Unless stated otherwise, the property definitions follow the JSON Schema.
418418
///
419-
/// See [link]
420-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject]
419+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject>.
421420
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
422421
pub struct Schema {
423422
/// [JSON reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03)
@@ -452,12 +451,12 @@ pub struct Schema {
452451
#[serde(skip_serializing_if = "Option::is_none", rename = "readOnly")]
453452
pub read_only: Option<bool>,
454453

454+
// FIXME: Why can this be a "boolean" (as per the spec)? It doesn't make sense. Here it's not.
455455
/// Value can be boolean or object. Inline or referenced schema MUST be of a
456456
/// [Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject)
457457
/// and not a standard JSON Schema.
458-
/// See [link]
459-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#properties]
460-
// FIXME: Why can this be a "boolean" (as per the spec)? It doesn't make sense. Here it's not.
458+
///
459+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#properties>.
461460
#[serde(
462461
skip_serializing_if = "Option::is_none",
463462
rename = "additionalProperties"
@@ -474,9 +473,11 @@ pub struct Schema {
474473
#[serde(skip_serializing_if = "Option::is_none")]
475474
pub example: Option<serde_json::value::Value>,
476475

476+
#[serde(skip_serializing_if = "Option::is_none")]
477+
pub title: Option<String>,
478+
477479
// The following properties are taken directly from the JSON Schema definition and
478480
// follow the same specifications:
479-
// title
480481
// multipleOf
481482
// maximum
482483
// exclusiveMaximum
@@ -511,7 +512,10 @@ pub struct Schema {
511512
/// defined type for the Schema Object defined at the same level. For example, if type is
512513
/// `string`, then `default` can be `"foo"` but cannot be `1`.
513514
#[serde(skip_serializing_if = "Option::is_none")]
514-
default: Option<serde_json::Value>,
515+
pub default: Option<serde_json::Value>,
516+
517+
#[serde(skip_serializing_if = "Option::is_none")]
518+
pub minimum: Option<serde_json::Value>,
515519

516520
/// Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard
517521
/// JSON Schema.
@@ -522,8 +526,7 @@ pub struct Schema {
522526
/// Describes a single response from an API Operation, including design-time, static `links`
523527
/// to operations based on the response.
524528
///
525-
/// See [link]
526-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#responseObject]
529+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#responseObject>.
527530
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
528531
pub struct Response {
529532
/// A short description of the response.
@@ -559,8 +562,8 @@ pub struct Response {
559562
/// 1. `in` MUST NOT be specified, it is implicitly in `header`.
560563
/// 1. All traits that are affected by the location MUST be applicable to a location of
561564
/// `header` (for example, [`style`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterStyle)).
562-
/// See [link]
563-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#headerObject]
565+
///
566+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#headerObject>.
564567
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
565568
pub struct Header {
566569
// FIXME: Is the third change properly implemented?
@@ -599,8 +602,8 @@ pub struct Header {
599602
}
600603

601604
/// Describes a single request body.
602-
/// See [link]
603-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#requestBodyObject]
605+
///
606+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#requestBodyObject>.
604607
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
605608
pub struct RequestBody {
606609
/// A brief description of the request body. This could contain examples of use.
@@ -632,8 +635,7 @@ pub struct RequestBody {
632635
/// is used for accessing values in an operation and using them as parameters while invoking
633636
/// the linked operation.
634637
///
635-
/// See [link]
636-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#linkObject]
638+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#linkObject>.
637639
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
638640
#[serde(untagged)]
639641
pub enum Link {
@@ -712,8 +714,8 @@ pub enum Link {
712714
}
713715

714716
/// Each Media Type Object provides schema and examples for the media type identified by its key.
715-
/// See [link]
716-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#media-type-object]
717+
///
718+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#media-type-object>.
717719
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
718720
pub struct MediaType {
719721
/// The schema defining the type used for the request body.
@@ -797,9 +799,7 @@ pub struct Encoding {
797799
pub allow_reserved: Option<bool>,
798800
}
799801

800-
///
801-
/// See [link]
802-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#exampleObject]
802+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#exampleObject>.
803803
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
804804
pub struct Example {
805805
/// Short description for the example.
@@ -831,8 +831,8 @@ pub struct Example {
831831
///OAuth2's common flows (implicit, password, application and access code) as defined
832832
/// in [RFC6749](https://tools.ietf.org/html/rfc6749), and
833833
/// [OpenID Connect Discovery](https://tools.ietf.org/html/draft-ietf-oauth-discovery-06).
834-
/// See [link]
835-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securitySchemeObject]
834+
///
835+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securitySchemeObject>.
836836
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
837837
#[serde(tag = "type")]
838838
pub enum SecurityScheme {
@@ -872,8 +872,8 @@ pub enum SecurityScheme {
872872
/// the API provider and the expected responses. The key value used to identify the callback
873873
/// object is an expression, evaluated at runtime, that identifies a URL to use for the
874874
/// callback operation.
875-
/// See [link]
876-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#callbackObject]
875+
///
876+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#callbackObject>.
877877
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
878878
pub struct Callback(
879879
/// A Path Item Object used to define a callback request and expected responses.
@@ -891,8 +891,7 @@ pub struct Callback(
891891
/// [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#operationObject).
892892
/// It is not mandatory to have a Tag Object per tag defined in the Operation Object instances.
893893
///
894-
/// See [link]
895-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#tagObject]
894+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#tagObject>.
896895
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
897896
pub struct Tag {
898897
/// The name of the tag.
@@ -910,15 +909,12 @@ pub struct Tag {
910909
}
911910

912911
/// Allows referencing an external resource for extended documentation.
913-
/// See [link]
914-
/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#externalDocumentationObject]
915-
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
912+
///
913+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#externalDocumentationObject>.
914+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
916915
pub struct ExternalDoc {
917-
/// The URL for the target documentation. Value MUST be in the format of a URL.
918-
// FIXME: Use `url::Url` instead of `String`
919-
// #[serde(with = "url_serde")]
920-
// pub url: url::Url,
921-
pub url: String,
916+
/// The URL for the target documentation.
917+
pub url: Url,
922918

923919
/// A short description of the target documentation.
924920
/// [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.

0 commit comments

Comments
 (0)