Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeGen
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
scripts
CodeGen
Commits
986652ba
Commit
986652ba
authored
3 years ago
by
Benedikt Heinrichs
Browse files
Options
Downloads
Patches
Plain Diff
Add additional api inclusion
parent
b6550fc6
No related branches found
No related tags found
1 merge request
!1
New: Create a Api Client Script
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/CodeGen/Program.cs
+18
-5
18 additions, 5 deletions
src/CodeGen/Program.cs
with
18 additions
and
5 deletions
src/CodeGen/Program.cs
+
18
−
5
View file @
986652ba
...
...
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using
System.Diagnostics
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.Text.RegularExpressions
;
namespace
Coscine.CodeGen
{
...
...
@@ -63,6 +64,8 @@ namespace Coscine.CodeGen
var
first
=
true
;
var
apiRegex
=
new
Regex
(
"(?<= )(.*?)(?= extends BaseAPI)"
);
foreach
(
var
directory
in
Directory
.
GetDirectories
(
outputPath
))
{
var
apiName
=
directory
[(
directory
.
LastIndexOf
(
"."
)
+
1
)..];
...
...
@@ -71,15 +74,25 @@ namespace Coscine.CodeGen
apiName
=
apiName
.
Replace
(
"Resources"
,
"Resource"
);
apiName
=
apiName
.
Replace
(
"Notices"
,
"Notice"
);
combinationFileImports
.
Add
(
$"import
{{
{
apiName
}
ApiFactory
}}
from './
{
directoryName
}
/api';"
);
var
apiContent
=
File
.
ReadAllText
(
$"./
{
outputPath
}
/
{
directoryName
}
/api.ts"
);
var
apiImplementations
=
apiRegex
.
Matches
(
apiContent
);
foreach
(
var
apiImplementation
in
apiImplementations
)
{
var
concreteApiName
=
apiImplementation
.
ToString
().
Replace
(
"class "
,
""
);
combinationFileImports
.
Add
(
$"import
{{
{
concreteApiName
}
Factory
}}
from './
{
directoryName
}
/api';"
);
if
(
first
)
{
first
=
false
;
combinationFileImports
.
Add
(
$"import
{{
Configuration
}}
from './
{
directoryName
}
/configuration';"
);
}
combinationFileExports
.
Add
(
$"
{
apiName
}
Api:
{
apiName
}
ApiFactory(new Configuration(
{{
'
accessToken
'
:
accessToken
}}
), 'https://' + getHostName() + '/coscine/api/
{
directoryName
}
', axios)"
);
combinationFileExports
.
Add
(
$"
{
concreteApiName
}
:
{
concreteApiName
}
Factory(new Configuration(
{{
'
accessToken
'
:
accessToken
}}
), 'https://' + getHostName() + '/coscine/api/
{
directoryName
}
', axios)"
);
}
}
combinationFileExports
.
Sort
();
var
combinationFileText
=
"import { AxiosInstance } from 'axios';\n\n"
;
combinationFileText
+=
string
.
Join
(
'\n'
,
combinationFileImports
);
combinationFileText
+=
"\n\n"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment