Skip to content

Commit b205144

Browse files
committed
feat: change swagger key
1 parent d4fb5c5 commit b205144

22 files changed

+558
-513
lines changed

api/jiaozifs.gen.go

Lines changed: 130 additions & 124 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger.yml

Lines changed: 200 additions & 159 deletions
Large diffs are not rendered by default.

config/blockstore.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,53 @@ import (
99
)
1010

1111
type BlockStoreConfig struct {
12-
Type string `mapstructure:"type" validate:"required"`
13-
DefaultNamespacePrefix *string `mapstructure:"default_namespace_prefix"`
12+
Type string `mapstructure:"type" validate:"required" json:"type"`
13+
DefaultNamespacePrefix *string `mapstructure:"default_namespace_prefix" json:"default_namespace_prefix"`
1414

1515
Local *struct {
16-
Path string `mapstructure:"path"`
17-
ImportEnabled bool `mapstructure:"import_enabled"`
18-
ImportHidden bool `mapstructure:"import_hidden"`
19-
AllowedExternalPrefixes []string `mapstructure:"allowed_external_prefixes"`
20-
} `mapstructure:"local"`
16+
Path string `mapstructure:"path" json:"path"`
17+
ImportEnabled bool `mapstructure:"import_enabled" json:"import_enabled"`
18+
ImportHidden bool `mapstructure:"import_hidden" json:"import_hidden"`
19+
AllowedExternalPrefixes []string `mapstructure:"allowed_external_prefixes" json:"allowed_external_prefixes"`
20+
} `mapstructure:"local" json:"local"`
2121
S3 *struct {
2222
S3AuthInfo `mapstructure:",squash"`
23-
Region string `mapstructure:"region"`
24-
Endpoint string `mapstructure:"endpoint"`
25-
MaxRetries int `mapstructure:"max_retries"`
26-
ForcePathStyle bool `mapstructure:"force_path_style"`
27-
DiscoverBucketRegion bool `mapstructure:"discover_bucket_region"`
28-
SkipVerifyCertificateTestOnly bool `mapstructure:"skip_verify_certificate_test_only"`
29-
ServerSideEncryption string `mapstructure:"server_side_encryption"`
30-
ServerSideEncryptionKmsKeyID string `mapstructure:"server_side_encryption_kms_key_id"`
31-
PreSignedExpiry time.Duration `mapstructure:"pre_signed_expiry"`
32-
DisablePreSigned bool `mapstructure:"disable_pre_signed"`
33-
DisablePreSignedUI bool `mapstructure:"disable_pre_signed_ui"`
34-
ClientLogRetries bool `mapstructure:"client_log_retries"`
35-
ClientLogRequest bool `mapstructure:"client_log_request"`
23+
Region string `mapstructure:"region" json:"region"`
24+
Endpoint string `mapstructure:"endpoint" json:"endpoint"`
25+
MaxRetries int `mapstructure:"max_retries" json:"max_retries"`
26+
ForcePathStyle bool `mapstructure:"force_path_style" json:"force_path_style"`
27+
DiscoverBucketRegion bool `mapstructure:"discover_bucket_region" json:"discover_bucket_region"`
28+
SkipVerifyCertificateTestOnly bool `mapstructure:"skip_verify_certificate_test_only" json:"skip_verify_certificate_test_only"`
29+
ServerSideEncryption string `mapstructure:"server_side_encryption" json:"server_side_encryption"`
30+
ServerSideEncryptionKmsKeyID string `mapstructure:"server_side_encryption_kms_key_id" json:"server_side_encryption_kms_key_id"`
31+
PreSignedExpiry time.Duration `mapstructure:"pre_signed_expiry" json:"pre_signed_expiry"`
32+
DisablePreSigned bool `mapstructure:"disable_pre_signed" json:"disable_pre_signed"`
33+
DisablePreSignedUI bool `mapstructure:"disable_pre_signed_ui" json:"disable_pre_signed_ui"`
34+
ClientLogRetries bool `mapstructure:"client_log_retries" json:"client_log_retries"`
35+
ClientLogRequest bool `mapstructure:"client_log_request" json:"client_log_request"`
3636
WebIdentity *struct {
37-
SessionDuration time.Duration `mapstructure:"session_duration"`
38-
SessionExpiryWindow time.Duration `mapstructure:"session_expiry_window"`
37+
SessionDuration time.Duration `mapstructure:"session_duration" json:"session_duration"`
38+
SessionExpiryWindow time.Duration `mapstructure:"session_expiry_window" json:"session_expiry_window"`
3939
} `mapstructure:"web_identity"`
40-
} `mapstructure:"s3"`
40+
} `mapstructure:"s3" json:"s3"`
4141
Azure *struct {
42-
TryTimeout time.Duration `mapstructure:"try_timeout"`
43-
StorageAccount string `mapstructure:"storage_account"`
44-
StorageAccessKey string `mapstructure:"storage_access_key"`
45-
PreSignedExpiry time.Duration `mapstructure:"pre_signed_expiry"`
46-
DisablePreSigned bool `mapstructure:"disable_pre_signed"`
47-
DisablePreSignedUI bool `mapstructure:"disable_pre_signed_ui"`
42+
TryTimeout time.Duration `mapstructure:"try_timeout" json:"try_timeout"`
43+
StorageAccount string `mapstructure:"storage_account" json:"storage_account"`
44+
StorageAccessKey string `mapstructure:"storage_access_key" json:"storage_access_key"`
45+
PreSignedExpiry time.Duration `mapstructure:"pre_signed_expiry" json:"pre_signed_expiry"`
46+
DisablePreSigned bool `mapstructure:"disable_pre_signed" json:"disable_pre_signed"`
47+
DisablePreSignedUI bool `mapstructure:"disable_pre_signed_ui" json:"disable_pre_signed_ui"`
4848
// TestEndpointURL for testing purposes
49-
TestEndpointURL string `mapstructure:"test_endpoint_url"`
50-
} `mapstructure:"azure"`
49+
TestEndpointURL string `mapstructure:"test_endpoint_url" json:"test_endpoint_url"`
50+
} `mapstructure:"azure" json:"azure"`
5151
GS *struct {
52-
S3Endpoint string `mapstructure:"s3_endpoint"`
53-
CredentialsFile string `mapstructure:"credentials_file"`
54-
CredentialsJSON string `mapstructure:"credentials_json"`
55-
PreSignedExpiry time.Duration `mapstructure:"pre_signed_expiry"`
56-
DisablePreSigned bool `mapstructure:"disable_pre_signed"`
57-
DisablePreSignedUI bool `mapstructure:"disable_pre_signed_ui"`
58-
} `mapstructure:"gs"`
52+
S3Endpoint string `mapstructure:"s3_endpoint" json:"s3_endpoint"`
53+
CredentialsFile string `mapstructure:"credentials_file" json:"credentials_file"`
54+
CredentialsJSON string `mapstructure:"credentials_json" json:"credentials_json"`
55+
PreSignedExpiry time.Duration `mapstructure:"pre_signed_expiry" json:"pre_signed_expiry"`
56+
DisablePreSigned bool `mapstructure:"disable_pre_signed" json:"disable_pre_signed"`
57+
DisablePreSignedUI bool `mapstructure:"disable_pre_signed_ui" json:"disable_pre_signed_ui"`
58+
} `mapstructure:"gs" json:"gs"`
5959
}
6060

6161
func (c *BlockStoreConfig) BlockstoreType() string {
@@ -151,11 +151,11 @@ func (s SecureString) SecureValue() string {
151151

152152
// S3AuthInfo holds S3-style authentication.
153153
type S3AuthInfo struct {
154-
CredentialsFile string `mapstructure:"credentials_file"`
154+
CredentialsFile string `mapstructure:"credentials_file" json:"credentials_file"`
155155
Profile string
156156
Credentials *struct {
157-
AccessKeyID SecureString `mapstructure:"access_key_id"`
158-
SecretAccessKey SecureString `mapstructure:"secret_access_key"`
159-
SessionToken SecureString `mapstructure:"session_token"`
157+
AccessKeyID SecureString `mapstructure:"access_key_id" json:"access_key_id"`
158+
SecretAccessKey SecureString `mapstructure:"secret_access_key" json:"secret_access_key"`
159+
SessionToken SecureString `mapstructure:"session_token" json:"session_token"`
160160
}
161161
}

config/default.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ var defaultCfg = Config{
1717
Blockstore: BlockStoreConfig{
1818
Type: "local",
1919
Local: (*struct {
20-
Path string `mapstructure:"path"`
21-
ImportEnabled bool `mapstructure:"import_enabled"`
22-
ImportHidden bool `mapstructure:"import_hidden"`
23-
AllowedExternalPrefixes []string `mapstructure:"allowed_external_prefixes"`
20+
Path string `mapstructure:"path" json:"path"`
21+
ImportEnabled bool `mapstructure:"import_enabled" json:"import_enabled"`
22+
ImportHidden bool `mapstructure:"import_hidden" json:"import_hidden"`
23+
AllowedExternalPrefixes []string `mapstructure:"allowed_external_prefixes" json:"allowed_external_prefixes"`
2424
})(&struct {
2525
Path string
2626
ImportEnabled bool

controller/branch_ctl.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ func (bct BranchController) ListBranches(ctx context.Context, w *api.JiaozifsRes
9696
r := api.Branch{
9797
CommitHash: branch.CommitHash.Hex(),
9898
CreatedAt: branch.CreatedAt,
99-
CreatorID: branch.CreatorID,
99+
CreatorId: branch.CreatorID,
100100
Description: branch.Description,
101-
ID: branch.ID,
101+
Id: branch.ID,
102102
Name: branch.Name,
103-
RepositoryID: branch.RepositoryID,
103+
RepositoryId: branch.RepositoryID,
104104
UpdatedAt: branch.UpdatedAt,
105105
}
106106
results = append(results, r)
@@ -171,7 +171,7 @@ func (bct BranchController) CreateBranch(ctx context.Context, w *api.JiaozifsRes
171171
}
172172

173173
// Create branch
174-
newBranch := &models.Branches{
174+
newBranch := &models.Branch{
175175
RepositoryID: repository.ID,
176176
CommitHash: commitHash,
177177
Name: body.Name,
@@ -187,11 +187,11 @@ func (bct BranchController) CreateBranch(ctx context.Context, w *api.JiaozifsRes
187187
w.JSON(api.Branch{
188188
CommitHash: newBranch.CommitHash.Hex(),
189189
CreatedAt: newBranch.CreatedAt,
190-
CreatorID: newBranch.CreatorID,
190+
CreatorId: newBranch.CreatorID,
191191
Description: newBranch.Description,
192-
ID: newBranch.ID,
192+
Id: newBranch.ID,
193193
Name: newBranch.Name,
194-
RepositoryID: newBranch.RepositoryID,
194+
RepositoryId: newBranch.RepositoryID,
195195
UpdatedAt: newBranch.UpdatedAt,
196196
}, http.StatusCreated)
197197
}
@@ -268,11 +268,11 @@ func (bct BranchController) GetBranch(ctx context.Context, w *api.JiaozifsRespon
268268
w.JSON(api.Branch{
269269
CommitHash: ref.CommitHash.Hex(),
270270
CreatedAt: ref.CreatedAt,
271-
CreatorID: ref.CreatorID,
271+
CreatorId: ref.CreatorID,
272272
Description: ref.Description,
273-
ID: ref.ID,
273+
Id: ref.ID,
274274
Name: ref.Name,
275-
RepositoryID: ref.RepositoryID,
275+
RepositoryId: ref.RepositoryID,
276276
UpdatedAt: ref.UpdatedAt,
277277
})
278278
}

controller/repository_ctl.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ func (repositoryCtl RepositoryController) ListRepositoryOfAuthenticatedUser(ctx
8787
for _, repo := range repositories {
8888
r := api.Repository{
8989
CreatedAt: repo.CreatedAt,
90-
CreatorID: repo.CreatorID,
90+
CreatorId: repo.CreatorID,
9191
Description: repo.Description,
9292
Head: repo.HEAD,
93-
ID: repo.ID,
93+
Id: repo.ID,
9494
Name: repo.Name,
9595
UpdatedAt: repo.UpdatedAt,
9696
}
@@ -149,10 +149,10 @@ func (repositoryCtl RepositoryController) ListRepository(ctx context.Context, w
149149
for _, repo := range repositories {
150150
r := api.Repository{
151151
CreatedAt: repo.CreatedAt,
152-
CreatorID: repo.CreatorID,
152+
CreatorId: repo.CreatorID,
153153
Description: repo.Description,
154154
Head: repo.HEAD,
155-
ID: repo.ID,
155+
Id: repo.ID,
156156
Name: repo.Name,
157157
UpdatedAt: repo.UpdatedAt,
158158
}
@@ -185,9 +185,9 @@ func (repositoryCtl RepositoryController) CreateRepository(ctx context.Context,
185185
}
186186

187187
var usePublicStorage = true
188-
storageConfig := utils.StringValue(body.BlockStoreConfig)
188+
storageConfig := utils.StringValue(body.BlockstoreConfig)
189189
repoID := uuid.New()
190-
var storageNamespace string
190+
var storageNamespace *string
191191
if len(storageConfig) > 0 {
192192
usePublicStorage = false
193193
var cfg = config.BlockStoreConfig{}
@@ -202,12 +202,12 @@ func (repositoryCtl RepositoryController) CreateRepository(ctx context.Context,
202202
w.Forbidden()
203203
return
204204
}
205-
storageNamespace = utils.StringValue(cfg.DefaultNamespacePrefix)
205+
storageNamespace = cfg.DefaultNamespacePrefix
206206
} else {
207-
storageNamespace = fmt.Sprintf("%s://%s", repositoryCtl.PublicStorageConfig.BlockstoreType(), repoID.String())
207+
storageNamespace = utils.String(fmt.Sprintf("%s://%s", repositoryCtl.PublicStorageConfig.BlockstoreType(), repoID.String()))
208208
}
209209

210-
defaultRef := &models.Branches{
210+
defaultRef := &models.Branch{
211211
RepositoryID: repoID,
212212
CommitHash: hash.Hash{},
213213
Name: DefaultBranchName,
@@ -219,7 +219,7 @@ func (repositoryCtl RepositoryController) CreateRepository(ctx context.Context,
219219
ID: repoID,
220220
Name: body.Name,
221221
UsePublicStorage: usePublicStorage,
222-
StorageAdapterParams: storageConfig,
222+
StorageAdapterParams: &storageConfig,
223223
StorageNamespace: storageNamespace,
224224
Description: body.Description,
225225
HEAD: DefaultBranchName,
@@ -246,10 +246,10 @@ func (repositoryCtl RepositoryController) CreateRepository(ctx context.Context,
246246

247247
w.JSON(api.Repository{
248248
CreatedAt: createdRepo.CreatedAt,
249-
CreatorID: createdRepo.CreatorID,
249+
CreatorId: createdRepo.CreatorID,
250250
Description: createdRepo.Description,
251251
Head: createdRepo.HEAD,
252-
ID: createdRepo.ID,
252+
Id: createdRepo.ID,
253253
Name: createdRepo.Name,
254254
UpdatedAt: createdRepo.UpdatedAt,
255255
})
@@ -403,7 +403,7 @@ func (repositoryCtl RepositoryController) GetCommitsInRepository(ctx context.Con
403403
if err == nil {
404404
modelCommit := commit.Commit()
405405
commits = append(commits, api.Commit{
406-
RepositoryID: modelCommit.RepositoryID,
406+
RepositoryId: modelCommit.RepositoryID,
407407
Author: api.Signature{
408408
Email: openapi_types.Email(modelCommit.Author.Email),
409409
Name: modelCommit.Author.Name,

controller/user_ctl.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (userCtl UserController) Login(ctx context.Context, w *api.JiaozifsResponse
8080

8181
func (userCtl UserController) Register(ctx context.Context, w *api.JiaozifsResponse, _ *http.Request, body api.RegisterJSONRequestBody) {
8282
register := auth.Register{
83-
Username: body.Username,
83+
Username: body.Name,
8484
Email: string(body.Email),
8585
Password: body.Password,
8686
}
@@ -104,14 +104,14 @@ func (userCtl UserController) GetUserInfo(ctx context.Context, w *api.JiaozifsRe
104104

105105
// perform GetUserInfo
106106
userInfo := api.UserInfo{
107-
CreatedAt: &user.CreatedAt,
108-
CurrentSignInAt: &user.CurrentSignInAt,
109-
CurrentSignInIP: &user.CurrentSignInIP,
107+
Name: user.Name,
110108
Email: openapitypes.Email(user.Email),
109+
CurrentSignInAt: &user.CurrentSignInAt,
110+
CurrentSignInIp: &user.CurrentSignInIP,
111111
LastSignInAt: &user.LastSignInAt,
112-
LastSignInIP: &user.LastSignInIP,
113-
UpdateAt: &user.UpdatedAt,
114-
Username: user.Name,
112+
LastSignInIp: &user.LastSignInIP,
113+
UpdatedAt: user.UpdatedAt,
114+
CreatedAt: user.CreatedAt,
115115
}
116116
w.JSON(userInfo)
117117
}

integrationtest/commit_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ func GetEntriesInRefSpec(ctx context.Context, urlStr string) func(c convey.C) {
102102
result, err := api.ParseGetEntriesInRefResponse(resp)
103103
convey.So(err, convey.ShouldBeNil)
104104
convey.So(*result.JSON200, convey.ShouldHaveLength, 2)
105-
convey.So(*(*result.JSON200)[0].Name, convey.ShouldEqual, "m.dat")
106-
convey.So(*(*result.JSON200)[1].Name, convey.ShouldEqual, "x.dat")
105+
convey.So((*result.JSON200)[0].Name, convey.ShouldEqual, "m.dat")
106+
convey.So((*result.JSON200)[1].Name, convey.ShouldEqual, "x.dat")
107107
})
108108

109109
c.Convey("success to get entries in root", func() {
@@ -118,8 +118,8 @@ func GetEntriesInRefSpec(ctx context.Context, urlStr string) func(c convey.C) {
118118
result, err := api.ParseGetEntriesInRefResponse(resp)
119119
convey.So(err, convey.ShouldBeNil)
120120
convey.So(*result.JSON200, convey.ShouldHaveLength, 2)
121-
convey.So(*(*result.JSON200)[0].Name, convey.ShouldEqual, "g")
122-
convey.So(*(*result.JSON200)[1].Name, convey.ShouldEqual, "m.dat")
121+
convey.So((*result.JSON200)[0].Name, convey.ShouldEqual, "g")
122+
convey.So((*result.JSON200)[1].Name, convey.ShouldEqual, "m.dat")
123123
})
124124
})
125125

@@ -201,8 +201,8 @@ func GetEntriesInRefSpec(ctx context.Context, urlStr string) func(c convey.C) {
201201
result, err := api.ParseGetEntriesInRefResponse(resp)
202202
convey.So(err, convey.ShouldBeNil)
203203
convey.So(*result.JSON200, convey.ShouldHaveLength, 2)
204-
convey.So(*(*result.JSON200)[0].Name, convey.ShouldEqual, "m.dat")
205-
convey.So(*(*result.JSON200)[1].Name, convey.ShouldEqual, "x.dat")
204+
convey.So((*result.JSON200)[0].Name, convey.ShouldEqual, "m.dat")
205+
convey.So((*result.JSON200)[1].Name, convey.ShouldEqual, "x.dat")
206206
})
207207

208208
c.Convey("success to get entries in root", func() {
@@ -217,8 +217,8 @@ func GetEntriesInRefSpec(ctx context.Context, urlStr string) func(c convey.C) {
217217
result, err := api.ParseGetEntriesInRefResponse(resp)
218218
convey.So(err, convey.ShouldBeNil)
219219
convey.So(*result.JSON200, convey.ShouldHaveLength, 2)
220-
convey.So(*(*result.JSON200)[0].Name, convey.ShouldEqual, "g")
221-
convey.So(*(*result.JSON200)[1].Name, convey.ShouldEqual, "m.dat")
220+
convey.So((*result.JSON200)[0].Name, convey.ShouldEqual, "g")
221+
convey.So((*result.JSON200)[1].Name, convey.ShouldEqual, "m.dat")
222222
})
223223
})
224224

integrationtest/helper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func SetupDaemon(t *testing.T, ctx context.Context) (string, Closer) { //nolint
105105
func createUser(ctx context.Context, c convey.C, client *api.Client, userName string) {
106106
c.Convey("register "+userName, func() {
107107
resp, err := client.Register(ctx, api.RegisterJSONRequestBody{
108-
Username: userName,
108+
Name: userName,
109109
Password: "12345678",
110110
Email: "mock@gmail.com",
111111
})

integrationtest/repo_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) {
3535
resp, err := client.CreateRepository(ctx, api.CreateRepository{
3636
Description: utils.String("test resp"),
3737
Name: "happygo",
38-
BlockStoreConfig: utils.String(cfg),
38+
BlockstoreConfig: utils.String(cfg),
3939
})
4040
convey.So(err, convey.ShouldBeNil)
4141
convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusBadRequest)
@@ -46,7 +46,7 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) {
4646
resp, err := client.CreateRepository(ctx, api.CreateRepository{
4747
Description: utils.String("test resp"),
4848
Name: "happygo",
49-
BlockStoreConfig: utils.String(cfg),
49+
BlockstoreConfig: utils.String(cfg),
5050
})
5151
convey.So(err, convey.ShouldBeNil)
5252
convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusForbidden)
@@ -63,7 +63,7 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) {
6363
grp, err := api.ParseGetRepositoryResponse(resp)
6464
convey.So(err, convey.ShouldBeNil)
6565
convey.So(grp.JSON200.Head, convey.ShouldEqual, controller.DefaultBranchName)
66-
fmt.Println(grp.JSON200.ID)
66+
fmt.Println(grp.JSON200.Id)
6767
//check default branch created
6868
branchResp, err := client.GetBranch(ctx, userName, grp.JSON200.Name, &api.GetBranchParams{RefName: controller.DefaultBranchName})
6969
convey.So(err, convey.ShouldBeNil)

0 commit comments

Comments
 (0)