Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added OpenAPI Generator #35

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 aaa - all about apps GmbH
Copyright (c) 2024 aaa - all about apps GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ npm install -g texterify

Follow the configuration steps described in the [documentation](https://github.com/chrztoph/texterify-cli#configuration).

#### OpenAPI Generator Setup

Install [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator)

```
brew install openapi-generator
```

Configuration can be edited in `APIGeneration/generator-config.json`, `APIGeneration/make` and `APIGeneration/.openapi-generator-ignore`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add instructions on how to execute the model generation


## Steps

1. Run `cookiecutter gh:allaboutapps/ios-starter`.
Expand Down
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"teamName": "aaa - all about apps Gmbh",
"bundleIdentifier": "at.allaboutapps.{{cookiecutter.projectName|lower|replace(' ', '-')}}",
"deploymentTarget": "16.0",
"swaggerURL": "https://petstore.swagger.io/v2/swagger.json",
"texterifyProjectId": "NONE",
"texterifyExportConfigurationId": "NONE",
"defaultLanguageCode": "en",
Expand Down
4 changes: 4 additions & 0 deletions hooks/post_gen_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
xcodegen
{%- endif %}

{%- if cookiecutter.swaggerURL != 'NONE' %}
./generateModels
{%- endif %}

printf 'all done - enjoy \xf0\x9f\x9a\x80\n'
1 change: 1 addition & 0 deletions {{cookiecutter.projectDirectory}}/.swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ excluded:
- Modules/Core/Sources/Assets/Colors.swift
- Modules/Core/Sources/Assets/Images.swift
- Modules/Core/Sources/Assets/Strings.swift
- Modules/Core/Sources/Models/Generated/*

# configurable rules can be customized from this configuration file
line_length:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# OpenAPI Generator Ignore

# example usage
# **/Modules/Core/Sources/Models/Generated/**/Filename.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"projectName": "{{cookiecutter.projectName}}",
"readonlyProperties": true,
"responseAs": "Combine",
"swiftPackagePath": "/",
"validateSpec": false,
"validatable": false,
"useJsonEncodable": false
}
20 changes: 20 additions & 0 deletions {{cookiecutter.projectDirectory}}/APIGeneration/make
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
cd $(dirname $0)

# if you want to supply your swagger.yml directly,
# comment the next two lines and create a swagger.yml
rm -rf swagger.yml;
curl -o swagger.yml {{cookiecutter.swaggerURL}};

rm -rf ../Modules/Core/Sources/Models/Generated;

openapi-generator generate -i swagger.yml \
-g swift5 \
-o ../Modules/Core/Sources/Models/Generated \
-c generator-config.json \
--global-property models,modelDocs=false,modelTests=false \
--ignore-file-override=./.openapi-generator-ignore \
--type-mappings uuid4=UUID;

mv ../Modules/Core/Sources/Models/Generated/Models/* ../Modules/Core/Sources/Models/Generated/;
rm -rf ../Modules/Core/Sources/Models/Generated/Models;
39 changes: 34 additions & 5 deletions {{cookiecutter.projectDirectory}}/Modules/Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,59 @@ let package = Package(
.package(url: "https://github.com/allaboutapps/Toolbox.git", from: "5.0.0"),
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess.git", from: "4.2.2"),
.package(url: "https://github.com/Alamofire/AlamofireImage.git", from: "4.2.0"),
.package(url: "https://github.com/Flight-School/AnyCodable.git", from: "0.6.7"),
],
targets: [
.target(
name: "Assets",
dependencies: ["Logbook", "Toolbox", "KeychainAccess"]
dependencies: [
"Logbook",
"Toolbox",
"KeychainAccess",
]
),
.target(
name: "CommonUI",
dependencies: ["Assets", "Models", "Utilities", "Logbook", "Toolbox", "AlamofireImage"]
dependencies: [
"Assets",
"Models",
"Utilities",
"Logbook",
"Toolbox",
"AlamofireImage",
]
),
.target(
name: "Models",
dependencies: ["Logbook", "Toolbox", "KeychainAccess"]
dependencies: [
"Logbook",
"Toolbox",
"KeychainAccess",
"AnyCodable",
]
),
.target(
name: "Networking",
dependencies: ["Models", "Utilities", "Fetch", "Logbook", "Toolbox", "KeychainAccess"],
dependencies: [
"Models",
"Utilities",
"Fetch",
"Logbook",
"Toolbox",
"KeychainAccess",
],
resources: [
.process("Stubs"),
]
),
.target(
name: "Utilities",
dependencies: ["Fetch", "Logbook", "Toolbox", "KeychainAccess"]
dependencies: [
"Fetch",
"Logbook",
"Toolbox",
"KeychainAccess",
]
),
]
)
4 changes: 4 additions & 0 deletions {{cookiecutter.projectDirectory}}/generateModels
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
cd $(dirname $0)

./APIGeneration/make
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there an extra script for the generation? Am I missing something or could this be simplified to one script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it makes sense to have everything generation related in an own folder and this script is just for convenience from the root folder - we can also move everything in here if you want