Skip to content

Commit

Permalink
4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dankinsoid committed Mar 21, 2024
1 parent b1e804e commit 5bf8c3f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
.package(url: "https://github.com/dankinsoid/SwiftOpenAPI.git", from: "2.19.5"),
.package(url: "https://github.com/dankinsoid/SwiftOpenAPI.git", from: "2.20.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "0.10.3"),
],
targets: [
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ You can customize OpenAPI schemas and parameters result by implementing `OpenAPI
```swift
import SwiftOpenAPI

@OpenAPIAutoDescriptable
@OpenAPIDescriptable
/// Login request body.
struct LoginBody: Codable {

Expand Down Expand Up @@ -211,7 +211,7 @@ import PackageDescription
let package = Package(
name: "SomeProject",
dependencies: [
.package(url: "https://github.com/dankinsoid/VaporToOpenAPI.git", from: "4.4.6")
.package(url: "https://github.com/dankinsoid/VaporToOpenAPI.git", from: "4.5.0")
],
targets: [
.target(name: "SomeProject", dependencies: ["VaporToOpenAPI"])
Expand Down
36 changes: 26 additions & 10 deletions Tests/VaporToOpenAPITests/RouteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,25 @@ final class RouteTests: XCTestCase {

func testOpenAPIResponse() {
route {
$0.openAPI(response: .type(TestType.self))
$0.openAPI(response: .type(GetStudentDTO.self))
} testOperation: {
XCTAssertNoDifference(
$0.responses?[.ok]?.object?.content,
[
.application(.json): MediaTypeObject(
schema: .ref(components: \.schemas, "TestType"),
examples: [
"TestType": .ref(components: \.examples, "TestType")
]
schema: .ref(components: \.schemas, "GetStudentDTO")
)
]
)
} testDocument: { openAPIObject in
XCTAssertNoDifference(
openAPIObject.components?.schemas,
["TestType": TestType.schema]
)
XCTAssertNoDifference(
openAPIObject.components?.examples,
["TestType": ["intValue": 0]]
["GetStudentDTO": GetStudentDTO.schema]
)
// XCTAssertNoDifference(
// openAPIObject.components?.examples,
// ["TestType": ["intValue": 0]]
// )
}
}

Expand Down Expand Up @@ -386,3 +383,22 @@ struct TestType: Codable, WithExample {

enum IDLink: LinkKey {
}

struct GetStudentDTO: Content {
var id: UUID
var courseOfStudy: String
var email: String

static var schema: ReferenceOr<SchemaObject> {
.value(
.object(
properties: [
"id": .uuid,
"courseOfStudy": .string,
"email": .string
],
required: ["id", "courseOfStudy", "email"]
)
)
}
}

0 comments on commit 5bf8c3f

Please sign in to comment.