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

Set up API client code generation #121

Merged
merged 8 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 static-analysis/git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

STAGED_KOTLIN_FILES=($(git --no-pager diff --cached --name-only --diff-filter=ACM | grep "\.kt"))
STAGED_KOTLIN_FILES=($(git --no-pager diff --cached --name-only --diff-filter=ACM | grep "\.kt$"))

if [ -z "$STAGED_KOTLIN_FILES" ]; then
echo "No Kotlin files staged."
Expand Down
41 changes: 29 additions & 12 deletions static-analysis/run-ktlint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && cd .. && pwd )
readonly ROOT_DIR
readonly CONFIG_DIR="$ROOT_DIR/static-analysis/config"
Expand All @@ -24,22 +25,33 @@ getKtlint(){
command="$INSTALL_TARGET"
}

# Analyze inputs
# Initialize options
auto_fix_flag=""
scan_generated_files=false
target_dir="$ROOT_DIR"
input=()
while getopts ":e:i:" opt; do

# Analyze inputs
while getopts ":e:i:Fd:g" opt; do
case $opt in
e) command="$OPTARG"
;;
i) input+=($OPTARG);
i) input+=($OPTARG)
;;
F) auto_fix_flag="-F" # Enable auto-fix
;;
d) target_dir="$OPTARG" # Set target directory
;;
g) scan_generated_files=true # Include generated files
;;
\?) echo "Invalid option -$OPTARG" >&2
exit 1
exit 1
;;
esac

case $OPTARG in
-*) echo "Option $opt needs a valid argument"
exit 1
exit 1
;;
esac
done
Expand All @@ -65,20 +77,25 @@ fi
# Specify which files to analyze
files_argument=""
for i in "${input[@]}"; do
if [[ "$i" != *'/generated/'* ]]; then
files_argument="$files_argument\"./$i\" "
else
if [ "$scan_generated_files" = false ] && [[ "$i" == *'/generated/'* ]]; then
echo "Ignoring generated file: $i"
else
files_argument="$files_argument\"./$i\" "
fi
done

# Set files to analyze based on whether input files or directory were provided
if [ "$files_argument" == "" ]; then
echo "No input files specified. Analyzing all Kotlin files..."
files_argument="**/*.kt **/*.kts !**/build/** !**/generated/**"
echo "No input files specified. Analyzing all Kotlin files in $target_dir..."
if [ "$scan_generated_files" = true ]; then
files_argument="$target_dir/**/*.kt $target_dir/**/*.kts !**/build/** !**/*.mustache"
else
files_argument="$target_dir/**/*.kt $target_dir/**/*.kts !**/build/** !**/generated/** !**/*.mustache"
fi
fi

echo
echo $files_argument
echo "Running ktlint..."
command="$command $files_argument --experimental --reporter plain --baseline=$CONFIG_DIR/ktlint-baseline.xml"
command="$command $files_argument --experimental --reporter plain --baseline=$CONFIG_DIR/ktlint-baseline.xml $auto_fix_flag"
eval "$command"
echo "Done."
134 changes: 134 additions & 0 deletions tidalapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
src/main/kotlin/com/tidal/sdk/tidalapi/generated/ApiClient.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/Albums.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/Artists.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/Playlists.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/Providers.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/SearchResults.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/Tracks.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/UserEntitlements.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/UserPublicProfilePicks.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/UserPublicProfiles.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/UserRecommendations.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/Users.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/apis/Videos.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsItemResourceIdentifier.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsItemResourceIdentifierMeta.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsItemsRelationship.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsItemsRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsItemsRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsMultiDataDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/AlbumsSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsMultiDataDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsTrackProvidersRelationship.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsTrackProvidersRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsTrackProvidersResourceIdentifier.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ArtistsTrackProvidersResourceIdentifierMeta.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/CatalogueItemExternalLink.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/CatalogueItemImageLink.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/CatalogueItemVideoLink.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ErrorDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ErrorObject.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ErrorObjectSource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ExternalLinkMeta.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ImageLinkMeta.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/Links.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/MultiDataRelationshipDoc.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsExternalLink.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsImageLink.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsItemsRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsMultiDataDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsOwnersRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsOwnersRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PlaylistsSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/PromptColors.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ProvidersAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ProvidersMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ProvidersRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ProvidersRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ProvidersResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ProvidersSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/ResourceIdentifier.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/SearchResultsAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/SearchResultsRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/SearchResultsResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/SearchResultsSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/SearchResultsTopHitsRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/SearchResultsTopHitsRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/SingletonDataRelationshipDoc.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/TracksAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/TracksMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/TracksMultiDataDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/TracksRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/TracksRelationshipsDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/TracksRelationshipsDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/TracksResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/TracksSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UpdateUserPublicProfilePicksRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserEntitlementsAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserEntitlementsRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserEntitlementsRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserEntitlementsResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserEntitlementsSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilePicksAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilePicksItemRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilePicksItemRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilePicksMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilePicksMultiDataDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilePicksRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilePicksRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilePicksRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilePicksResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesExternalLink.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesExternalLinkMeta.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesImageLink.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesMultiDataDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserPublicProfilesSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserRecommendationsMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserRecommendationsMultiDataDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserRecommendationsRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserRecommendationsResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UserRecommendationsSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersMultiDataDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersRecommendationsRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersRecommendationsRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersRelationshipDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersRelationshipDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/UsersSingleDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/Utils.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/VideoLinkMeta.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/VideosAttributes.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/VideosMultiDataDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/VideosMultiDataDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/VideosRelationships.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/VideosRelationshipsDocument.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/VideosRelationshipsDocumentIncludedInner.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/VideosResource.kt
src/main/kotlin/com/tidal/sdk/tidalapi/generated/models/VideosSingleDataDocument.kt
1 change: 1 addition & 0 deletions tidalapi/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.9.0-SNAPSHOT
21 changes: 21 additions & 0 deletions tidalapi/bin/generate-api-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"inputs": [
{
"inputURL": "https://developer.tidal.com/apiref/api-specifications/api-public-user-jsonapi/tidal-user-v2-openapi-3.0.json"
},
{
"inputURL": "https://developer.tidal.com/apiref/api-specifications/api-public-catalogue-jsonapi/tidal-catalog-v2-openapi-3.0.json"
},
{
"inputURL": "https://developer.tidal.com/apiref/api-specifications/api-public-search-jsonapi/tidal-search-v2-openapi-3.0.json"
},
{
"inputURL": "https://developer.tidal.com/apiref/api-specifications/api-public-user-content/tidal-user-content-openapi-3.0.json"
}

],
"output": "./tidal-api-joined.json",
"openapi_generator_path": "tbd"
Copy link
Contributor Author

@michpohl michpohl Oct 23, 2024

Choose a reason for hiding this comment

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

This would point to where the executable would be found. As I still work on providing it, it is tbd for now (which means, if you run the python script, it will download and merge the API schemas, but won't (re-) generate the code).



}
Loading
Loading