Skip to content

Commit

Permalink
Merge branch 'main' into paraipan/66-Support-default-values-for-schem…
Browse files Browse the repository at this point in the history
…a-properties
  • Loading branch information
PARAIPAN9 authored Dec 28, 2024
2 parents 7c5df3e + 9c01b32 commit d4e4541
Show file tree
Hide file tree
Showing 177 changed files with 2,890 additions and 1,433 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
7 changes: 3 additions & 4 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ changelog:
categories:
- title: SemVer Major
labels:
- semver/major
- ⚠️ semver/major
- title: SemVer Minor
labels:
- semver/minor
- 🆕 semver/minor
- title: SemVer Patch
labels:
- semver/patch
- 🔨 semver/patch
- title: Other Changes
labels:
- semver/none
- "*"
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Main

on:
push:
branches: [main]
schedule:
- cron: "0 8,20 * * *"

jobs:
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

integration-test:
name: Integration test
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Integration test"
matrix_linux_command: "apt-get update -yq && apt-get install -yq jq && SWIFT_OPENAPI_GENERATOR_REPO_URL=file://${GITHUB_WORKSPACE} ./scripts/run-integration-test.sh"

example-packages:
name: Example packages
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Example packages"
matrix_linux_command: "./scripts/test-examples.sh"
7 changes: 1 addition & 6 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_enabled: false

Expand Down Expand Up @@ -57,8 +57,3 @@ jobs:
name: "Example packages"
matrix_linux_command: "./scripts/test-examples.sh"
matrix_linux_nightly_main_enabled: false

swift-6-language-mode:
name: Swift 6 Language Mode
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
if: false # Disabled for now.
18 changes: 18 additions & 0 deletions .github/workflows/pull_request_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR label

on:
pull_request:
types: [labeled, unlabeled, opened, reopened, synchronize]

jobs:
semver-label-check:
name: Semantic version label check
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check for Semantic Version label
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main
30 changes: 0 additions & 30 deletions .github/workflows/scheduled.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .licenseignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/Assets.xcassets/*
Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/Preview*
Examples/**/Generated*
**/Makefile
**/*.html
**/*.html
.editorconfig
3 changes: 2 additions & 1 deletion .swiftformatignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Tests/OpenAPIGeneratorReferenceTests/Resources
Sources/swift-openapi-generator/Documentation.docc
Examples/**/Generated/*
Examples/**/GeneratedSources/*
Examples/**/GeneratedSources/*
**Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -609,15 +609,15 @@
repositoryURL = "https://github.com/apple/swift-openapi-generator.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
minimumVersion = 1.6.0;
};
};
3A133D0E2B1F2A600008DD5E /* XCRemoteSwiftPackageReference "swift-openapi-runtime" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-openapi-runtime.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
minimumVersion = 1.7.0;
};
};
3A133D112B1F2A730008DD5E /* XCRemoteSwiftPackageReference "swift-openapi-urlsession" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct ContentView: View {

// A mock client used in previews and tests to avoid making live network calls.
struct MockClient: APIProtocol {
func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output {
func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output {
let name = input.query.name ?? "Stranger"
return .ok(.init(body: .json(.init(message: "(Mock) Hello, \(name)!"))))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ generate:
- types
- client
accessModifier: internal
namingStrategy: idiomatic
4 changes: 2 additions & 2 deletions Examples/auth-client-middleware-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ let package = Package(
name: "auth-client-middleware-example",
platforms: [.macOS(.v11), .iOS(.v14), .tvOS(.v14), .watchOS(.v7), .visionOS(.v1)],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-http-types", from: "1.0.2"),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ generate:
- types
- client
accessModifier: internal
namingStrategy: idiomatic
4 changes: 2 additions & 2 deletions Examples/auth-server-middleware-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ let package = Package(
name: "auth-server-middleware-example",
platforms: [.macOS(.v10_15)],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor", from: "4.89.0"),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Vapor
import AuthenticationServerMiddleware

struct Handler: APIProtocol {
func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output {
func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output {
// Extract the authenticated user, if present.
// If unauthenticated, return the 401 HTTP status code.
// Note that the 401 is defined in the OpenAPI document, allowing the client
Expand All @@ -32,7 +32,7 @@ struct Handler: APIProtocol {

@main struct HelloWorldVaporServer {
static func main() async throws {
let app = Vapor.Application()
let app = try await Vapor.Application.make()
let transport = VaporTransport(routesBuilder: app)
let handler = Handler()
try handler.registerHandlers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ generate:
- types
- server
accessModifier: internal
namingStrategy: idiomatic
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ let package = Package(
name: "bidirectional-event-streams-client-example",
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.2.0"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-async-http-client", from: "1.0.0"),
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import Foundation
let (stream, continuation) = AsyncStream<Components.Schemas.Greeting>.makeStream()
/// To keep it simple, using JSON Lines, as it most straightforward and easy way to have streams.
/// For SSE and JSON Sequences cases please check `event-streams-client-example`.
let requestBody: Operations.getGreetingsStream.Input.Body = .application_jsonl(
let requestBody: Operations.GetGreetingsStream.Input.Body = .applicationJsonl(
.init(stream.asEncodedJSONLines(), length: .unknown, iterationBehavior: .single)
)
let response = try await client.getGreetingsStream(query: .init(name: "Example"), body: requestBody)
let greetingStream = try response.ok.body.application_jsonl.asDecodedJSONLines(
let greetingStream = try response.ok.body.applicationJsonl.asDecodedJSONLines(
of: Components.Schemas.Greeting.self
)
try await withThrowingTaskGroup(of: Void.self) { group in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ generate:
- types
- client
accessModifier: internal
namingStrategy: idiomatic
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import PackageDescription

let package = Package(
name: "bidirectional-event-streams-server-example",
platforms: [.macOS(.v10_15)],
platforms: [.macOS(.v14)],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.2.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0-rc.1"),
.package(url: "https://github.com/swift-server/swift-openapi-hummingbird.git", from: "2.0.0-beta.4"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.5.0"),
.package(url: "https://github.com/swift-server/swift-openapi-hummingbird.git", from: "2.0.1"),
],
targets: [
.executableTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import Foundation

struct Handler: APIProtocol {
private let storage: StreamStorage = .init()
func getGreetingsStream(_ input: Operations.getGreetingsStream.Input) async throws
-> Operations.getGreetingsStream.Output
func getGreetingsStream(_ input: Operations.GetGreetingsStream.Input) async throws
-> Operations.GetGreetingsStream.Output
{
let eventStream = await self.storage.makeStream(input: input)
/// To keep it simple, using JSON Lines, as it most straightforward and easy way to have streams.
/// For SSE and JSON Sequences cases please check `event-streams-server-example`.
let responseBody = Operations.getGreetingsStream.Output.Ok.Body.application_jsonl(
let responseBody = Operations.GetGreetingsStream.Output.Ok.Body.applicationJsonl(
.init(eventStream.asEncodedJSONLines(), length: .unknown, iterationBehavior: .single)
)
return .ok(.init(body: responseBody))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ actor StreamStorage: Sendable {
task.cancel()
print("Canceled stream \(id)")
}
func makeStream(input: Operations.getGreetingsStream.Input) -> AsyncStream<Components.Schemas.Greeting> {
func makeStream(input: Operations.GetGreetingsStream.Input) -> AsyncStream<Components.Schemas.Greeting> {
let name = input.query.name ?? "Stranger"
let id = UUID().uuidString
print("Creating stream \(id) for name: \(name)")
Expand All @@ -44,7 +44,7 @@ actor StreamStorage: Sendable {
}
let inputStream =
switch input.body {
case .application_jsonl(let body): body.asDecodedJSONLines(of: Components.Schemas.Greeting.self)
case .applicationJsonl(let body): body.asDecodedJSONLines(of: Components.Schemas.Greeting.self)
}
let task = Task<Void, any Error> {
for try await message in inputStream {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ generate:
- types
- server
accessModifier: internal
namingStrategy: idiomatic
4 changes: 2 additions & 2 deletions Examples/command-line-client-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ let package = Package(
name: "command-line-client-example",
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ generate:
- types
- client
accessModifier: internal
namingStrategy: idiomatic
4 changes: 2 additions & 2 deletions Examples/curated-client-library-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ let package = Package(
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)],
products: [.library(name: "CuratedLibraryClient", targets: ["CuratedLibraryClient"])],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ generate:
- types
- client
accessModifier: internal
namingStrategy: idiomatic
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct TestClient: APIProtocol {
var name: String?
}

func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output {
func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output {
guard !shouldFail else { throw TestError(name: input.query.name) }
let name = input.query.name ?? "Stranger"
return .ok(.init(body: .json(.init(message: "(Test) Hello, \(name)!"))))
Expand Down
4 changes: 2 additions & 2 deletions Examples/event-streams-client-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ let package = Package(
name: "event-streams-client-example",
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.2.0"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
],
targets: [
Expand Down
Loading

0 comments on commit d4e4541

Please sign in to comment.