| @@ -216,15 +216,6 @@ | |||||
| "version" : "1.0.2" | "version" : "1.0.2" | ||||
| } | } | ||||
| }, | }, | ||||
| { | |||||
| "identity" : "swift-syntax", | |||||
| "kind" : "remoteSourceControl", | |||||
| "location" : "https://github.com/apple/swift-syntax.git", | |||||
| "state" : { | |||||
| "revision" : "64889f0c732f210a935a0ad7cda38f77f876262d", | |||||
| "version" : "509.1.1" | |||||
| } | |||||
| }, | |||||
| { | { | ||||
| "identity" : "swift-system", | "identity" : "swift-system", | ||||
| "kind" : "remoteSourceControl", | "kind" : "remoteSourceControl", | ||||
| @@ -234,15 +225,6 @@ | |||||
| "version" : "1.2.1" | "version" : "1.2.1" | ||||
| } | } | ||||
| }, | }, | ||||
| { | |||||
| "identity" : "swiftopenapi", | |||||
| "kind" : "remoteSourceControl", | |||||
| "location" : "https://github.com/dankinsoid/SwiftOpenAPI.git", | |||||
| "state" : { | |||||
| "revision" : "d4ac9379e1f7071844deda554c247c8cb13823ce", | |||||
| "version" : "2.20.0" | |||||
| } | |||||
| }, | |||||
| { | { | ||||
| "identity" : "vapor", | "identity" : "vapor", | ||||
| "kind" : "remoteSourceControl", | "kind" : "remoteSourceControl", | ||||
| @@ -252,15 +234,6 @@ | |||||
| "version" : "4.92.1" | "version" : "4.92.1" | ||||
| } | } | ||||
| }, | }, | ||||
| { | |||||
| "identity" : "vaportoopenapi", | |||||
| "kind" : "remoteSourceControl", | |||||
| "location" : "https://github.com/dankinsoid/VaporToOpenAPI.git", | |||||
| "state" : { | |||||
| "revision" : "5bf8c3fc73a42f0dd8c1ae2928fb5817026fa69e", | |||||
| "version" : "4.5.0" | |||||
| } | |||||
| }, | |||||
| { | { | ||||
| "identity" : "websocket-kit", | "identity" : "websocket-kit", | ||||
| "kind" : "remoteSourceControl", | "kind" : "remoteSourceControl", | ||||
| @@ -13,7 +13,6 @@ let package = Package( | |||||
| .package(url: "https://github.com/vapor/fluent.git", from: "4.8.0"), | .package(url: "https://github.com/vapor/fluent.git", from: "4.8.0"), | ||||
| // 🐘 Fluent driver for Postgres. | // 🐘 Fluent driver for Postgres. | ||||
| .package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.7.2"), | .package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.7.2"), | ||||
| .package(url: "https://github.com/dankinsoid/VaporToOpenAPI.git", from: "4.5.0"), | |||||
| ], | ], | ||||
| targets: [ | targets: [ | ||||
| .executableTarget( | .executableTarget( | ||||
| @@ -22,7 +21,6 @@ let package = Package( | |||||
| .product(name: "Fluent", package: "fluent"), | .product(name: "Fluent", package: "fluent"), | ||||
| .product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"), | .product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"), | ||||
| .product(name: "Vapor", package: "vapor"), | .product(name: "Vapor", package: "vapor"), | ||||
| .product(name: "VaporToOpenAPI", package: "vaportoopenapi"), | |||||
| ] | ] | ||||
| ), | ), | ||||
| .testTarget(name: "AppTests", dependencies: [ | .testTarget(name: "AppTests", dependencies: [ | ||||
| @@ -8,8 +8,6 @@ | |||||
| import Fluent | import Fluent | ||||
| import Vapor | import Vapor | ||||
| import Crypto | import Crypto | ||||
| import SwiftOpenAPI | |||||
| import VaporToOpenAPI | |||||
| @@ -18,12 +16,12 @@ struct cntrlUser: RouteCollection { | |||||
| let rts = routes.grouped("users") | let rts = routes.grouped("users") | ||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.get("login", ":x", use: login) | rts.get("login", ":x", use: login) | ||||
| rts.get(":x", use: read).openAPI( | |||||
| summary: "Create User", | |||||
| description: "Create a new user with the provided data", | |||||
| body: .type(mdlUser.self), | |||||
| response: .type(mdlUser.self) | |||||
| ) | |||||
| // rts.get(":x", use: read).openAPI( | |||||
| // summary: "Create User", | |||||
| // description: "Create a new user with the provided data", | |||||
| // body: .type(mdlUser.self), | |||||
| // response: .type(mdlUser.self) | |||||
| // ) | |||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.delete(":x", use: delete) | rts.delete(":x", use: delete) | ||||
| @@ -19,6 +19,8 @@ final class mdlWorkOrderSegment: Model, Content { | |||||
| @Parent(key: "workOrderId") var workorder: mdlWorkOrder | @Parent(key: "workOrderId") var workorder: mdlWorkOrder | ||||
| @Parent(key: "segmentId") var segment: mdlSegment | @Parent(key: "segmentId") var segment: mdlSegment | ||||
| @Children(for: \.$segment) var parts: [mdlWorkOrderPart] | @Children(for: \.$segment) var parts: [mdlWorkOrderPart] | ||||
| @Children(for: \.$segment) var inspections: [mdlInspection] | @Children(for: \.$segment) var inspections: [mdlInspection] | ||||
| @Children(for: \.$segment) var samples: [mdlOilSample] | @Children(for: \.$segment) var samples: [mdlOilSample] | ||||
| @@ -29,6 +31,8 @@ final class mdlWorkOrderSegment: Model, Content { | |||||
| @Timestamp(key: "updateDate", on: .update) var updatedate: Date? | @Timestamp(key: "updateDate", on: .update) var updatedate: Date? | ||||
| @Field(key: "updateUserId") var updateuserid: Int? | @Field(key: "updateUserId") var updateuserid: Int? | ||||
| var segmentname: String? | |||||
| init() { } | init() { } | ||||
| init(id: Int? = nil, | init(id: Int? = nil, | ||||
| @@ -42,6 +46,7 @@ final class mdlWorkOrderSegment: Model, Content { | |||||
| self.$segment.$id.value = segmentid | self.$segment.$id.value = segmentid | ||||
| self.createuserid = createuserid | self.createuserid = createuserid | ||||
| self.updateuserid = updateuserid | self.updateuserid = updateuserid | ||||
| self.segmentname = self.$segment.name | |||||
| } | } | ||||
| } | } | ||||
| extension mdlWorkOrderSegment{ | extension mdlWorkOrderSegment{ | ||||
| @@ -165,3 +165,4 @@ public func configure(_ app: Application) async throws { | |||||
| } | } | ||||
| @@ -1,8 +1,7 @@ | |||||
| import Foundation | |||||
| import Fluent | import Fluent | ||||
| import Vapor | import Vapor | ||||
| import Crypto | import Crypto | ||||
| import SwiftOpenAPI | |||||
| import VaporToOpenAPI | |||||
| let | let | ||||
| @@ -12,21 +11,22 @@ func routes(_ app: Application) throws { | |||||
| app.routes.caseInsensitive = true | app.routes.caseInsensitive = true | ||||
| app.routes.defaultMaxBodySize = "64mb"; | app.routes.defaultMaxBodySize = "64mb"; | ||||
| let baseApp = app.grouped("api").grouped("v2.0") | let baseApp = app.grouped("api").grouped("v2.0") | ||||
| let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String | |||||
| baseApp.get { req async in | baseApp.get { req async in | ||||
| "Connexion Mobile Services Version 2.0" | "Connexion Mobile Services Version 2.0" | ||||
| } | } | ||||
| baseApp.get("Swagger", "swagger.json") { req async in | |||||
| req.application.routes.openAPI( | |||||
| info: InfoObject( | |||||
| title: "Example API", | |||||
| description: "Example API Description", | |||||
| version: "2.0" | |||||
| ) | |||||
| ) | |||||
| }.excludeFromOpenAPI() | |||||
| // baseApp.get("Swagger", "swagger.json") { req async in | |||||
| // req.application.routes.openAPI( | |||||
| // info: InfoObject( | |||||
| // title: "Example API", | |||||
| // description: "Example API Description", | |||||
| // version: "2.0" | |||||
| // ) | |||||
| // ) | |||||
| // }.excludeFromOpenAPI() | |||||
| // baseApp.get("Swagger", "swagger.json"){ | // baseApp.get("Swagger", "swagger.json"){ | ||||
| // baseApp.openAPI( | // baseApp.openAPI( | ||||