From 4b37eb2c23f8488f36247f25f9cfd4949eb17e23 Mon Sep 17 00:00:00 2001
From: Giteabot <teabot@gitea.io>
Date: Mon, 25 Sep 2023 15:02:08 +0800
Subject: [PATCH] Fix PushEvent NullPointerException jenkinsci/github-plugin
 (#27203) (#27249)

Backport #27203 by @Nabapadma-sarker

Fixes #27202

Co-authored-by: Nabapadma-sarker <nabapadmacse1991@gmail.com>
---
 modules/structs/repo.go        | 1 +
 services/convert/repository.go | 1 +
 templates/swagger/v1_json.tmpl | 4 ++++
 3 files changed, 6 insertions(+)

diff --git a/modules/structs/repo.go b/modules/structs/repo.go
index 159ba76cec..a131646fc0 100644
--- a/modules/structs/repo.go
+++ b/modules/structs/repo.go
@@ -63,6 +63,7 @@ type Repository struct {
 	Language      string      `json:"language"`
 	LanguagesURL  string      `json:"languages_url"`
 	HTMLURL       string      `json:"html_url"`
+	URL           string      `json:"url"`
 	Link          string      `json:"link"`
 	SSHURL        string      `json:"ssh_url"`
 	CloneURL      string      `json:"clone_url"`
diff --git a/services/convert/repository.go b/services/convert/repository.go
index 6f77b4932e..71038cd062 100644
--- a/services/convert/repository.go
+++ b/services/convert/repository.go
@@ -181,6 +181,7 @@ func innerToRepo(ctx context.Context, repo *repo_model.Repository, permissionInR
 		Parent:                        parent,
 		Mirror:                        repo.IsMirror,
 		HTMLURL:                       repo.HTMLURL(),
+		URL:                           repoAPIURL,
 		SSHURL:                        cloneLink.SSH,
 		CloneURL:                      cloneLink.HTTPS,
 		OriginalURL:                   repo.SanitizedOriginalURL(),
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index 6bedcfd4f0..370bed2b24 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -21038,6 +21038,10 @@
           "format": "date-time",
           "x-go-name": "Updated"
         },
+        "url": {
+          "type": "string",
+          "x-go-name": "URL"
+        },
         "watchers_count": {
           "type": "integer",
           "format": "int64",