From 362c8f45bc2314f6d5bf47b07379ebca4065d287 Mon Sep 17 00:00:00 2001 From: Satyam Seth Date: Tue, 22 Oct 2024 00:43:39 +0530 Subject: [PATCH 1/2] Generate Swift OpenAPi Client --- openapi swift client generation/README.md | 5 + .../backend/README.md | 13 + .../backend/demo/core/__init__.py | 0 .../backend/demo/core/admin.py | 9 + .../backend/demo/core/apps.py | 6 + .../demo/core/migrations/0001_initial.py | 23 + .../backend/demo/core/migrations/__init__.py | 0 .../backend/demo/core/models.py | 9 + .../backend/demo/core/serializers.py | 8 + .../backend/demo/core/tests.py | 3 + .../backend/demo/core/views.py | 10 + .../backend/demo/db.sqlite3 | Bin 0 -> 135168 bytes .../backend/demo/demo/__init__.py | 0 .../backend/demo/demo/asgi.py | 16 + .../backend/demo/demo/settings.py | 129 ++ .../backend/demo/demo/urls.py | 38 + .../backend/demo/demo/wsgi.py | 16 + .../backend/demo/manage.py | 22 + .../backend/requirements.txt | 9 + .../frontend/README.md | 13 + .../frontend/client/.gitignore | 100 ++ .../frontend/client/.openapi-generator-ignore | 23 + .../frontend/client/.openapi-generator/FILES | 25 + .../client/.openapi-generator/VERSION | 1 + .../frontend/client/.swiftformat | 45 + .../frontend/client/Cartfile | 1 + .../frontend/client/OpenAPIClient.podspec | 15 + .../Classes/OpenAPIs/APIHelper.swift | 121 ++ .../OpenAPIClient/Classes/OpenAPIs/APIs.swift | 68 + .../Classes/OpenAPIs/APIs/StudentapiAPI.swift | 280 ++++ .../Classes/OpenAPIs/CodableHelper.swift | 49 + .../Classes/OpenAPIs/Configuration.swift | 18 + .../Classes/OpenAPIs/Extensions.swift | 236 ++++ .../Classes/OpenAPIs/JSONDataEncoding.swift | 56 + .../Classes/OpenAPIs/JSONEncodingHelper.swift | 45 + .../Classes/OpenAPIs/Models.swift | 129 ++ .../Classes/OpenAPIs/Models/Student.swift | 46 + .../OpenAPIs/OpenISO8601DateFormatter.swift | 56 + .../OpenAPIs/SynchronizedDictionary.swift | 26 + .../OpenAPIs/URLSessionImplementations.swift | 670 ++++++++++ .../Classes/OpenAPIs/Validation.swift | 161 +++ .../frontend/client/Package.swift | 33 + .../frontend/client/README.md | 51 + .../frontend/client/docs/Student.md | 13 + .../frontend/client/docs/StudentapiAPI.md | 308 +++++ .../frontend/client/git_push.sh | 57 + .../frontend/client/project.yml | 15 + .../frontend/openapi-schema.yml | 160 +++ .../frontend/openapitools.json | 7 + .../frontend/package-lock.json | 1136 +++++++++++++++++ .../frontend/package.json | 14 + 51 files changed, 4294 insertions(+) create mode 100644 openapi swift client generation/README.md create mode 100644 openapi swift client generation/backend/README.md create mode 100644 openapi swift client generation/backend/demo/core/__init__.py create mode 100644 openapi swift client generation/backend/demo/core/admin.py create mode 100644 openapi swift client generation/backend/demo/core/apps.py create mode 100644 openapi swift client generation/backend/demo/core/migrations/0001_initial.py create mode 100644 openapi swift client generation/backend/demo/core/migrations/__init__.py create mode 100644 openapi swift client generation/backend/demo/core/models.py create mode 100644 openapi swift client generation/backend/demo/core/serializers.py create mode 100644 openapi swift client generation/backend/demo/core/tests.py create mode 100644 openapi swift client generation/backend/demo/core/views.py create mode 100644 openapi swift client generation/backend/demo/db.sqlite3 create mode 100644 openapi swift client generation/backend/demo/demo/__init__.py create mode 100644 openapi swift client generation/backend/demo/demo/asgi.py create mode 100644 openapi swift client generation/backend/demo/demo/settings.py create mode 100644 openapi swift client generation/backend/demo/demo/urls.py create mode 100644 openapi swift client generation/backend/demo/demo/wsgi.py create mode 100644 openapi swift client generation/backend/demo/manage.py create mode 100644 openapi swift client generation/backend/requirements.txt create mode 100644 openapi swift client generation/frontend/README.md create mode 100644 openapi swift client generation/frontend/client/.gitignore create mode 100644 openapi swift client generation/frontend/client/.openapi-generator-ignore create mode 100644 openapi swift client generation/frontend/client/.openapi-generator/FILES create mode 100644 openapi swift client generation/frontend/client/.openapi-generator/VERSION create mode 100644 openapi swift client generation/frontend/client/.swiftformat create mode 100644 openapi swift client generation/frontend/client/Cartfile create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient.podspec create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIHelper.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIs.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIs/StudentapiAPI.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/CodableHelper.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Configuration.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Extensions.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/JSONDataEncoding.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/JSONEncodingHelper.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Models.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Models/Student.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/SynchronizedDictionary.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/URLSessionImplementations.swift create mode 100644 openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Validation.swift create mode 100644 openapi swift client generation/frontend/client/Package.swift create mode 100644 openapi swift client generation/frontend/client/README.md create mode 100644 openapi swift client generation/frontend/client/docs/Student.md create mode 100644 openapi swift client generation/frontend/client/docs/StudentapiAPI.md create mode 100644 openapi swift client generation/frontend/client/git_push.sh create mode 100644 openapi swift client generation/frontend/client/project.yml create mode 100644 openapi swift client generation/frontend/openapi-schema.yml create mode 100644 openapi swift client generation/frontend/openapitools.json create mode 100644 openapi swift client generation/frontend/package-lock.json create mode 100644 openapi swift client generation/frontend/package.json diff --git a/openapi swift client generation/README.md b/openapi swift client generation/README.md new file mode 100644 index 0000000..d41a14d --- /dev/null +++ b/openapi swift client generation/README.md @@ -0,0 +1,5 @@ +[Reference Link](https://github.com/ajaishankar/openapi-typescript-fetch) + +#### Steps to run the demo +- Follow Backend Readme +- Follow Frontend Readme \ No newline at end of file diff --git a/openapi swift client generation/backend/README.md b/openapi swift client generation/backend/README.md new file mode 100644 index 0000000..acf8786 --- /dev/null +++ b/openapi swift client generation/backend/README.md @@ -0,0 +1,13 @@ +[Reference Link](https://www.django-rest-framework.org/api-guide/schemas/) + +#### Steps + +- Generate Open Api Schema File + ```bash + ./manage.py generateschema --file '../../frontend/openapi-schema.yml' + ``` + +- Run Backend Server + ```bash + ./manage.py runserver + ``` diff --git a/openapi swift client generation/backend/demo/core/__init__.py b/openapi swift client generation/backend/demo/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/openapi swift client generation/backend/demo/core/admin.py b/openapi swift client generation/backend/demo/core/admin.py new file mode 100644 index 0000000..201d949 --- /dev/null +++ b/openapi swift client generation/backend/demo/core/admin.py @@ -0,0 +1,9 @@ +from django.contrib import admin +from .models import Student + +# Register your models here. + + +@admin.register(Student) +class StudentAdmin(admin.ModelAdmin): + list_display = ['id', 'name', 'roll', 'city'] diff --git a/openapi swift client generation/backend/demo/core/apps.py b/openapi swift client generation/backend/demo/core/apps.py new file mode 100644 index 0000000..8115ae6 --- /dev/null +++ b/openapi swift client generation/backend/demo/core/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class CoreConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'core' diff --git a/openapi swift client generation/backend/demo/core/migrations/0001_initial.py b/openapi swift client generation/backend/demo/core/migrations/0001_initial.py new file mode 100644 index 0000000..2916ad6 --- /dev/null +++ b/openapi swift client generation/backend/demo/core/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 4.0.5 on 2022-06-15 18:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Student', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ('roll', models.IntegerField()), + ('city', models.CharField(max_length=50)), + ], + ), + ] diff --git a/openapi swift client generation/backend/demo/core/migrations/__init__.py b/openapi swift client generation/backend/demo/core/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/openapi swift client generation/backend/demo/core/models.py b/openapi swift client generation/backend/demo/core/models.py new file mode 100644 index 0000000..1bcb589 --- /dev/null +++ b/openapi swift client generation/backend/demo/core/models.py @@ -0,0 +1,9 @@ +from django.db import models + +# Create your models here. + + +class Student(models.Model): + name = models.CharField(max_length=50) + roll = models.IntegerField() + city = models.CharField(max_length=50) diff --git a/openapi swift client generation/backend/demo/core/serializers.py b/openapi swift client generation/backend/demo/core/serializers.py new file mode 100644 index 0000000..1c7491e --- /dev/null +++ b/openapi swift client generation/backend/demo/core/serializers.py @@ -0,0 +1,8 @@ +from rest_framework import serializers +from .models import Student + + +class StudentSerializer(serializers.ModelSerializer): + class Meta: + model = Student + fields = ['id', 'name', 'roll', 'city'] diff --git a/openapi swift client generation/backend/demo/core/tests.py b/openapi swift client generation/backend/demo/core/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/openapi swift client generation/backend/demo/core/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/openapi swift client generation/backend/demo/core/views.py b/openapi swift client generation/backend/demo/core/views.py new file mode 100644 index 0000000..3b0a1f2 --- /dev/null +++ b/openapi swift client generation/backend/demo/core/views.py @@ -0,0 +1,10 @@ +from .models import Student +from .serializers import StudentSerializer +from rest_framework import viewsets + +# Create your views here. + + +class StudentModelViewSet(viewsets.ModelViewSet): + queryset = Student.objects.all() + serializer_class = StudentSerializer diff --git a/openapi swift client generation/backend/demo/db.sqlite3 b/openapi swift client generation/backend/demo/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..e8be118b3e3ad4280ce4807419da3b98bea42b5d GIT binary patch literal 135168 zcmeI5du$uYeaE?ct!Rl{$+FD5vwd38)}47e+56z~q3boFWlEMMOJ_aKmfOQ-NiM0i zNG{EXWciR5)cKMkY5!=71ZaUaMS=d&#~*Fb_FAMti=;)-6m8NXDbOY<`uHPlfFwnM zcjm7-E(MaQ6nq8uM& zS%<^%9Qrec{xm<+=)~Q;Kz~!V^Sw@=b6mQ0-GhypA7Yyz^F#l+{_poc)Bk6_uhQT1 z{g(Ihp1k{)UEgy4*ttY~!tv$3933{i@qv?caC4GsRJBr8y|2`38*;s>R^)s|ua~RF zxt299Wpt8=h!U6KGIG77-Rm?To?cERS5xfT;@r)(6g#(gHFcW}by^+ZG{i0~b|(t4 z7ehptmJL16hKM|*Clqc>4bj1Tf@&yM35?jXS}AJPs-~B!vUQFN5sze~OhQnJvM%G3 zW-09QyNvemXcOO+1Q(%A2NFLqNC#g*;&1FH-tdHUr+IyUW=@lA8&T z+Ph3&u;EHjyXOxjx2>=;m&uBPl;*6K(?w`-@AlJWYc{gfU0Jq zt!iv08NF0fOEtN+Q&w@45^|APRE?xb)mU~+k2`VMnpZ3A;?gR+xVEsszO+1d zBe}fJ&ZpMd5u>C}oXQ!|e+dlknn6G?N6bE|X7 zg@tu9Fm<)75q4|p@@}y>Tpr(=s}*8< zNMx@)=c9w8qtr*vw?QJmL-JZiD?G4V3?b|F2;zqk5 z=Y8lc8vk+ZUhvSti3#eppSQ|mQ6z=3F1CD^}0vv-wJUT=GN zo01NGIJKV7R?o!Qw1gYi+;mVEsm811X6uoatdz@gK}o9xxrp9G3UVx(&Wc$vO@^#KS6lfyA}`{5@OhLn+*qgR;N{EI zu3~3b)bbUjh6iIN7c0Qo<~P(8eR|qc`4p37#sdEw_{G2#|BwBj^>6zl1K%9@^uWslL;YXsf4zSdnZXAL00AHX1b_e# z00KY&2)v&Oh{GPox$$IGHI`jCj^kymq}4Q~AaH^($weo5iRI%{f-ogWm*NpVCdDqF z^f*SwlNr6D9+-d^ViI?42qn0c#N%$1fgme|8d|X;Q?k~im0VQr%LTQRuWj_oI+lnc zPahmao@Se#c)4CCvrFZQet*Zd!c*<(AtvxqX_`SEZZth`rWRu=0go~ck|9Y^AvPO8 zPS#8(T*6);GS_z)M`E0hM`rxU(Mr=%-0rA3?RStMJ{}e0^8?7wD@{K!)6bSt&=4QJ zf+pv(Sy`=A^om?Wb*<#po`|A}I2Y%V{m9u|(^*umpwXpPQJZrRcm<^@qna0bQI5tF z5iW7%1adLobRpTxWle_4rFx-fGmFNBSTy=UAM(+xYc68<(PE>QYrP8+jmD$gbRY82 ztZPoRdm!_i2cV5gVk9nHqmh$l!-*P0+AGp+}D5@SLna?R^;jL)L`hO9&pjF=+g zThzB&c#Rb*+=6=I6}XrXpYwPeL8K{L)Jn*Oh$olP;#Osc)H9xl)k|`&pycJuhOVJ` zfnKhpgeb(gq#L) zg#Ei5Nr;Mq5Tg(}+~u^P+dn5xkc60@`CSLiEIOJ0VHTOsGF!~YnO|eF@8>QZ$_500 z01yBIKmZ5;0U!VbfB+Bx0zlwV37m4dCMk2dpUfEG*#hUF-!)F**+8^8td6#;)||s$ z*96tE&E~AX-!;}p0?BOKz<_JiM=tSfj>Exx#WCcwdkK16Vly-Qo*5dIV#L>}VuW&C zZdzMA6^2hBW14y3V7|lr9rLfu=a}DQ9xxw&R1T0H2mk>f00e*l5C8%|00;m9AOHk_ z01z+;47x|okXZq9Qh+|?K6i#{?ldz0_MUZ*pGQ{KvcB!y<9CmYkZA-wL*Nd$M}p*v zOdq(0-6Lb<(%OpQ9C8QG`N+gXb3+8)|4%bJ4(8j;zc629{+#(V^D%S@A0Pk(fB+Bx z0zd!=00AHX1b_e#00KbZaS&i=w`1fCUe7nj|HEFlD8+=|q=f_|h8x4^eJM@Lb#YAFuzP^?%vHd>5_$|26X&=GU3m znIdzGnPno(7&FLFf$s*s5%~MS8-d>lydEe8el{>05CWqCzyAmR|3V4j0|bBo5C8%| z00;m9AOHk_01yBIKM?{a-PAZmZ)xgwbF=x`Q*J6u(df$wRrJlF=3w)T5s1ExwUloK zJ~iZ~&Qmo0Dg@K)N#f3HxHG;3;|Y?|+jM6H293a`J0tKkapxuOjF6GjZfcV95O=n5 z?5QW*6i<0fm$ryuBf@lRi#R#rrY0y4c5MqCV%*dyDU16?H0^w|t_4!V8gXahjD z^(_W?{hwk!%#oimD}RYYa99K z=GM;jISzf7p|Vlm&K8q*cCwND+^yQZ>1(l7Ei)Z|(fIbk#3U!O0zbv^Q)1*&Op1#! zzM|{3uJ0z4_)Afgvn1m6e~S5m1O1P`Hvm3B00;m9AOHk_01yBIKmZ5;0U!VbfWZ5R z0PPy_;h6!v{_hxk9~BIW0tA2n5C8%|00;m9AOHk_01yBIKmZ7I5y0brCxia||2NSA zK0p8n00AHX1b_e#00KY&2mk>f00e-*dxF4-)8jZtok^xQwCaYs>AbGgOXYecNO>IR zeP>pb+Ky6WSJc|ZLOrut(znU@-~T6$z}L_LK0p8n00AHX1b_e#00KY&2mk>f@Gc{; z8*+MXyta}o@p*AOqU`89nVhmyQWDv;D2NZ#D!)~h;#~BSdj0;(cW+dewzcHi@=KF5 zwUycU%{#feeDlsuJ z?B<>MY~sOmWJbIP(t_s0U!VbfB+Bx0zd!=00AHX1b_e#IPL^IE{dYh zlH(b2e2N^O#7FNFJyGHJ6`M{)&Cvu>%pZ-s=;fe zta@Lm*EZyORjtVRie4{QjdLw4M-^UBv+;DN!KvxxRB|=N&MjU|-DX3b(Ov07?9yVl zS%|$DBDreWP`L4dlXP$sNviHIi71qjwnRjfxD1z(>m}`8r-ETq;M(Hc&9#Gd_I7%( z>gU-|Gbt*;)DRuaC#Z&EmB5HCtCgZwt!jFyDqH8c5b;Px$|MAp=<;ls2VZuS<8;;Q72Zcyq6c7Zp#|CpN<4b=8B(&o7ij&7ON`U#I4Q` zw;Ssw-sSq~;N&FraJZ(V3q}`cdkA%Q=>uj1UQJ$ENcDc0pyvpyp}QfkR@lX*Rd#W0 zVS#;VdG1DXd7Yh4t+UCs)up*b_?}p zRIA&11wq|XDwz$Xa*-F};TBm`&Vo{{$pt;Hl|pP*si`%ssM_PTs$8w3djWF}v1wf| z*kf^MNhzw9f047?v&OR<<&x7XD4V@4n?m-rP>YIIuyTq?R!%5A7Fttsxo(jtM#$M$U&263ZZkn=uN4j+Dp-)#&I)9!vmaL$(-yj|SJ%#gQ5y@pQPm37a17K6*#) z)t8*!;KT&APQaS|WmUabS4$bSfJup{y!z6YO2DZ`C*iVj}BOzkSfXZEgA%Ik7b z%U6^d9*lJbINSV&y5f&iBTBh!J$D4D{lU}TUv$Qzqy??_(*@T5aeoLOAOHk_01yBI zKmZ5;0U!VbfB+Bx0`G4EepI|u4&A}r4V3+VJn-KqzIo!Oe81E8jlPrKZ=rnvMdzEY zkGuZT`B&7BC@=LF$neoVjZ-l?xDuus2{L_c&Wu!5vZ^hs_sd#EmC1y-B4wgNG%B{6 zjF~el=8l2($e!tqmB)5NJpW?L3oSZEB{~=mQ@hXFXLw9m?P>da&h40{*m1Kko9d1= zUlXy<;Mx{T(2Q8q9+g@Nu{HI6&Azx{m)T=+;Dx9+xD?)N7Pwux%(q{&jZ}mVj*nBj zH%O^7I$~d~)w5_B*nZxz7-Ww+(nMDKT$N-agJ@Lr0$N__Tzx|k8LejHX-^gA#kaab z($^T`XfmN+Bt^HT@vXDwO1FKX(7rCwC34>-!uCS*cKzlGRaoTT`i%bQYtISvzDs$% z)+KB+wr{NzM_tN83#h0H-|8}6FG|P_SuNa$Co<_+r4yvc+r3POGVQg#*j5Cz1>@Pr zumvN~-UpHvYpn}BmMs|1(7~MvYL~Hg#q5(oMn^pcnk$z%UP+5FNwGG>SgE|G=pH+% zETb;%yz22&?x6UzDc64UTgFG~_BwaEbl-XQbxO0V zwkI-kJ$TzdtIXDdJJ;UJw%X?~z z(^)Yqrb)&3Q10$o`8^Ex_uTdUq*G#GAN9HoOY+G}~!-cnk&-FI^&ol)azx>MSj1Ekq23~x=#n11$_*pVU>e(mR; zCYyvldfDC*T2ea|o$J{KTINS<0BHM%UXtRiKHNOQjreIg zm_dbEKd3OoBf4djgrq82-nIj~v)oS}x)_~44^sd$4U)b+g0|fHlGN_y!)k9Uyv#?G zXgVqi)=LKQ-C3L`%;NNT-{@)I>Oc3%?X46P-Op{FP|1f+(ZQRjx0E^xP6icKYx{2^ zCP@h?60us6VR3q|8rsW2r(VMjw&00;m9AOHk_01yBIKmZ5; z0U+>RAOPe4_d+d!Mj!wLfB+Bx0zd!=00AHX1b_e#00NIj0LK51#t%{h0U!VbfB+Bx z0zd!=00AHX1b_e#crOsZ<9{dfJqPncbbt>K00KY&2mk>f00e*l5C8%|00;m9An^Vn z;BiqD?R2{+A8m~P-*hlPV%~iJ6c9=R1b_e#00KY&2mk>f00e*l5C8%|002{*{qrkO|h?j_`|Qz zGt}OGgv6z2Oc105-|2_%@`K0!XZyeCV7|_LhWQ01%}g-^fqx79QQ%X7N?qRXa5=n10AYp61Q=i5?cTt5>exp|waEUTs})9$ok*HmTM zHB}iQ>`ceG&q|3~|Wnl_1 zY)%+9rh=A@DS=#{^&y+lXI)rB%K(cY7Z>|b?1bnfDy(1GYe}(!o~M!J<(SjdV?|(F zQyw|Wcm01zk+LUJnKI1{wVcv-~TA|n!3$;QnxIGTvvpf-teyA1wxO!!$B^3p* zB;=wCSxrc$P`jNe)3S6DOH-uX(v;Y;3{l8({4y43H^cH;Hn#8oV}1gi7GwzofB+Bx z0zd!=00AHX1b_e#00KY&2)qLXjDP?ChJ$&7`T9GM9b^FnfB+Bx0zd!=00AHX1b_e# z00KY&2ppck1=kI##OKBBh_a*aWOB+*Nl9eWq98s{tNd13igQutdDji!{iZb|tCicM0$@@?8S_lo+`bi$-`p<~-+0nqM^#ofHx*AD 0.6 diff --git a/openapi swift client generation/frontend/client/OpenAPIClient.podspec b/openapi swift client generation/frontend/client/OpenAPIClient.podspec new file mode 100644 index 0000000..4ea84be --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient.podspec @@ -0,0 +1,15 @@ +Pod::Spec.new do |s| + s.name = 'OpenAPIClient' + s.ios.deployment_target = '11.0' + s.osx.deployment_target = '10.13' + s.tvos.deployment_target = '11.0' + s.watchos.deployment_target = '4.0' + s.version = '' + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v' } + s.authors = 'OpenAPI Generator' + s.license = 'Proprietary' + s.homepage = 'https://github.com/OpenAPITools/openapi-generator' + s.summary = 'OpenAPIClient Swift SDK' + s.source_files = 'OpenAPIClient/Classes/**/*.swift' + s.dependency 'AnyCodable-FlightSchool', '~> 0.6' +end diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIHelper.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIHelper.swift new file mode 100644 index 0000000..7c975bb --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIHelper.swift @@ -0,0 +1,121 @@ +// APIHelper.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +public struct APIHelper { + public static func rejectNil(_ source: [String: Any?]) -> [String: Any]? { + let destination = source.reduce(into: [String: Any]()) { result, item in + if let value = item.value { + result[item.key] = value + } + } + + if destination.isEmpty { + return nil + } + return destination + } + + public static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] { + return source.reduce(into: [String: String]()) { result, item in + if let collection = item.value as? [Any?] { + result[item.key] = collection + .compactMap { value in convertAnyToString(value) } + .joined(separator: ",") + } else if let value: Any = item.value { + result[item.key] = convertAnyToString(value) + } + } + } + + public static func convertBoolToString(_ source: [String: Any]?) -> [String: Any]? { + guard let source = source else { + return nil + } + + return source.reduce(into: [String: Any]()) { result, item in + switch item.value { + case let x as Bool: + result[item.key] = x.description + default: + result[item.key] = item.value + } + } + } + + public static func convertAnyToString(_ value: Any?) -> String? { + guard let value = value else { return nil } + if let value = value as? any RawRepresentable { + return "\(value.rawValue)" + } else { + return "\(value)" + } + } + + public static func mapValueToPathItem(_ source: Any) -> Any { + if let collection = source as? [Any?] { + return collection + .compactMap { value in convertAnyToString(value) } + .joined(separator: ",") + } else if let value = source as? any RawRepresentable { + return "\(value.rawValue)" + } + return source + } + + /// maps all values from source to query parameters + /// + /// explode attribute is respected: collection values might be either joined or split up into separate key value pairs + public static func mapValuesToQueryItems(_ source: [String: (wrappedValue: Any?, isExplode: Bool)]) -> [URLQueryItem]? { + let destination = source.filter { $0.value.wrappedValue != nil }.reduce(into: [URLQueryItem]()) { result, item in + if let collection = item.value.wrappedValue as? [Any?] { + + let collectionValues: [String] = collection.compactMap { value in convertAnyToString(value) } + + if !item.value.isExplode { + result.append(URLQueryItem(name: item.key, value: collectionValues.joined(separator: ","))) + } else { + collectionValues + .forEach { value in + result.append(URLQueryItem(name: item.key, value: value)) + } + } + + } else if let value = item.value.wrappedValue { + result.append(URLQueryItem(name: item.key, value: convertAnyToString(value))) + } + } + + if destination.isEmpty { + return nil + } + return destination.sorted { $0.name < $1.name } + } + + /// maps all values from source to query parameters + /// + /// collection values are always exploded + public static func mapValuesToQueryItems(_ source: [String: Any?]) -> [URLQueryItem]? { + let destination = source.filter { $0.value != nil }.reduce(into: [URLQueryItem]()) { result, item in + if let collection = item.value as? [Any?] { + collection + .compactMap { value in convertAnyToString(value) } + .forEach { value in + result.append(URLQueryItem(name: item.key, value: value)) + } + + } else if let value = item.value { + result.append(URLQueryItem(name: item.key, value: convertAnyToString(value))) + } + } + + if destination.isEmpty { + return nil + } + return destination.sorted { $0.name < $1.name } + } +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIs.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIs.swift new file mode 100644 index 0000000..bcee0e5 --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIs.swift @@ -0,0 +1,68 @@ +// APIs.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif +open class OpenAPIClientAPI { + public static var basePath = "http://localhost" + public static var customHeaders: [String: String] = [:] + public static var credential: URLCredential? + public static var requestBuilderFactory: RequestBuilderFactory = URLSessionRequestBuilderFactory() + public static var apiResponseQueue: DispatchQueue = .main +} + +open class RequestBuilder { + var credential: URLCredential? + var headers: [String: String] + public let parameters: [String: Any]? + public let method: String + public let URLString: String + public let requestTask: RequestTask = RequestTask() + public let requiresAuthentication: Bool + + /// Optional block to obtain a reference to the request's progress instance when available. + public var onProgressReady: ((Progress) -> Void)? + + required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:], requiresAuthentication: Bool) { + self.method = method + self.URLString = URLString + self.parameters = parameters + self.headers = headers + self.requiresAuthentication = requiresAuthentication + + addHeaders(OpenAPIClientAPI.customHeaders) + } + + open func addHeaders(_ aHeaders: [String: String]) { + for (header, value) in aHeaders { + headers[header] = value + } + } + + @discardableResult + open func execute(_ apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result, ErrorResponse>) -> Void) -> RequestTask { + return requestTask + } + + public func addHeader(name: String, value: String) -> Self { + if !value.isEmpty { + headers[name] = value + } + return self + } + + open func addCredential() -> Self { + credential = OpenAPIClientAPI.credential + return self + } +} + +public protocol RequestBuilderFactory { + func getNonDecodableBuilder() -> RequestBuilder.Type + func getBuilder() -> RequestBuilder.Type +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIs/StudentapiAPI.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIs/StudentapiAPI.swift new file mode 100644 index 0000000..5809f9e --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/APIs/StudentapiAPI.swift @@ -0,0 +1,280 @@ +// +// StudentapiAPI.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +#if canImport(AnyCodable) +import AnyCodable +#endif + +open class StudentapiAPI { + + /** + + - parameter student: (body) (optional) + - parameter apiResponseQueue: The queue on which api response is dispatched. + - parameter completion: completion handler to receive the data and the error objects + */ + @discardableResult + open class func createStudent(student: Student? = nil, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: Student?, _ error: Error?) -> Void)) -> RequestTask { + return createStudentWithRequestBuilder(student: student).execute(apiResponseQueue) { result in + switch result { + case let .success(response): + completion(response.body, nil) + case let .failure(error): + completion(nil, error) + } + } + } + + /** + - POST /studentapi/ + - + - parameter student: (body) (optional) + - returns: RequestBuilder + */ + open class func createStudentWithRequestBuilder(student: Student? = nil) -> RequestBuilder { + let localVariablePath = "/studentapi/" + let localVariableURLString = OpenAPIClientAPI.basePath + localVariablePath + let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: student) + + let localVariableUrlComponents = URLComponents(string: localVariableURLString) + + let localVariableNillableHeaders: [String: Any?] = [ + "Content-Type": "application/json", + ] + + let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders) + + let localVariableRequestBuilder: RequestBuilder.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder() + + return localVariableRequestBuilder.init(method: "POST", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false) + } + + /** + + - parameter id: (path) A unique integer value identifying this student. + - parameter apiResponseQueue: The queue on which api response is dispatched. + - parameter completion: completion handler to receive the data and the error objects + */ + @discardableResult + open class func destroyStudent(id: String, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) -> RequestTask { + return destroyStudentWithRequestBuilder(id: id).execute(apiResponseQueue) { result in + switch result { + case .success: + completion((), nil) + case let .failure(error): + completion(nil, error) + } + } + } + + /** + - DELETE /studentapi/{id}/ + - + - parameter id: (path) A unique integer value identifying this student. + - returns: RequestBuilder + */ + open class func destroyStudentWithRequestBuilder(id: String) -> RequestBuilder { + var localVariablePath = "/studentapi/{id}/" + let idPreEscape = "\(APIHelper.mapValueToPathItem(id))" + let idPostEscape = idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" + localVariablePath = localVariablePath.replacingOccurrences(of: "{id}", with: idPostEscape, options: .literal, range: nil) + let localVariableURLString = OpenAPIClientAPI.basePath + localVariablePath + let localVariableParameters: [String: Any]? = nil + + let localVariableUrlComponents = URLComponents(string: localVariableURLString) + + let localVariableNillableHeaders: [String: Any?] = [ + : + ] + + let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders) + + let localVariableRequestBuilder: RequestBuilder.Type = OpenAPIClientAPI.requestBuilderFactory.getNonDecodableBuilder() + + return localVariableRequestBuilder.init(method: "DELETE", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false) + } + + /** + + - parameter apiResponseQueue: The queue on which api response is dispatched. + - parameter completion: completion handler to receive the data and the error objects + */ + @discardableResult + open class func listStudents(apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: [Student]?, _ error: Error?) -> Void)) -> RequestTask { + return listStudentsWithRequestBuilder().execute(apiResponseQueue) { result in + switch result { + case let .success(response): + completion(response.body, nil) + case let .failure(error): + completion(nil, error) + } + } + } + + /** + - GET /studentapi/ + - + - returns: RequestBuilder<[Student]> + */ + open class func listStudentsWithRequestBuilder() -> RequestBuilder<[Student]> { + let localVariablePath = "/studentapi/" + let localVariableURLString = OpenAPIClientAPI.basePath + localVariablePath + let localVariableParameters: [String: Any]? = nil + + let localVariableUrlComponents = URLComponents(string: localVariableURLString) + + let localVariableNillableHeaders: [String: Any?] = [ + : + ] + + let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders) + + let localVariableRequestBuilder: RequestBuilder<[Student]>.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder() + + return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false) + } + + /** + + - parameter id: (path) A unique integer value identifying this student. + - parameter student: (body) (optional) + - parameter apiResponseQueue: The queue on which api response is dispatched. + - parameter completion: completion handler to receive the data and the error objects + */ + @discardableResult + open class func partialUpdateStudent(id: String, student: Student? = nil, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: Student?, _ error: Error?) -> Void)) -> RequestTask { + return partialUpdateStudentWithRequestBuilder(id: id, student: student).execute(apiResponseQueue) { result in + switch result { + case let .success(response): + completion(response.body, nil) + case let .failure(error): + completion(nil, error) + } + } + } + + /** + - PATCH /studentapi/{id}/ + - + - parameter id: (path) A unique integer value identifying this student. + - parameter student: (body) (optional) + - returns: RequestBuilder + */ + open class func partialUpdateStudentWithRequestBuilder(id: String, student: Student? = nil) -> RequestBuilder { + var localVariablePath = "/studentapi/{id}/" + let idPreEscape = "\(APIHelper.mapValueToPathItem(id))" + let idPostEscape = idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" + localVariablePath = localVariablePath.replacingOccurrences(of: "{id}", with: idPostEscape, options: .literal, range: nil) + let localVariableURLString = OpenAPIClientAPI.basePath + localVariablePath + let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: student) + + let localVariableUrlComponents = URLComponents(string: localVariableURLString) + + let localVariableNillableHeaders: [String: Any?] = [ + "Content-Type": "application/json", + ] + + let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders) + + let localVariableRequestBuilder: RequestBuilder.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder() + + return localVariableRequestBuilder.init(method: "PATCH", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false) + } + + /** + + - parameter id: (path) A unique integer value identifying this student. + - parameter apiResponseQueue: The queue on which api response is dispatched. + - parameter completion: completion handler to receive the data and the error objects + */ + @discardableResult + open class func retrieveStudent(id: String, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: Student?, _ error: Error?) -> Void)) -> RequestTask { + return retrieveStudentWithRequestBuilder(id: id).execute(apiResponseQueue) { result in + switch result { + case let .success(response): + completion(response.body, nil) + case let .failure(error): + completion(nil, error) + } + } + } + + /** + - GET /studentapi/{id}/ + - + - parameter id: (path) A unique integer value identifying this student. + - returns: RequestBuilder + */ + open class func retrieveStudentWithRequestBuilder(id: String) -> RequestBuilder { + var localVariablePath = "/studentapi/{id}/" + let idPreEscape = "\(APIHelper.mapValueToPathItem(id))" + let idPostEscape = idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" + localVariablePath = localVariablePath.replacingOccurrences(of: "{id}", with: idPostEscape, options: .literal, range: nil) + let localVariableURLString = OpenAPIClientAPI.basePath + localVariablePath + let localVariableParameters: [String: Any]? = nil + + let localVariableUrlComponents = URLComponents(string: localVariableURLString) + + let localVariableNillableHeaders: [String: Any?] = [ + : + ] + + let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders) + + let localVariableRequestBuilder: RequestBuilder.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder() + + return localVariableRequestBuilder.init(method: "GET", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false) + } + + /** + + - parameter id: (path) A unique integer value identifying this student. + - parameter student: (body) (optional) + - parameter apiResponseQueue: The queue on which api response is dispatched. + - parameter completion: completion handler to receive the data and the error objects + */ + @discardableResult + open class func updateStudent(id: String, student: Student? = nil, apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, completion: @escaping ((_ data: Student?, _ error: Error?) -> Void)) -> RequestTask { + return updateStudentWithRequestBuilder(id: id, student: student).execute(apiResponseQueue) { result in + switch result { + case let .success(response): + completion(response.body, nil) + case let .failure(error): + completion(nil, error) + } + } + } + + /** + - PUT /studentapi/{id}/ + - + - parameter id: (path) A unique integer value identifying this student. + - parameter student: (body) (optional) + - returns: RequestBuilder + */ + open class func updateStudentWithRequestBuilder(id: String, student: Student? = nil) -> RequestBuilder { + var localVariablePath = "/studentapi/{id}/" + let idPreEscape = "\(APIHelper.mapValueToPathItem(id))" + let idPostEscape = idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" + localVariablePath = localVariablePath.replacingOccurrences(of: "{id}", with: idPostEscape, options: .literal, range: nil) + let localVariableURLString = OpenAPIClientAPI.basePath + localVariablePath + let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: student) + + let localVariableUrlComponents = URLComponents(string: localVariableURLString) + + let localVariableNillableHeaders: [String: Any?] = [ + "Content-Type": "application/json", + ] + + let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders) + + let localVariableRequestBuilder: RequestBuilder.Type = OpenAPIClientAPI.requestBuilderFactory.getBuilder() + + return localVariableRequestBuilder.init(method: "PUT", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters, requiresAuthentication: false) + } +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/CodableHelper.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/CodableHelper.swift new file mode 100644 index 0000000..09c82e5 --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/CodableHelper.swift @@ -0,0 +1,49 @@ +// +// CodableHelper.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +open class CodableHelper { + private static var customDateFormatter: DateFormatter? + private static var defaultDateFormatter: DateFormatter = OpenISO8601DateFormatter() + + private static var customJSONDecoder: JSONDecoder? + private static var defaultJSONDecoder: JSONDecoder = { + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .formatted(CodableHelper.dateFormatter) + return decoder + }() + + private static var customJSONEncoder: JSONEncoder? + private static var defaultJSONEncoder: JSONEncoder = { + let encoder = JSONEncoder() + encoder.dateEncodingStrategy = .formatted(CodableHelper.dateFormatter) + encoder.outputFormatting = .prettyPrinted + return encoder + }() + + public static var dateFormatter: DateFormatter { + get { return customDateFormatter ?? defaultDateFormatter } + set { customDateFormatter = newValue } + } + public static var jsonDecoder: JSONDecoder { + get { return customJSONDecoder ?? defaultJSONDecoder } + set { customJSONDecoder = newValue } + } + public static var jsonEncoder: JSONEncoder { + get { return customJSONEncoder ?? defaultJSONEncoder } + set { customJSONEncoder = newValue } + } + + open class func decode(_ type: T.Type, from data: Data) -> Swift.Result where T: Decodable { + return Swift.Result { try jsonDecoder.decode(type, from: data) } + } + + open class func encode(_ value: T) -> Swift.Result where T: Encodable { + return Swift.Result { try jsonEncoder.encode(value) } + } +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Configuration.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Configuration.swift new file mode 100644 index 0000000..0457d99 --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Configuration.swift @@ -0,0 +1,18 @@ +// Configuration.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif + +open class Configuration { + + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Extensions.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Extensions.swift new file mode 100644 index 0000000..286c500 --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Extensions.swift @@ -0,0 +1,236 @@ +// Extensions.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif +#if canImport(AnyCodable) +import AnyCodable +#endif + +extension Bool: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension Float: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension Int: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension Int32: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension Int64: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension Double: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension Decimal: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension String: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension URL: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension UUID: JSONEncodable { + func encodeToJSON() -> Any { self } +} + +extension RawRepresentable where RawValue: JSONEncodable { + func encodeToJSON() -> Any { return self.rawValue } +} + +private func encodeIfPossible(_ object: T) -> Any { + if let encodableObject = object as? JSONEncodable { + return encodableObject.encodeToJSON() + } else { + return object + } +} + +extension Array: JSONEncodable { + func encodeToJSON() -> Any { + return self.map(encodeIfPossible) + } +} + +extension Set: JSONEncodable { + func encodeToJSON() -> Any { + return Array(self).encodeToJSON() + } +} + +extension Dictionary: JSONEncodable { + func encodeToJSON() -> Any { + var dictionary = [AnyHashable: Any]() + for (key, value) in self { + dictionary[key] = encodeIfPossible(value) + } + return dictionary + } +} + +extension Data: JSONEncodable { + func encodeToJSON() -> Any { + return self.base64EncodedString(options: Data.Base64EncodingOptions()) + } +} + +extension Date: JSONEncodable { + func encodeToJSON() -> Any { + return CodableHelper.dateFormatter.string(from: self) + } +} + +extension JSONEncodable where Self: Encodable { + func encodeToJSON() -> Any { + guard let data = try? CodableHelper.jsonEncoder.encode(self) else { + fatalError("Could not encode to json: \(self)") + } + return data.encodeToJSON() + } +} + +extension String: CodingKey { + + public var stringValue: String { + return self + } + + public init?(stringValue: String) { + self.init(stringLiteral: stringValue) + } + + public var intValue: Int? { + return nil + } + + public init?(intValue: Int) { + return nil + } + +} + +extension KeyedEncodingContainerProtocol { + + public mutating func encodeArray(_ values: [T], forKey key: Self.Key) throws where T: Encodable { + var arrayContainer = nestedUnkeyedContainer(forKey: key) + try arrayContainer.encode(contentsOf: values) + } + + public mutating func encodeArrayIfPresent(_ values: [T]?, forKey key: Self.Key) throws where T: Encodable { + if let values = values { + try encodeArray(values, forKey: key) + } + } + + public mutating func encodeMap(_ pairs: [Self.Key: T]) throws where T: Encodable { + for (key, value) in pairs { + try encode(value, forKey: key) + } + } + + public mutating func encodeMapIfPresent(_ pairs: [Self.Key: T]?) throws where T: Encodable { + if let pairs = pairs { + try encodeMap(pairs) + } + } + + public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws { + let decimalNumber = NSDecimalNumber(decimal: value) + let numberFormatter = NumberFormatter() + numberFormatter.numberStyle = .decimal + numberFormatter.locale = Locale(identifier: "en_US") + let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)" + try encode(formattedString, forKey: key) + } + + public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws { + if let value = value { + try encode(value, forKey: key) + } + } +} + +extension KeyedDecodingContainerProtocol { + + public func decodeArray(_ type: T.Type, forKey key: Self.Key) throws -> [T] where T: Decodable { + var tmpArray = [T]() + + var nestedContainer = try nestedUnkeyedContainer(forKey: key) + while !nestedContainer.isAtEnd { + let arrayValue = try nestedContainer.decode(T.self) + tmpArray.append(arrayValue) + } + + return tmpArray + } + + public func decodeArrayIfPresent(_ type: T.Type, forKey key: Self.Key) throws -> [T]? where T: Decodable { + var tmpArray: [T]? + + if contains(key) { + tmpArray = try decodeArray(T.self, forKey: key) + } + + return tmpArray + } + + public func decodeMap(_ type: T.Type, excludedKeys: Set) throws -> [Self.Key: T] where T: Decodable { + var map: [Self.Key: T] = [:] + + for key in allKeys { + if !excludedKeys.contains(key) { + let value = try decode(T.self, forKey: key) + map[key] = value + } + } + + return map + } + + public func decode(_ type: Decimal.Type, forKey key: Self.Key) throws -> Decimal { + let stringValue = try decode(String.self, forKey: key) + guard let decimalValue = Decimal(string: stringValue) else { + let context = DecodingError.Context(codingPath: [key], debugDescription: "The key \(key) couldn't be converted to a Decimal value") + throw DecodingError.typeMismatch(type, context) + } + + return decimalValue + } + + public func decodeIfPresent(_ type: Decimal.Type, forKey key: Self.Key) throws -> Decimal? { + guard let stringValue = try decodeIfPresent(String.self, forKey: key) else { + return nil + } + guard let decimalValue = Decimal(string: stringValue) else { + let context = DecodingError.Context(codingPath: [key], debugDescription: "The key \(key) couldn't be converted to a Decimal value") + throw DecodingError.typeMismatch(type, context) + } + + return decimalValue + } + +} + +extension HTTPURLResponse { + var isStatusCodeSuccessful: Bool { + return Configuration.successfulStatusCodeRange.contains(statusCode) + } +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/JSONDataEncoding.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/JSONDataEncoding.swift new file mode 100644 index 0000000..cb3121a --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/JSONDataEncoding.swift @@ -0,0 +1,56 @@ +// +// JSONDataEncoding.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif + +public struct JSONDataEncoding { + + // MARK: Properties + + private static let jsonDataKey = "jsonData" + + // MARK: Encoding + + /// Creates a URL request by encoding parameters and applying them onto an existing request. + /// + /// - parameter urlRequest: The request to have parameters applied. + /// - parameter parameters: The parameters to apply. This should have a single key/value + /// pair with "jsonData" as the key and a Data object as the value. + /// + /// - throws: An `Error` if the encoding process encounters an error. + /// + /// - returns: The encoded request. + public func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) -> URLRequest { + var urlRequest = urlRequest + + guard let jsonData = parameters?[JSONDataEncoding.jsonDataKey] as? Data, !jsonData.isEmpty else { + return urlRequest + } + + if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { + urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") + } + + urlRequest.httpBody = jsonData + + return urlRequest + } + + public static func encodingParameters(jsonData: Data?) -> [String: Any]? { + var returnedParams: [String: Any]? + if let jsonData = jsonData, !jsonData.isEmpty { + var params: [String: Any] = [:] + params[jsonDataKey] = jsonData + returnedParams = params + } + return returnedParams + } + +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/JSONEncodingHelper.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/JSONEncodingHelper.swift new file mode 100644 index 0000000..02f78ff --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -0,0 +1,45 @@ +// +// JSONEncodingHelper.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +open class JSONEncodingHelper { + + open class func encodingParameters(forEncodableObject encodableObj: T?) -> [String: Any]? { + var params: [String: Any]? + + // Encode the Encodable object + if let encodableObj = encodableObj { + let encodeResult = CodableHelper.encode(encodableObj) + do { + let data = try encodeResult.get() + params = JSONDataEncoding.encodingParameters(jsonData: data) + } catch { + print(error.localizedDescription) + } + } + + return params + } + + open class func encodingParameters(forEncodableObject encodableObj: Any?) -> [String: Any]? { + var params: [String: Any]? + + if let encodableObj = encodableObj { + do { + let data = try JSONSerialization.data(withJSONObject: encodableObj, options: .prettyPrinted) + params = JSONDataEncoding.encodingParameters(jsonData: data) + } catch { + print(error.localizedDescription) + return nil + } + } + + return params + } + +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Models.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Models.swift new file mode 100644 index 0000000..e6dc494 --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Models.swift @@ -0,0 +1,129 @@ +// Models.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif + +protocol JSONEncodable { + func encodeToJSON() -> Any +} + +/// An enum where the last case value can be used as a default catch-all. +protocol CaseIterableDefaultsLast: Decodable & CaseIterable & RawRepresentable +where RawValue: Decodable, AllCases: BidirectionalCollection {} + +extension CaseIterableDefaultsLast { + /// Initializes an enum such that if a known raw value is found, then it is decoded. + /// Otherwise the last case is used. + /// - Parameter decoder: A decoder. + public init(from decoder: Decoder) throws { + if let value = try Self(rawValue: decoder.singleValueContainer().decode(RawValue.self)) { + self = value + } else if let lastValue = Self.allCases.last { + self = lastValue + } else { + throw DecodingError.valueNotFound( + Self.Type.self, + .init(codingPath: decoder.codingPath, debugDescription: "CaseIterableDefaultsLast") + ) + } + } +} + +/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`) +/// or not encoded (`.encodeNothing`). Intended for request payloads. +public enum NullEncodable: Hashable { + case encodeNothing + case encodeNull + case encodeValue(Wrapped) +} + +extension NullEncodable: Codable where Wrapped: Codable { + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + if let value = try? container.decode(Wrapped.self) { + self = .encodeValue(value) + } else if container.decodeNil() { + self = .encodeNull + } else { + self = .encodeNothing + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + switch self { + case .encodeNothing: return + case .encodeNull: try container.encodeNil() + case .encodeValue(let wrapped): try container.encode(wrapped) + } + } +} + +public enum ErrorResponse: Error { + case error(Int, Data?, URLResponse?, Error) +} + +public enum DownloadException: Error { + case responseDataMissing + case responseFailed + case requestMissing + case requestMissingPath + case requestMissingURL +} + +public enum DecodableRequestBuilderError: Error { + case emptyDataResponse + case nilHTTPResponse + case unsuccessfulHTTPStatusCode + case jsonDecoding(DecodingError) + case generalError(Error) +} + +open class Response { + public let statusCode: Int + public let header: [String: String] + public let body: T + public let bodyData: Data? + + public init(statusCode: Int, header: [String: String], body: T, bodyData: Data?) { + self.statusCode = statusCode + self.header = header + self.body = body + self.bodyData = bodyData + } + + public convenience init(response: HTTPURLResponse, body: T, bodyData: Data?) { + let rawHeader = response.allHeaderFields + var responseHeader = [String: String]() + for (key, value) in rawHeader { + if let key = key.base as? String, let value = value as? String { + responseHeader[key] = value + } + } + self.init(statusCode: response.statusCode, header: responseHeader, body: body, bodyData: bodyData) + } +} + +public final class RequestTask { + private let lock = NSRecursiveLock() + private var task: URLSessionDataTaskProtocol? + + internal func set(task: URLSessionDataTaskProtocol) { + lock.lock() + defer { lock.unlock() } + self.task = task + } + + public func cancel() { + lock.lock() + defer { lock.unlock() } + task?.cancel() + task = nil + } +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Models/Student.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Models/Student.swift new file mode 100644 index 0000000..8018fb2 --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Models/Student.swift @@ -0,0 +1,46 @@ +// +// Student.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +#if canImport(AnyCodable) +import AnyCodable +#endif + +public struct Student: Codable, JSONEncodable, Hashable { + + static let nameRule = StringRule(minLength: nil, maxLength: 50, pattern: nil) + static let cityRule = StringRule(minLength: nil, maxLength: 50, pattern: nil) + public var id: Int? + public var name: String + public var roll: Int + public var city: String + + public init(id: Int? = nil, name: String, roll: Int, city: String) { + self.id = id + self.name = name + self.roll = roll + self.city = city + } + + public enum CodingKeys: String, CodingKey, CaseIterable { + case id + case name + case roll + case city + } + + // Encodable protocol methods + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(id, forKey: .id) + try container.encode(name, forKey: .name) + try container.encode(roll, forKey: .roll) + try container.encode(city, forKey: .city) + } +} + diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift new file mode 100644 index 0000000..cc32888 --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift @@ -0,0 +1,56 @@ +// +// OpenISO8601DateFormatter.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +// https://stackoverflow.com/a/50281094/976628 +public class OpenISO8601DateFormatter: DateFormatter { + static let withoutSeconds: DateFormatter = { + let formatter = DateFormatter() + formatter.calendar = Calendar(identifier: .iso8601) + formatter.locale = Locale(identifier: "en_US_POSIX") + formatter.timeZone = TimeZone(secondsFromGMT: 0) + formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" + return formatter + }() + + static let withoutTime: DateFormatter = { + let formatter = DateFormatter() + formatter.calendar = Calendar(identifier: .iso8601) + formatter.locale = Locale(identifier: "en_US_POSIX") + formatter.timeZone = TimeZone(secondsFromGMT: 0) + formatter.dateFormat = "yyyy-MM-dd" + return formatter + }() + + private func setup() { + calendar = Calendar(identifier: .iso8601) + locale = Locale(identifier: "en_US_POSIX") + timeZone = TimeZone(secondsFromGMT: 0) + dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + } + + override init() { + super.init() + setup() + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + setup() + } + + override public func date(from string: String) -> Date? { + if let result = super.date(from: string) { + return result + } else if let result = OpenISO8601DateFormatter.withoutSeconds.date(from: string) { + return result + } + + return OpenISO8601DateFormatter.withoutTime.date(from: string) + } +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/SynchronizedDictionary.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/SynchronizedDictionary.swift new file mode 100644 index 0000000..fbaa624 --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/SynchronizedDictionary.swift @@ -0,0 +1,26 @@ +// SynchronizedDictionary.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +internal struct SynchronizedDictionary { + + private var dictionary = [K: V]() + private let lock = NSRecursiveLock() + + internal subscript(key: K) -> V? { + get { + lock.lock() + defer { lock.unlock() } + return self.dictionary[key] + } + set { + lock.lock() + defer { lock.unlock() } + self.dictionary[key] = newValue + } + } +} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/URLSessionImplementations.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/URLSessionImplementations.swift new file mode 100644 index 0000000..cbbb21f --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -0,0 +1,670 @@ +// URLSessionImplementations.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +#if !os(macOS) +import MobileCoreServices +#endif +#if canImport(UniformTypeIdentifiers) +import UniformTypeIdentifiers +#endif + +// Protocol defined for a session data task. This allows mocking out the URLSessionProtocol below since +// you may not want to create or return a real URLSessionDataTask. +public protocol URLSessionDataTaskProtocol { + func resume() + + var taskIdentifier: Int { get } + + var progress: Progress { get } + + func cancel() +} + +// Protocol allowing implementations to alter what is returned or to test their implementations. +public protocol URLSessionProtocol { + // Task which performs the network fetch. Expected to be from URLSession.dataTask(with:completionHandler:) such that a network request + // is sent off when `.resume()` is called. + func dataTaskFromProtocol(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTaskProtocol +} + +extension URLSession: URLSessionProtocol { + // Passthrough to URLSession.dataTask(with:completionHandler) since URLSessionDataTask conforms to URLSessionDataTaskProtocol and fetches the network data. + public func dataTaskFromProtocol(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, (any Error)?) -> Void) -> any URLSessionDataTaskProtocol { + return dataTask(with: request, completionHandler: completionHandler) + } +} + +extension URLSessionDataTask: URLSessionDataTaskProtocol {} + +class URLSessionRequestBuilderFactory: RequestBuilderFactory { + func getNonDecodableBuilder() -> RequestBuilder.Type { + return URLSessionRequestBuilder.self + } + + func getBuilder() -> RequestBuilder.Type { + return URLSessionDecodableRequestBuilder.self + } +} + +public typealias OpenAPIClientAPIChallengeHandler = ((URLSession, URLSessionTask, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?)) + +// Store the URLSession's delegate to retain its reference +private let sessionDelegate = SessionDelegate() + +// Store the URLSession to retain its reference +private let defaultURLSession = URLSession(configuration: .default, delegate: sessionDelegate, delegateQueue: nil) + +// Store current taskDidReceiveChallenge for every URLSessionTask +private var challengeHandlerStore = SynchronizedDictionary() + +// Store current URLCredential for every URLSessionTask +private var credentialStore = SynchronizedDictionary() + +open class URLSessionRequestBuilder: RequestBuilder { + + /** + May be assigned if you want to control the authentication challenges. + */ + public var taskDidReceiveChallenge: OpenAPIClientAPIChallengeHandler? + + required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:], requiresAuthentication: Bool) { + super.init(method: method, URLString: URLString, parameters: parameters, headers: headers, requiresAuthentication: requiresAuthentication) + } + + /** + May be overridden by a subclass if you want to control the URLSession + configuration. + */ + open func createURLSession() -> URLSessionProtocol { + return defaultURLSession + } + + /** + May be overridden by a subclass if you want to control the Content-Type + that is given to an uploaded form part. + + Return nil to use the default behavior (inferring the Content-Type from + the file extension). Return the desired Content-Type otherwise. + */ + open func contentTypeForFormPart(fileURL: URL) -> String? { + return nil + } + + /** + May be overridden by a subclass if you want to control the URLRequest + configuration (e.g. to override the cache policy). + */ + open func createURLRequest(urlSession: URLSessionProtocol, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest { + + guard let url = URL(string: URLString) else { + throw DownloadException.requestMissingURL + } + + var originalRequest = URLRequest(url: url) + + originalRequest.httpMethod = method.rawValue + + buildHeaders().forEach { key, value in + originalRequest.setValue(value, forHTTPHeaderField: key) + } + + let modifiedRequest = try encoding.encode(originalRequest, with: parameters) + + return modifiedRequest + } + + @discardableResult + override open func execute(_ apiResponseQueue: DispatchQueue = OpenAPIClientAPI.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result, ErrorResponse>) -> Void) -> RequestTask { + let urlSession = createURLSession() + + guard let xMethod = HTTPMethod(rawValue: method) else { + fatalError("Unsupported Http method - \(method)") + } + + let encoding: ParameterEncoding + + switch xMethod { + case .get, .head: + encoding = URLEncoding() + + case .options, .post, .put, .patch, .delete, .trace, .connect: + let contentType = headers["Content-Type"] ?? "application/json" + + if contentType.hasPrefix("application/") && contentType.contains("json") { + encoding = JSONDataEncoding() + } else if contentType.hasPrefix("multipart/form-data") { + encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:)) + } else if contentType.hasPrefix("application/x-www-form-urlencoded") { + encoding = FormURLEncoding() + } else if contentType.hasPrefix("application/octet-stream"){ + encoding = OctetStreamEncoding() + } else { + fatalError("Unsupported Media Type - \(contentType)") + } + } + + do { + let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) + + var taskIdentifier: Int? + let cleanupRequest = { + if let taskIdentifier = taskIdentifier { + challengeHandlerStore[taskIdentifier] = nil + credentialStore[taskIdentifier] = nil + } + } + + let dataTask = urlSession.dataTaskFromProtocol(with: request) { data, response, error in + apiResponseQueue.async { + self.processRequestResponse(urlRequest: request, data: data, response: response, error: error, completion: completion) + cleanupRequest() + } + } + + onProgressReady?(dataTask.progress) + + taskIdentifier = dataTask.taskIdentifier + challengeHandlerStore[dataTask.taskIdentifier] = taskDidReceiveChallenge + credentialStore[dataTask.taskIdentifier] = credential + + dataTask.resume() + + requestTask.set(task: dataTask) + } catch { + apiResponseQueue.async { + completion(.failure(ErrorResponse.error(415, nil, nil, error))) + } + } + + return requestTask + } + + fileprivate func processRequestResponse(urlRequest: URLRequest, data: Data?, response: URLResponse?, error: Error?, completion: @escaping (_ result: Swift.Result, ErrorResponse>) -> Void) { + + if let error = error { + completion(.failure(ErrorResponse.error(-1, data, response, error))) + return + } + + guard let httpResponse = response as? HTTPURLResponse else { + completion(.failure(ErrorResponse.error(-2, data, response, DecodableRequestBuilderError.nilHTTPResponse))) + return + } + + guard httpResponse.isStatusCodeSuccessful else { + completion(.failure(ErrorResponse.error(httpResponse.statusCode, data, response, DecodableRequestBuilderError.unsuccessfulHTTPStatusCode))) + return + } + + switch T.self { + case is Void.Type: + + completion(.success(Response(response: httpResponse, body: () as! T, bodyData: data))) + + default: + fatalError("Unsupported Response Body Type - \(String(describing: T.self))") + } + + } + + open func buildHeaders() -> [String: String] { + var httpHeaders: [String: String] = [:] + for (key, value) in OpenAPIClientAPI.customHeaders { + httpHeaders[key] = value + } + for (key, value) in headers { + httpHeaders[key] = value + } + return httpHeaders + } + + fileprivate func getFileName(fromContentDisposition contentDisposition: String?) -> String? { + + guard let contentDisposition = contentDisposition else { + return nil + } + + let items = contentDisposition.components(separatedBy: ";") + + var filename: String? + + for contentItem in items { + + let filenameKey = "filename=" + guard let range = contentItem.range(of: filenameKey) else { + continue + } + + filename = contentItem + return filename? + .replacingCharacters(in: range, with: "") + .replacingOccurrences(of: "\"", with: "") + .trimmingCharacters(in: .whitespacesAndNewlines) + } + + return filename + + } + + fileprivate func getPath(from url: URL) throws -> String { + + guard var path = URLComponents(url: url, resolvingAgainstBaseURL: true)?.path else { + throw DownloadException.requestMissingPath + } + + if path.hasPrefix("/") { + path.remove(at: path.startIndex) + } + + return path + + } + + fileprivate func getURL(from urlRequest: URLRequest) throws -> URL { + + guard let url = urlRequest.url else { + throw DownloadException.requestMissingURL + } + + return url + } + +} + +open class URLSessionDecodableRequestBuilder: URLSessionRequestBuilder { + override fileprivate func processRequestResponse(urlRequest: URLRequest, data: Data?, response: URLResponse?, error: Error?, completion: @escaping (_ result: Swift.Result, ErrorResponse>) -> Void) { + + if let error = error { + completion(.failure(ErrorResponse.error(-1, data, response, error))) + return + } + + guard let httpResponse = response as? HTTPURLResponse else { + completion(.failure(ErrorResponse.error(-2, data, response, DecodableRequestBuilderError.nilHTTPResponse))) + return + } + + guard httpResponse.isStatusCodeSuccessful else { + completion(.failure(ErrorResponse.error(httpResponse.statusCode, data, response, DecodableRequestBuilderError.unsuccessfulHTTPStatusCode))) + return + } + + switch T.self { + case is String.Type: + + let body = data.flatMap { String(data: $0, encoding: .utf8) } ?? "" + + completion(.success(Response(response: httpResponse, body: body as! T, bodyData: data))) + + case is URL.Type: + do { + + guard error == nil else { + throw DownloadException.responseFailed + } + + guard let data = data else { + throw DownloadException.responseDataMissing + } + + let fileManager = FileManager.default + let cachesDirectory = fileManager.urls(for: .cachesDirectory, in: .userDomainMask)[0] + let requestURL = try getURL(from: urlRequest) + + var requestPath = try getPath(from: requestURL) + + if let headerFileName = getFileName(fromContentDisposition: httpResponse.allHeaderFields["Content-Disposition"] as? String) { + requestPath = requestPath.appending("/\(headerFileName)") + } else { + requestPath = requestPath.appending("/tmp.OpenAPIClient.\(UUID().uuidString)") + } + + let filePath = cachesDirectory.appendingPathComponent(requestPath) + let directoryPath = filePath.deletingLastPathComponent().path + + try fileManager.createDirectory(atPath: directoryPath, withIntermediateDirectories: true, attributes: nil) + try data.write(to: filePath, options: .atomic) + + completion(.success(Response(response: httpResponse, body: filePath as! T, bodyData: data))) + + } catch let requestParserError as DownloadException { + completion(.failure(ErrorResponse.error(400, data, response, requestParserError))) + } catch { + completion(.failure(ErrorResponse.error(400, data, response, error))) + } + + case is Void.Type: + + completion(.success(Response(response: httpResponse, body: () as! T, bodyData: data))) + + case is Data.Type: + + completion(.success(Response(response: httpResponse, body: data as! T, bodyData: data))) + + default: + + guard let unwrappedData = data, !unwrappedData.isEmpty else { + if let expressibleByNilLiteralType = T.self as? ExpressibleByNilLiteral.Type { + completion(.success(Response(response: httpResponse, body: expressibleByNilLiteralType.init(nilLiteral: ()) as! T, bodyData: data))) + } else { + completion(.failure(ErrorResponse.error(httpResponse.statusCode, nil, response, DecodableRequestBuilderError.emptyDataResponse))) + } + return + } + + let decodeResult = CodableHelper.decode(T.self, from: unwrappedData) + + switch decodeResult { + case let .success(decodableObj): + completion(.success(Response(response: httpResponse, body: decodableObj, bodyData: unwrappedData))) + case let .failure(error): + completion(.failure(ErrorResponse.error(httpResponse.statusCode, unwrappedData, response, error))) + } + } + } +} + +private class SessionDelegate: NSObject, URLSessionTaskDelegate { + func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { + + var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling + + var credential: URLCredential? + + if let taskDidReceiveChallenge = challengeHandlerStore[task.taskIdentifier] { + (disposition, credential) = taskDidReceiveChallenge(session, task, challenge) + } else { + if challenge.previousFailureCount > 0 { + disposition = .rejectProtectionSpace + } else { + credential = credentialStore[task.taskIdentifier] ?? session.configuration.urlCredentialStorage?.defaultCredential(for: challenge.protectionSpace) + + if credential != nil { + disposition = .useCredential + } + } + } + + completionHandler(disposition, credential) + } +} + +public enum HTTPMethod: String { + case options = "OPTIONS" + case get = "GET" + case head = "HEAD" + case post = "POST" + case put = "PUT" + case patch = "PATCH" + case delete = "DELETE" + case trace = "TRACE" + case connect = "CONNECT" +} + +public protocol ParameterEncoding { + func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) throws -> URLRequest +} + +private class URLEncoding: ParameterEncoding { + func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) throws -> URLRequest { + + var urlRequest = urlRequest + + guard let parameters = parameters else { return urlRequest } + + guard let url = urlRequest.url else { + throw DownloadException.requestMissingURL + } + + if var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false), !parameters.isEmpty { + urlComponents.queryItems = APIHelper.mapValuesToQueryItems(parameters) + urlRequest.url = urlComponents.url + } + + return urlRequest + } +} + +private class FormDataEncoding: ParameterEncoding { + + let contentTypeForFormPart: (_ fileURL: URL) -> String? + + init(contentTypeForFormPart: @escaping (_ fileURL: URL) -> String?) { + self.contentTypeForFormPart = contentTypeForFormPart + } + + func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) throws -> URLRequest { + + var urlRequest = urlRequest + + guard let parameters = parameters, !parameters.isEmpty else { + return urlRequest + } + + let boundary = "Boundary-\(UUID().uuidString)" + + urlRequest.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type") + + for (key, value) in parameters { + for value in (value as? Array ?? [value]) { + switch value { + case let fileURL as URL: + + urlRequest = try configureFileUploadRequest( + urlRequest: urlRequest, + boundary: boundary, + name: key, + fileURL: fileURL + ) + + case let string as String: + + if let data = string.data(using: .utf8) { + urlRequest = configureDataUploadRequest( + urlRequest: urlRequest, + boundary: boundary, + name: key, + data: data + ) + } + + case let number as NSNumber: + + if let data = number.stringValue.data(using: .utf8) { + urlRequest = configureDataUploadRequest( + urlRequest: urlRequest, + boundary: boundary, + name: key, + data: data + ) + } + + case let data as Data: + + urlRequest = configureDataUploadRequest( + urlRequest: urlRequest, + boundary: boundary, + name: key, + data: data + ) + + case let uuid as UUID: + + if let data = uuid.uuidString.data(using: .utf8) { + urlRequest = configureDataUploadRequest( + urlRequest: urlRequest, + boundary: boundary, + name: key, + data: data + ) + } + + default: + fatalError("Unprocessable value \(value) with key \(key)") + } + } + } + + var body = urlRequest.httpBody.orEmpty + + body.append("\r\n--\(boundary)--\r\n") + + urlRequest.httpBody = body + + return urlRequest + } + + private func configureFileUploadRequest(urlRequest: URLRequest, boundary: String, name: String, fileURL: URL) throws -> URLRequest { + + var urlRequest = urlRequest + + var body = urlRequest.httpBody.orEmpty + + let fileData = try Data(contentsOf: fileURL) + + let mimetype = contentTypeForFormPart(fileURL) ?? mimeType(for: fileURL) + + let fileName = fileURL.lastPathComponent + + // If we already added something then we need an additional newline. + if body.count > 0 { + body.append("\r\n") + } + + // Value boundary. + body.append("--\(boundary)\r\n") + + // Value headers. + body.append("Content-Disposition: form-data; name=\"\(name)\"; filename=\"\(fileName)\"\r\n") + body.append("Content-Type: \(mimetype)\r\n") + + // Separate headers and body. + body.append("\r\n") + + // The value data. + body.append(fileData) + + urlRequest.httpBody = body + + return urlRequest + } + + private func configureDataUploadRequest(urlRequest: URLRequest, boundary: String, name: String, data: Data) -> URLRequest { + + var urlRequest = urlRequest + + var body = urlRequest.httpBody.orEmpty + + // If we already added something then we need an additional newline. + if body.count > 0 { + body.append("\r\n") + } + + // Value boundary. + body.append("--\(boundary)\r\n") + + // Value headers. + body.append("Content-Disposition: form-data; name=\"\(name)\"\r\n") + + // Separate headers and body. + body.append("\r\n") + + // The value data. + body.append(data) + + urlRequest.httpBody = body + + return urlRequest + + } + + func mimeType(for url: URL) -> String { + let pathExtension = url.pathExtension + + if #available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) { + #if canImport(UniformTypeIdentifiers) + if let utType = UTType(filenameExtension: pathExtension) { + return utType.preferredMIMEType ?? "application/octet-stream" + } + #else + return "application/octet-stream" + #endif + } else { + if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue(), + let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() { + return mimetype as String + } + return "application/octet-stream" + } + return "application/octet-stream" + } + +} + +private class FormURLEncoding: ParameterEncoding { + func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) throws -> URLRequest { + + var urlRequest = urlRequest + + var requestBodyComponents = URLComponents() + requestBodyComponents.queryItems = APIHelper.mapValuesToQueryItems(parameters ?? [:]) + + if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { + urlRequest.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") + } + + urlRequest.httpBody = requestBodyComponents.query?.data(using: .utf8) + + return urlRequest + } +} + +private class OctetStreamEncoding: ParameterEncoding { + func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) throws -> URLRequest { + + var urlRequest = urlRequest + + guard let body = parameters?["body"] else { return urlRequest } + + if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil { + urlRequest.setValue("application/octet-stream", forHTTPHeaderField: "Content-Type") + } + + switch body { + case let fileURL as URL: + urlRequest.httpBody = try Data(contentsOf: fileURL) + case let data as Data: + urlRequest.httpBody = data + default: + fatalError("Unprocessable body \(body)") + } + + return urlRequest + } +} + +private extension Data { + /// Append string to Data + /// + /// Rather than littering my code with calls to `dataUsingEncoding` to convert strings to Data, and then add that data to the Data, this wraps it in a nice convenient little extension to Data. This converts using UTF-8. + /// + /// - parameter string: The string to be added to the `Data`. + + mutating func append(_ string: String) { + if let data = string.data(using: .utf8) { + append(data) + } + } +} + +private extension Optional where Wrapped == Data { + var orEmpty: Data { + self ?? Data() + } +} + +extension JSONDataEncoding: ParameterEncoding {} diff --git a/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Validation.swift b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Validation.swift new file mode 100644 index 0000000..6a0d4c9 --- /dev/null +++ b/openapi swift client generation/frontend/client/OpenAPIClient/Classes/OpenAPIs/Validation.swift @@ -0,0 +1,161 @@ +// Validation.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +public struct StringRule { + public var minLength: Int? + public var maxLength: Int? + public var pattern: String? +} + +public struct NumericRule { + public var minimum: T? + public var exclusiveMinimum = false + public var maximum: T? + public var exclusiveMaximum = false + public var multipleOf: T? +} + +public struct ArrayRule { + public var minItems: Int? + public var maxItems: Int? + public var uniqueItems: Bool +} + +public enum StringValidationErrorKind: Error { + case minLength, maxLength, pattern +} + +public enum NumericValidationErrorKind: Error { + case minimum, maximum, multipleOf +} + +public enum ArrayValidationErrorKind: Error { + case minItems, maxItems, uniqueItems +} + +public struct ValidationError: Error { + public fileprivate(set) var kinds: Set +} + +public struct Validator { + /// Validate a string against a rule. + /// - Parameter string: The String you wish to validate. + /// - Parameter rule: The StringRule you wish to use for validation. + /// - Returns: A validated string. + /// - Throws: `ValidationError` if the string is invalid against the rule, + /// `NSError` if the rule.pattern is invalid. + public static func validate(_ string: String, against rule: StringRule) throws -> String { + var error = ValidationError(kinds: []) + if let minLength = rule.minLength, !(minLength <= string.count) { + error.kinds.insert(.minLength) + } + if let maxLength = rule.maxLength, !(string.count <= maxLength) { + error.kinds.insert(.maxLength) + } + if let pattern = rule.pattern { + let matches = try NSRegularExpression(pattern: pattern, options: .caseInsensitive) + .matches(in: string, range: .init(location: 0, length: string.utf16.count)) + if matches.isEmpty { + error.kinds.insert(.pattern) + } + } + guard error.kinds.isEmpty else { + throw error + } + return string + } + + /// Validate a integer against a rule. + /// - Parameter numeric: The integer you wish to validate. + /// - Parameter rule: The NumericRule you wish to use for validation. + /// - Returns: A validated integer. + /// - Throws: `ValidationError` if the numeric is invalid against the rule. + public static func validate(_ numeric: T, against rule: NumericRule) throws -> T { + var error = ValidationError(kinds: []) + if let minium = rule.minimum { + if !rule.exclusiveMinimum, minium > numeric { + error.kinds.insert(.minimum) + } + if rule.exclusiveMinimum, minium >= numeric { + error.kinds.insert(.minimum) + } + } + if let maximum = rule.maximum { + if !rule.exclusiveMaximum, numeric > maximum { + error.kinds.insert(.maximum) + } + if rule.exclusiveMaximum, numeric >= maximum { + error.kinds.insert(.maximum) + } + } + if let multipleOf = rule.multipleOf, !numeric.isMultiple(of: multipleOf) { + error.kinds.insert(.multipleOf) + } + guard error.kinds.isEmpty else { + throw error + } + return numeric + } + + /// Validate a fractional number against a rule. + /// - Parameter numeric: The fractional number you wish to validate. + /// - Parameter rule: The NumericRule you wish to use for validation. + /// - Returns: A validated fractional number. + /// - Throws: `ValidationError` if the numeric is invalid against the rule. + public static func validate(_ numeric: T, against rule: NumericRule) throws -> T { + var error = ValidationError(kinds: []) + if let minium = rule.minimum { + if !rule.exclusiveMinimum, minium > numeric { + error.kinds.insert(.minimum) + } + if rule.exclusiveMinimum, minium >= numeric { + error.kinds.insert(.minimum) + } + } + if let maximum = rule.maximum { + if !rule.exclusiveMaximum, numeric > maximum { + error.kinds.insert(.maximum) + } + if rule.exclusiveMaximum, numeric >= maximum { + error.kinds.insert(.maximum) + } + } + if let multipleOf = rule.multipleOf, numeric.remainder(dividingBy: multipleOf) != 0 { + error.kinds.insert(.multipleOf) + } + guard error.kinds.isEmpty else { + throw error + } + return numeric + } + + /// Validate a array against a rule. + /// - Parameter array: The Array you wish to validate. + /// - Parameter rule: The ArrayRule you wish to use for validation. + /// - Returns: A validated array. + /// - Throws: `ValidationError` if the string is invalid against the rule. + public static func validate(_ array: Array, against rule: ArrayRule) throws -> Array { + var error = ValidationError(kinds: []) + if let minItems = rule.minItems, !(minItems <= array.count) { + error.kinds.insert(.minItems) + } + if let maxItems = rule.maxItems, !(array.count <= maxItems) { + error.kinds.insert(.maxItems) + } + if rule.uniqueItems { + let unique = Set(array) + if unique.count != array.count { + error.kinds.insert(.uniqueItems) + } + } + guard error.kinds.isEmpty else { + throw error + } + return array + } +} diff --git a/openapi swift client generation/frontend/client/Package.swift b/openapi swift client generation/frontend/client/Package.swift new file mode 100644 index 0000000..af715db --- /dev/null +++ b/openapi swift client generation/frontend/client/Package.swift @@ -0,0 +1,33 @@ +// swift-tools-version:5.1 + +import PackageDescription + +let package = Package( + name: "OpenAPIClient", + platforms: [ + .iOS(.v11), + .macOS(.v10_13), + .tvOS(.v11), + .watchOS(.v4), + ], + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "OpenAPIClient", + targets: ["OpenAPIClient"] + ), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + .package(url: "https://github.com/Flight-School/AnyCodable", .upToNextMajor(from: "0.6.1")), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "OpenAPIClient", + dependencies: ["AnyCodable", ], + path: "OpenAPIClient/Classes" + ), + ] +) diff --git a/openapi swift client generation/frontend/client/README.md b/openapi swift client generation/frontend/client/README.md new file mode 100644 index 0000000..8f30b0a --- /dev/null +++ b/openapi swift client generation/frontend/client/README.md @@ -0,0 +1,51 @@ +# Swift5 API client for OpenAPIClient + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client. + +- API version: +- Package version: +- Generator version: 7.9.0 +- Build package: org.openapitools.codegen.languages.Swift5ClientCodegen + +## Installation + +### Carthage + +Run `carthage update` + +### CocoaPods + +Run `pod install` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*StudentapiAPI* | [**createStudent**](docs/StudentapiAPI.md#createstudent) | **POST** /studentapi/ | +*StudentapiAPI* | [**destroyStudent**](docs/StudentapiAPI.md#destroystudent) | **DELETE** /studentapi/{id}/ | +*StudentapiAPI* | [**listStudents**](docs/StudentapiAPI.md#liststudents) | **GET** /studentapi/ | +*StudentapiAPI* | [**partialUpdateStudent**](docs/StudentapiAPI.md#partialupdatestudent) | **PATCH** /studentapi/{id}/ | +*StudentapiAPI* | [**retrieveStudent**](docs/StudentapiAPI.md#retrievestudent) | **GET** /studentapi/{id}/ | +*StudentapiAPI* | [**updateStudent**](docs/StudentapiAPI.md#updatestudent) | **PUT** /studentapi/{id}/ | + + +## Documentation For Models + + - [Student](docs/Student.md) + + + +## Documentation For Authorization + +Endpoints do not require authorization. + + +## Author + + + diff --git a/openapi swift client generation/frontend/client/docs/Student.md b/openapi swift client generation/frontend/client/docs/Student.md new file mode 100644 index 0000000..a1e5beb --- /dev/null +++ b/openapi swift client generation/frontend/client/docs/Student.md @@ -0,0 +1,13 @@ +# Student + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Int** | | [optional] [readonly] +**name** | **String** | | +**roll** | **Int** | | +**city** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/openapi swift client generation/frontend/client/docs/StudentapiAPI.md b/openapi swift client generation/frontend/client/docs/StudentapiAPI.md new file mode 100644 index 0000000..3e7ae02 --- /dev/null +++ b/openapi swift client generation/frontend/client/docs/StudentapiAPI.md @@ -0,0 +1,308 @@ +# StudentapiAPI + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createStudent**](StudentapiAPI.md#createstudent) | **POST** /studentapi/ | +[**destroyStudent**](StudentapiAPI.md#destroystudent) | **DELETE** /studentapi/{id}/ | +[**listStudents**](StudentapiAPI.md#liststudents) | **GET** /studentapi/ | +[**partialUpdateStudent**](StudentapiAPI.md#partialupdatestudent) | **PATCH** /studentapi/{id}/ | +[**retrieveStudent**](StudentapiAPI.md#retrievestudent) | **GET** /studentapi/{id}/ | +[**updateStudent**](StudentapiAPI.md#updatestudent) | **PUT** /studentapi/{id}/ | + + +# **createStudent** +```swift + open class func createStudent(student: Student? = nil, completion: @escaping (_ data: Student?, _ error: Error?) -> Void) +``` + + + + + +### Example +```swift +// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new +import OpenAPIClient + +let student = Student(id: 123, name: "name_example", roll: 123, city: "city_example") // Student | (optional) + +StudentapiAPI.createStudent(student: student) { (response, error) in + guard error == nil else { + print(error) + return + } + + if (response) { + dump(response) + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **student** | [**Student**](Student.md) | | [optional] + +### Return type + +[**Student**](Student.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded, multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **destroyStudent** +```swift + open class func destroyStudent(id: String, completion: @escaping (_ data: Void?, _ error: Error?) -> Void) +``` + + + + + +### Example +```swift +// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new +import OpenAPIClient + +let id = "id_example" // String | A unique integer value identifying this student. + +StudentapiAPI.destroyStudent(id: id) { (response, error) in + guard error == nil else { + print(error) + return + } + + if (response) { + dump(response) + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **id** | **String** | A unique integer value identifying this student. | + +### Return type + +Void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **listStudents** +```swift + open class func listStudents(completion: @escaping (_ data: [Student]?, _ error: Error?) -> Void) +``` + + + + + +### Example +```swift +// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new +import OpenAPIClient + + +StudentapiAPI.listStudents() { (response, error) in + guard error == nil else { + print(error) + return + } + + if (response) { + dump(response) + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**[Student]**](Student.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **partialUpdateStudent** +```swift + open class func partialUpdateStudent(id: String, student: Student? = nil, completion: @escaping (_ data: Student?, _ error: Error?) -> Void) +``` + + + + + +### Example +```swift +// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new +import OpenAPIClient + +let id = "id_example" // String | A unique integer value identifying this student. +let student = Student(id: 123, name: "name_example", roll: 123, city: "city_example") // Student | (optional) + +StudentapiAPI.partialUpdateStudent(id: id, student: student) { (response, error) in + guard error == nil else { + print(error) + return + } + + if (response) { + dump(response) + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **id** | **String** | A unique integer value identifying this student. | + **student** | [**Student**](Student.md) | | [optional] + +### Return type + +[**Student**](Student.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded, multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **retrieveStudent** +```swift + open class func retrieveStudent(id: String, completion: @escaping (_ data: Student?, _ error: Error?) -> Void) +``` + + + + + +### Example +```swift +// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new +import OpenAPIClient + +let id = "id_example" // String | A unique integer value identifying this student. + +StudentapiAPI.retrieveStudent(id: id) { (response, error) in + guard error == nil else { + print(error) + return + } + + if (response) { + dump(response) + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **id** | **String** | A unique integer value identifying this student. | + +### Return type + +[**Student**](Student.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updateStudent** +```swift + open class func updateStudent(id: String, student: Student? = nil, completion: @escaping (_ data: Student?, _ error: Error?) -> Void) +``` + + + + + +### Example +```swift +// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new +import OpenAPIClient + +let id = "id_example" // String | A unique integer value identifying this student. +let student = Student(id: 123, name: "name_example", roll: 123, city: "city_example") // Student | (optional) + +StudentapiAPI.updateStudent(id: id, student: student) { (response, error) in + guard error == nil else { + print(error) + return + } + + if (response) { + dump(response) + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **id** | **String** | A unique integer value identifying this student. | + **student** | [**Student**](Student.md) | | [optional] + +### Return type + +[**Student**](Student.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json, application/x-www-form-urlencoded, multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/openapi swift client generation/frontend/client/git_push.sh b/openapi swift client generation/frontend/client/git_push.sh new file mode 100644 index 0000000..f53a75d --- /dev/null +++ b/openapi swift client generation/frontend/client/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/openapi swift client generation/frontend/client/project.yml b/openapi swift client generation/frontend/client/project.yml new file mode 100644 index 0000000..b95a6e4 --- /dev/null +++ b/openapi swift client generation/frontend/client/project.yml @@ -0,0 +1,15 @@ +name: OpenAPIClient +targets: + OpenAPIClient: + type: framework + platform: iOS + deploymentTarget: "11.0" + sources: [OpenAPIClient] + info: + path: ./Info.plist + version: + settings: + APPLICATION_EXTENSION_API_ONLY: true + scheme: {} + dependencies: + - carthage: AnyCodable diff --git a/openapi swift client generation/frontend/openapi-schema.yml b/openapi swift client generation/frontend/openapi-schema.yml new file mode 100644 index 0000000..8135c43 --- /dev/null +++ b/openapi swift client generation/frontend/openapi-schema.yml @@ -0,0 +1,160 @@ +openapi: 3.0.2 +info: + title: '' + version: '' +paths: + /studentapi/: + get: + operationId: listStudents + description: '' + parameters: [] + responses: + '200': + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Student' + description: '' + tags: + - studentapi + post: + operationId: createStudent + description: '' + parameters: [] + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Student' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Student' + multipart/form-data: + schema: + $ref: '#/components/schemas/Student' + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/Student' + description: '' + tags: + - studentapi + /studentapi/{id}/: + get: + operationId: retrieveStudent + description: '' + parameters: + - name: id + in: path + required: true + description: A unique integer value identifying this student. + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Student' + description: '' + tags: + - studentapi + put: + operationId: updateStudent + description: '' + parameters: + - name: id + in: path + required: true + description: A unique integer value identifying this student. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Student' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Student' + multipart/form-data: + schema: + $ref: '#/components/schemas/Student' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Student' + description: '' + tags: + - studentapi + patch: + operationId: partialUpdateStudent + description: '' + parameters: + - name: id + in: path + required: true + description: A unique integer value identifying this student. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Student' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Student' + multipart/form-data: + schema: + $ref: '#/components/schemas/Student' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Student' + description: '' + tags: + - studentapi + delete: + operationId: destroyStudent + description: '' + parameters: + - name: id + in: path + required: true + description: A unique integer value identifying this student. + schema: + type: string + responses: + '204': + description: '' + tags: + - studentapi +components: + schemas: + Student: + type: object + properties: + id: + type: integer + readOnly: true + name: + type: string + maxLength: 50 + roll: + type: integer + city: + type: string + maxLength: 50 + required: + - name + - roll + - city diff --git a/openapi swift client generation/frontend/openapitools.json b/openapi swift client generation/frontend/openapitools.json new file mode 100644 index 0000000..f80faaa --- /dev/null +++ b/openapi swift client generation/frontend/openapitools.json @@ -0,0 +1,7 @@ +{ + "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", + "spaces": 2, + "generator-cli": { + "version": "7.9.0" + } +} diff --git a/openapi swift client generation/frontend/package-lock.json b/openapi swift client generation/frontend/package-lock.json new file mode 100644 index 0000000..242be4d --- /dev/null +++ b/openapi swift client generation/frontend/package-lock.json @@ -0,0 +1,1136 @@ +{ + "name": "openapi-dart-client-generation", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "openapi-dart-client-generation", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@openapitools/openapi-generator-cli": "^2.5.2" + } + }, + "node_modules/@babel/runtime": { + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.7.tgz", + "integrity": "sha512-FjoyLe754PMiYsFaN5C94ttGiOmBNYTf6pLr4xXHAT5uctHb092PBszndLDR5XA/jghQvn4n7JMHl7dmTgbm9w==", + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@nestjs/common": { + "version": "8.4.4", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-8.4.4.tgz", + "integrity": "sha512-QHi7QcgH/5Jinz+SCfIZJkFHc6Cch1YsAEGFEhi6wSp6MILb0sJMQ1CX06e9tCOAjSlBwaJj4PH0eFCVau5v9Q==", + "dependencies": { + "axios": "0.26.1", + "iterare": "1.2.1", + "tslib": "2.3.1", + "uuid": "8.3.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "cache-manager": "*", + "class-transformer": "*", + "class-validator": "*", + "reflect-metadata": "^0.1.12", + "rxjs": "^7.1.0" + }, + "peerDependenciesMeta": { + "cache-manager": { + "optional": true + }, + "class-transformer": { + "optional": true + }, + "class-validator": { + "optional": true + } + } + }, + "node_modules/@nestjs/common/node_modules/tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" + }, + "node_modules/@nestjs/core": { + "version": "8.4.4", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-8.4.4.tgz", + "integrity": "sha512-Ef3yJPuzAttpNfehnGqIV5kHIL9SHptB5F4ERxoU7pT61H3xiYpZw6hSjx68cJO7cc6rm7/N+b4zeuJvFHtvBg==", + "hasInstallScript": true, + "dependencies": { + "@nuxtjs/opencollective": "0.3.2", + "fast-safe-stringify": "2.1.1", + "iterare": "1.2.1", + "object-hash": "3.0.0", + "path-to-regexp": "3.2.0", + "tslib": "2.3.1", + "uuid": "8.3.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "@nestjs/common": "^8.0.0", + "@nestjs/microservices": "^8.0.0", + "@nestjs/platform-express": "^8.0.0", + "@nestjs/websockets": "^8.0.0", + "reflect-metadata": "^0.1.12", + "rxjs": "^7.1.0" + }, + "peerDependenciesMeta": { + "@nestjs/microservices": { + "optional": true + }, + "@nestjs/platform-express": { + "optional": true + }, + "@nestjs/websockets": { + "optional": true + } + } + }, + "node_modules/@nestjs/core/node_modules/tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" + }, + "node_modules/@nuxtjs/opencollective": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz", + "integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==", + "dependencies": { + "chalk": "^4.1.0", + "consola": "^2.15.0", + "node-fetch": "^2.6.1" + }, + "bin": { + "opencollective": "bin/opencollective.js" + }, + "engines": { + "node": ">=8.0.0", + "npm": ">=5.0.0" + } + }, + "node_modules/@openapitools/openapi-generator-cli": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.5.2.tgz", + "integrity": "sha512-FLgkjzpDiHVsH821db0VDSElDoA6TcspGyq3RD4zLBJaJhbSsRwr4u87sNoyuHKBg4OMJbZMT4iJxAhkosKrzw==", + "hasInstallScript": true, + "dependencies": { + "@nestjs/common": "8.4.4", + "@nestjs/core": "8.4.4", + "@nuxtjs/opencollective": "0.3.2", + "chalk": "4.1.2", + "commander": "8.3.0", + "compare-versions": "4.1.3", + "concurrently": "6.5.1", + "console.table": "0.10.0", + "fs-extra": "10.0.1", + "glob": "7.1.6", + "inquirer": "8.2.2", + "lodash": "4.17.21", + "reflect-metadata": "0.1.13", + "rxjs": "7.5.5", + "tslib": "2.0.3" + }, + "bin": { + "openapi-generator-cli": "main.js" + }, + "engines": { + "node": ">=10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/openapi_generator" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/axios": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "dependencies": { + "follow-redirects": "^1.14.8" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" + }, + "node_modules/cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dependencies": { + "restore-cursor": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-width": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", + "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", + "engines": { + "node": ">= 10" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "engines": { + "node": ">= 12" + } + }, + "node_modules/compare-versions": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-4.1.3.tgz", + "integrity": "sha512-WQfnbDcrYnGr55UwbxKiQKASnTtNnaAWVi8jZyy8NTpVAXWACSne8lMD1iaIo9AiU6mnuLvSVshCzewVuWxHUg==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/concurrently": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-6.5.1.tgz", + "integrity": "sha512-FlSwNpGjWQfRwPLXvJ/OgysbBxPkWpiVjy1042b0U7on7S7qwwMIILRj7WTN1mTgqa582bG6NFuScOoh6Zgdag==", + "dependencies": { + "chalk": "^4.1.0", + "date-fns": "^2.16.1", + "lodash": "^4.17.21", + "rxjs": "^6.6.3", + "spawn-command": "^0.0.2-1", + "supports-color": "^8.1.0", + "tree-kill": "^1.2.2", + "yargs": "^16.2.0" + }, + "bin": { + "concurrently": "bin/concurrently.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/concurrently/node_modules/rxjs": { + "version": "6.6.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", + "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", + "dependencies": { + "tslib": "^1.9.0" + }, + "engines": { + "npm": ">=2.0.0" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + }, + "node_modules/consola": { + "version": "2.15.3", + "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", + "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==" + }, + "node_modules/console.table": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/console.table/-/console.table-0.10.0.tgz", + "integrity": "sha512-dPyZofqggxuvSf7WXvNjuRfnsOk1YazkVP8FdxH4tcH2c37wc79/Yl6Bhr7Lsu00KMgy2ql/qCMuNu8xctZM8g==", + "dependencies": { + "easy-table": "1.1.0" + }, + "engines": { + "node": "> 0.10" + } + }, + "node_modules/date-fns": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, + "node_modules/defaults": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "dependencies": { + "clone": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/easy-table": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/easy-table/-/easy-table-1.1.0.tgz", + "integrity": "sha512-oq33hWOSSnl2Hoh00tZWaIPi1ievrD9aFG82/IgjlycAnW9hHx5PkJiXpxPsgEE+H7BsbVQXFVFST8TEXS6/pA==", + "optionalDependencies": { + "wcwidth": ">=1.0.1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dependencies": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" + }, + "node_modules/figures": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", + "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", + "dependencies": { + "escape-string-regexp": "^1.0.5" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/fs-extra": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", + "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/inquirer": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.2.tgz", + "integrity": "sha512-pG7I/si6K/0X7p1qU+rfWnpTE1UIkTONN1wxtzh0d+dHXtT/JG6qBgLxoyHVsQa8cFABxAPh0pD6uUUHiAoaow==", + "dependencies": { + "ansi-escapes": "^4.2.1", + "chalk": "^4.1.1", + "cli-cursor": "^3.1.0", + "cli-width": "^3.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.21", + "mute-stream": "0.0.8", + "ora": "^5.4.1", + "run-async": "^2.4.0", + "rxjs": "^7.5.5", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", + "through": "^2.3.6" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/iterare": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz", + "integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==", + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "engines": { + "node": ">= 6" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "dependencies": { + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-to-regexp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.2.0.tgz", + "integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA==" + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/reflect-metadata": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", + "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==" + }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/run-async": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/rxjs": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz", + "integrity": "sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/rxjs/node_modules/tslib": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz", + "integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==" + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, + "node_modules/spawn-command": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", + "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==" + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" + }, + "node_modules/tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dependencies": { + "os-tmpdir": "~1.0.2" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/tslib": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz", + "integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==" + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "dependencies": { + "defaults": "^1.0.3" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "engines": { + "node": ">=10" + } + } + } +} diff --git a/openapi swift client generation/frontend/package.json b/openapi swift client generation/frontend/package.json new file mode 100644 index 0000000..3bd9526 --- /dev/null +++ b/openapi swift client generation/frontend/package.json @@ -0,0 +1,14 @@ +{ + "name": "openapi-dart-client-generation", + "version": "1.0.0", + "description": "[Reference Link](https://github.com/ajaishankar/openapi-typescript-fetch)", + "main": "index.js", + "scripts": { + "gen-client": "rm -rf ./client && openapi-generator-cli generate -g swift5 -i openapi-schema.yml -o client" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@openapitools/openapi-generator-cli": "2.5.2" + } +} From 267d2ee0bdce5786c6bc32cc2157c0793ad94888 Mon Sep 17 00:00:00 2001 From: Satyam Seth Date: Wed, 23 Oct 2024 23:53:00 +0530 Subject: [PATCH 2/2] backend code restructuring --- .../backend/README.md | 28 +++++++++++++++--- .../backend/{demo => }/core/__init__.py | 0 .../backend/{demo => }/core/admin.py | 0 .../backend/{demo => }/core/apps.py | 0 .../core/migrations/0001_initial.py | 0 .../{demo => }/core/migrations/__init__.py | 0 .../backend/{demo => }/core/models.py | 0 .../backend/{demo => }/core/serializers.py | 0 .../backend/{demo => }/core/tests.py | 0 .../backend/{demo => }/core/views.py | 0 .../backend/{demo => }/db.sqlite3 | Bin .../backend/demo/{demo => }/__init__.py | 0 .../backend/demo/{demo => }/asgi.py | 0 .../backend/demo/{demo => }/settings.py | 0 .../backend/demo/{demo => }/urls.py | 0 .../backend/demo/{demo => }/wsgi.py | 0 .../backend/{demo => }/manage.py | 0 .../backend/requirements.txt | 6 +--- 18 files changed, 25 insertions(+), 9 deletions(-) rename openapi swift client generation/backend/{demo => }/core/__init__.py (100%) rename openapi swift client generation/backend/{demo => }/core/admin.py (100%) rename openapi swift client generation/backend/{demo => }/core/apps.py (100%) rename openapi swift client generation/backend/{demo => }/core/migrations/0001_initial.py (100%) rename openapi swift client generation/backend/{demo => }/core/migrations/__init__.py (100%) rename openapi swift client generation/backend/{demo => }/core/models.py (100%) rename openapi swift client generation/backend/{demo => }/core/serializers.py (100%) rename openapi swift client generation/backend/{demo => }/core/tests.py (100%) rename openapi swift client generation/backend/{demo => }/core/views.py (100%) rename openapi swift client generation/backend/{demo => }/db.sqlite3 (100%) rename openapi swift client generation/backend/demo/{demo => }/__init__.py (100%) rename openapi swift client generation/backend/demo/{demo => }/asgi.py (100%) rename openapi swift client generation/backend/demo/{demo => }/settings.py (100%) rename openapi swift client generation/backend/demo/{demo => }/urls.py (100%) rename openapi swift client generation/backend/demo/{demo => }/wsgi.py (100%) rename openapi swift client generation/backend/{demo => }/manage.py (100%) diff --git a/openapi swift client generation/backend/README.md b/openapi swift client generation/backend/README.md index acf8786..975b618 100644 --- a/openapi swift client generation/backend/README.md +++ b/openapi swift client generation/backend/README.md @@ -2,12 +2,32 @@ #### Steps +- Create virtual env + + ```sh + python -m venv .venv + ``` + +- Activate virtual env + + ```sh + source .venv/bin/activate + ``` + +- Install required dependencies + + ```sh + pip install -r requirements.txt + ``` + - Generate Open Api Schema File - ```bash - ./manage.py generateschema --file '../../frontend/openapi-schema.yml' + + ```sh + python manage.py generateschema --file '../../frontend/openapi-schema.yml' ``` - Run Backend Server - ```bash - ./manage.py runserver + + ```sh + python manage.py runserver ``` diff --git a/openapi swift client generation/backend/demo/core/__init__.py b/openapi swift client generation/backend/core/__init__.py similarity index 100% rename from openapi swift client generation/backend/demo/core/__init__.py rename to openapi swift client generation/backend/core/__init__.py diff --git a/openapi swift client generation/backend/demo/core/admin.py b/openapi swift client generation/backend/core/admin.py similarity index 100% rename from openapi swift client generation/backend/demo/core/admin.py rename to openapi swift client generation/backend/core/admin.py diff --git a/openapi swift client generation/backend/demo/core/apps.py b/openapi swift client generation/backend/core/apps.py similarity index 100% rename from openapi swift client generation/backend/demo/core/apps.py rename to openapi swift client generation/backend/core/apps.py diff --git a/openapi swift client generation/backend/demo/core/migrations/0001_initial.py b/openapi swift client generation/backend/core/migrations/0001_initial.py similarity index 100% rename from openapi swift client generation/backend/demo/core/migrations/0001_initial.py rename to openapi swift client generation/backend/core/migrations/0001_initial.py diff --git a/openapi swift client generation/backend/demo/core/migrations/__init__.py b/openapi swift client generation/backend/core/migrations/__init__.py similarity index 100% rename from openapi swift client generation/backend/demo/core/migrations/__init__.py rename to openapi swift client generation/backend/core/migrations/__init__.py diff --git a/openapi swift client generation/backend/demo/core/models.py b/openapi swift client generation/backend/core/models.py similarity index 100% rename from openapi swift client generation/backend/demo/core/models.py rename to openapi swift client generation/backend/core/models.py diff --git a/openapi swift client generation/backend/demo/core/serializers.py b/openapi swift client generation/backend/core/serializers.py similarity index 100% rename from openapi swift client generation/backend/demo/core/serializers.py rename to openapi swift client generation/backend/core/serializers.py diff --git a/openapi swift client generation/backend/demo/core/tests.py b/openapi swift client generation/backend/core/tests.py similarity index 100% rename from openapi swift client generation/backend/demo/core/tests.py rename to openapi swift client generation/backend/core/tests.py diff --git a/openapi swift client generation/backend/demo/core/views.py b/openapi swift client generation/backend/core/views.py similarity index 100% rename from openapi swift client generation/backend/demo/core/views.py rename to openapi swift client generation/backend/core/views.py diff --git a/openapi swift client generation/backend/demo/db.sqlite3 b/openapi swift client generation/backend/db.sqlite3 similarity index 100% rename from openapi swift client generation/backend/demo/db.sqlite3 rename to openapi swift client generation/backend/db.sqlite3 diff --git a/openapi swift client generation/backend/demo/demo/__init__.py b/openapi swift client generation/backend/demo/__init__.py similarity index 100% rename from openapi swift client generation/backend/demo/demo/__init__.py rename to openapi swift client generation/backend/demo/__init__.py diff --git a/openapi swift client generation/backend/demo/demo/asgi.py b/openapi swift client generation/backend/demo/asgi.py similarity index 100% rename from openapi swift client generation/backend/demo/demo/asgi.py rename to openapi swift client generation/backend/demo/asgi.py diff --git a/openapi swift client generation/backend/demo/demo/settings.py b/openapi swift client generation/backend/demo/settings.py similarity index 100% rename from openapi swift client generation/backend/demo/demo/settings.py rename to openapi swift client generation/backend/demo/settings.py diff --git a/openapi swift client generation/backend/demo/demo/urls.py b/openapi swift client generation/backend/demo/urls.py similarity index 100% rename from openapi swift client generation/backend/demo/demo/urls.py rename to openapi swift client generation/backend/demo/urls.py diff --git a/openapi swift client generation/backend/demo/demo/wsgi.py b/openapi swift client generation/backend/demo/wsgi.py similarity index 100% rename from openapi swift client generation/backend/demo/demo/wsgi.py rename to openapi swift client generation/backend/demo/wsgi.py diff --git a/openapi swift client generation/backend/demo/manage.py b/openapi swift client generation/backend/manage.py similarity index 100% rename from openapi swift client generation/backend/demo/manage.py rename to openapi swift client generation/backend/manage.py diff --git a/openapi swift client generation/backend/requirements.txt b/openapi swift client generation/backend/requirements.txt index 17671db..6847092 100644 --- a/openapi swift client generation/backend/requirements.txt +++ b/openapi swift client generation/backend/requirements.txt @@ -1,9 +1,5 @@ -asgiref==3.5.2 Django==4.0.5 djangorestframework==3.13.1 -pytz==2022.1 -PyYAML==6.0 -sqlparse==0.4.2 -tzdata==2022.1 +PyYAML==6.0.2 uritemplate==4.1.1 django-cors-headers==3.13.0