From ce11dbb4b73ab9fe4c0034a356a22c93d3ea7ca5 Mon Sep 17 00:00:00 2001 From: Alexandra Talalaieva <25621530+sashatalalasha@users.noreply.github.com> Date: Wed, 17 Jan 2024 12:52:47 +0100 Subject: [PATCH 1/9] feat: add swift support --- Dockerfile | 25 + .../clients/swift/CustomDateTranscoder.swift | 26 + contrib/clients/swift/openapi.yaml | 19337 ++++++++++++++++ scripts/generate.sh | 54 + 4 files changed, 19442 insertions(+) create mode 100644 contrib/clients/swift/CustomDateTranscoder.swift create mode 100644 contrib/clients/swift/openapi.yaml diff --git a/Dockerfile b/Dockerfile index 2ce57e6b5bb..166603ddea3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,31 @@ FROM openjdk:15-buster RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates ssh bash +RUN apt-get -y install libncurses5 clang libcurl4 libpython2.7 libpython2.7-dev + +RUN apt-get -y install libxml2 + +RUN \ + curl https://download.swift.org/swift-5.9.2-release/ubuntu1804/swift-5.9.2-RELEASE/swift-5.9.2-RELEASE-ubuntu18.04.tar.gz -o swift.tar.gz &&\ + tar xzf swift.tar.gz && \ + mv swift-5.9.2-RELEASE-ubuntu18.04 /usr/share/swift && \ + export PATH=/usr/share/swift/usr/bin:$PATH && \ + swift -v + +ENV PATH /usr/share/swift/usr/bin:$PATH + +RUN git clone https://github.com/apple/swift-openapi-generator.git \ +&& cd swift-openapi-generator \ +&& swift build \ +&& ln -s .build/debug/swift-openapi-generator /usr/local/bin/swift-openapi-generator \ +&& swift-openapi-generator --help + +RUN git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew \ +&& mkdir ~/.linuxbrew/bin \ +&& ln -s ../Homebrew/bin/brew ~/.linuxbrew/bin \ +&& eval $(~/.linuxbrew/bin/brew shellenv) \ +&& brew --version + ENV GOLANG_VERSION 1.17 RUN set -eux; \ diff --git a/contrib/clients/swift/CustomDateTranscoder.swift b/contrib/clients/swift/CustomDateTranscoder.swift new file mode 100644 index 00000000000..3f5b2813cb5 --- /dev/null +++ b/contrib/clients/swift/CustomDateTranscoder.swift @@ -0,0 +1,26 @@ +import Foundation +import OpenAPIRuntime + +/// A transcoder for dates encoded as an ISO-8601 string (in RFC 3339 format). Allows date with internet date time and fractional seconds. +public struct CustomDateTranscoder: DateTranscoder, @unchecked Sendable { + + /// Creates and returns an ISO 8601 formatted string representation of the specified date. + public func encode(_ date: Date) throws -> String { + let formatter = ISO8601DateFormatter() + formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds] + return formatter.string(from: date) } + + /// Creates and returns a date object from the specified ISO 8601 formatted string representation. + public func decode(_ dateString: String) throws -> Date { + let formatter = ISO8601DateFormatter() + formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds] + print(dateString) + guard let date = formatter.date(from: dateString) else { + throw DecodingError.dataCorrupted( + .init(codingPath: [], debugDescription: "Expected date string to be ISO8601-formatted.") + ) + } + return date + } +} + diff --git a/contrib/clients/swift/openapi.yaml b/contrib/clients/swift/openapi.yaml new file mode 100644 index 00000000000..9b3629474c5 --- /dev/null +++ b/contrib/clients/swift/openapi.yaml @@ -0,0 +1,19337 @@ +openapi: 3.0.3 +info: + contact: + email: support@ory.sh + name: API Support + description: | + Documentation for all public and administrative Ory APIs. Administrative APIs can only be accessed + with a valid Personal Access Token. Public APIs are mostly used in browsers. + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + termsOfService: /ptos + title: Ory APIs + version: v1.5.1 +servers: +- url: "https://{project}.projects.oryapis.com/" + variables: + project: + default: playground + description: Project slug as provided by the Ory Console. +tags: +- description: APIs for managing identities. + name: identity +- description: "Endpoints used by frontend applications (e.g. Single-Page-App, Native\ + \ Apps, Server Apps, ...) to manage a user's own profile." + name: frontend +- description: APIs for managing email and SMS message delivery. + name: courier +- description: Server Metadata provides relevant information about the running server. + Only available when self-hosting this service. + name: metadata +paths: + /.well-known/jwks.json: + get: + description: |- + This endpoint returns JSON Web Keys required to verifying OpenID Connect ID Tokens and, + if enabled, OAuth 2.0 JWT Access Tokens. This endpoint can be used with client libraries like + [node-jwks-rsa](https://github.com/auth0/node-jwks-rsa) among others. + operationId: discoverJsonWebKeys + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/jsonWebKeySet' + description: jsonWebKeySet + default: + content: + application/json: + schema: + $ref: '#/components/schemas/errorOAuth2' + description: errorOAuth2 + summary: Discover Well-Known JSON Web Keys + tags: + - wellknown + /.well-known/openid-configuration: + get: + description: |- + A mechanism for an OpenID Connect Relying Party to discover the End-User's OpenID Provider and obtain information needed to interact with it, including its OAuth 2.0 endpoint locations. + + Popular libraries for OpenID Connect clients include oidc-client-js (JavaScript), go-oidc (Golang), and others. + For a full list of clients go here: https://openid.net/developers/certified/ + operationId: discoverOidcConfiguration + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/oidcConfiguration' + description: oidcConfiguration + default: + content: + application/json: + schema: + $ref: '#/components/schemas/errorOAuth2' + description: errorOAuth2 + summary: OpenID Connect Discovery + tags: + - oidc + /.well-known/ory/webauthn.js: + get: + description: |- + This endpoint provides JavaScript which is needed in order to perform WebAuthn login and registration. + + If you are building a JavaScript Browser App (e.g. in ReactJS or AngularJS) you will need to load this file: + + ```html +