Git Product home page Git Product logo

bow-openapi's People

Contributors

calvellido avatar dependabot[bot] avatar juanpe avatar miguelangel-dev avatar truizlop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

juanpe

bow-openapi's Issues

Generated client does not compile if UUID is redefined

Problem

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'.

Proposed solution

Do not redefine a type: string with format: uuid, and use Foundation's UUID instead.

Additional remarks

  • There may be a problem with Date, which uses DateFormatter's func string(from date: Date) -> String. I defined DateTime, so I don't have the problem.
  • There could be problems with other Foundation types.

Primitive schema objects are generated empty

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
}

Support oneOf

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.

Makefile performs destructive system updates (editing dotfiles, installing JRE)

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:

  • It both builds and installs (usually make install is a separate step)
  • It creates system installation directories before building, not after
  • It installs system-wide openjdk-8-jre-headless
  • It installs bash and zsh code completions

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.

Brew install fails

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

Error when installing bow-openapi using homebrew on macOS Big Sur

==> 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.