-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e536e91
commit 7945f04
Showing
4 changed files
with
83 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,30 @@ | ||
// | ||
// ExternalDocumentation.swift | ||
// SwaggerParser | ||
// | ||
// Created by Logan Shire on 7/12/17. | ||
// | ||
// | ||
|
||
import Foundation | ||
import ObjectMapper | ||
|
||
/// Allows referencing an external resource for extended documentation. | ||
public struct ExternalDocumentation { | ||
|
||
/// The URL for the target documentation. | ||
let url: URL | ||
|
||
/// A short description of the target documentation. | ||
/// GFM syntax can be used for rich text representation. | ||
let description: String? | ||
} | ||
|
||
struct ExternalDocumentationBuilder: Builder { | ||
|
||
typealias Building = ExternalDocumentation | ||
|
||
let url: URL | ||
let description: String? | ||
|
||
init(map: Map) throws { | ||
url = try map.value("url", using: URLTransform()) | ||
description = try? map.value("description") | ||
} | ||
|
||
func build(_ swagger: SwaggerBuilder) throws -> ExternalDocumentation { | ||
return ExternalDocumentation(url: self.url, description: self.description) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import ObjectMapper | ||
|
||
/// Allows adding meta data to a single tag that is used by the Operation. | ||
/// It is not mandatory to have a Tag per tag used there. | ||
public struct Tag { | ||
|
||
/// The name of the tag. | ||
let name: String | ||
|
||
/// A short description for the tag. | ||
/// GFM syntax can be used for rich text representation. | ||
let description: String? | ||
|
||
/// Additional external documentation for this tag. | ||
let externalDocumentation: ExternalDocumentation? | ||
} | ||
|
||
struct TagBuilder: Builder { | ||
|
||
typealias Building = Tag | ||
|
||
let name: String | ||
let description: String? | ||
let externalDocumentationBuilder: ExternalDocumentationBuilder? | ||
|
||
init(map: Map) throws { | ||
name = try map.value("name") | ||
description = try? map.value("description") | ||
externalDocumentationBuilder = try? map.value("externalDocs") | ||
} | ||
|
||
func build(_ swagger: SwaggerBuilder) throws -> Tag { | ||
return Tag(name: self.name, description: self.description, | ||
externalDocumentation: try self.externalDocumentationBuilder?.build(swagger)) | ||
} | ||
} |