bow-swift / bow-openapi Goto Github PK
View Code? Open in Web Editor NEW๐ Functional HTTP client generator from an OpenAPI/Swagger specification.
Home Page: https://openapi.bow-swift.io
License: Other
๐ Functional HTTP client generator from an OpenAPI/Swagger specification.
Home Page: https://openapi.bow-swift.io
License: Other
For readability purposes, I redefined UUID
in my OpenAPI 3 schemas.
components:
schemas:
UUID:
description: A `UUID` (or `GUID`).
type: string
format: uuid
example: ad959e79-55c3-4445-8c51-a74b6d52691a
This generates:
//
// UUID.swift
//
// Generated by bow-openapi
// Copyright ยฉ 2021 Bow Authors. All rights reserved.
//
import Foundation
/// A `UUID` (or `GUID`).
public struct UUID: Codable {
}
(Note the '`' character not escaped by swagger-codegen by the way)
The problem is that you add an extension to Foundation's UUID
in Extensions.swift
:
extension UUID: JSONEncodable {
func encodeToJSON() -> Any {
return self.uuidString
}
}
But due to the local redeclaration of UUID
, this extension points to our public struct UUID: Codable
. Therefore it generates a compilation error: Value of type 'UUID' has no member 'uuidString'
.
Do not redefine a type: string
with format: uuid
, and use Foundation's UUID
instead.
Date
, which uses DateFormatter
's func string(from date: Date) -> String
. I defined DateTime
, so I don't have the problem.Given the following schema:
openapi: 3.0.2
info:
version: 0.7.1
title: aoide
description: Music library management
license:
name: AGPL-3.0-or-later
url: 'https://www.gnu.org/licenses/agpl-3.0.html'
paths:
/date:
get:
summary: Get current date
operationId: date
parameters:
- $ref: '#/components/schemas/YYYYMMDD'
responses:
'400':
$ref: '#/components/schemas/YYYYMMDD'
components:
schemas:
YYYYMMDD:
type: integer
format: int32
bow-openapi 0.1.0 generates the following struct for YYYMMDD:
public struct YYYYMMDD: Codable {
}
I would expect the generated struct to be something like this:
public struct YYYYMMDD: Codable {
init(_ value: Int32) { self.value = value }
let value: Int32
}
Given the following schema:
openapi: 3.0.2
info:
version: 0.7.1
title: aoide
description: Music library management
license:
name: AGPL-3.0-or-later
url: 'https://www.gnu.org/licenses/agpl-3.0.html'
paths:
/date:
get:
summary: Get current date
operationId: date
parameters:
- $ref: '#/components/schemas/WRAPPER'
responses:
'400':
$ref: '#/components/schemas/YYYYMMDD'
components:
schemas:
WRAPPER:
oneOf:
- $ref: '#/components/schemas/YYYYMMDD'
YYYYMMDD:
type: object
required:
- value
properties:
value:
type: integer
format: int32
The YYYYMMDD struct is generated correctly. But then, bow-openapi generates two empty structs WRAPPER and OneOfWRAPPER.
I would expect WRAPPER to be an enum with a case with an associated value of YYYYMMDD.
The Linux installation instructions on the website (https://openapi.bow-swift.io/docs/quick-start/installation-guide/#-linux-users) ask you to sudo make linux
. Mac users may be tempted to build from the Makefile as well as the Homebrew installation doesn't currently work (#41).
The linux
target breaks normal conventions and does a bunch of destructive updates:
make install
is a separate step)openjdk-8-jre-headless
Installing dependencies, building the code and installing the code should be separate targets.
It should be possible to both build the code and execute it locally without using sudo
.
Hi, I'm using MacOS big sur and I'm having this issue. Anyone can help ?
Thanks
% brew install bow-openapi
==> Installing bow-openapi from bow-swift/bow
==> Downloading https://github.com/bow-swift/bow-openapi/archive/0.2.0.tar.gz
Already downloaded: /Users/l/Library/Caches/Homebrew/downloads/b513a89f395684e78745872d045af33a263f3dbcb71c26282e4e7f74c8fce3a2--bow-openapi-0.2.0.tar.gz
==> make macos prefix=/usr/local/Cellar/bow-openapi/0.2.0
Last 15 lines from /Users/l/Library/Logs/Homebrew/bow-openapi/01.make:
[4/6] Compiling BowEffects Array+TraverseConcurrent.swift
/tmp/bow-openapi/build/checkouts/bow/Sources/BowEffects/Data/Schedule.swift:725:36: warning: will never be executed
extract: { _, never in never },
^
/tmp/bow-openapi/build/checkouts/bow/Sources/BowEffects/Data/Schedule.swift:725:22: note: 'never' is uninhabited, so this function body can never be executed
extract: { _, never in never },
^
[5/6] Compiling BowOptics AutoFold.swift
[6/7] Compiling OpenApiGenerator APIClient.swift
[7/8] Compiling CLI BowOpenAPICommand.swift
[8/8] Linking bow-openapi
swift test --generate-linuxmain
/private/tmp/bow-openapi-20210225-69873-1h66f5f/bow-openapi-0.2.0: error: manifest parse error(s):
sandbox-exec: sandbox_apply: Operation not permitted
make: *** [macos] Error 1
==> Installing bow-openapi from bow-swift/bow
swagger-codegen: Java 1.8 is required to install this formula.
Install AdoptOpenJDK 8 with Homebrew Cask:
brew cask install homebrew/cask-versions/adoptopenjdk8
Error: An unsatisfied requirement failed this build.
Homebrew shows this error message even after adoptopenjdk8
successful installation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.