diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ad72fb..e238dd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/). - The `updated_at` date for language data is now the most recent last modified date of the data, matching `/data-version`, rather than the date of the request. - Data contracts exported from Scribe-Data are now copied to the server and deployed to Toolforge with the data so that `/contracts` returns them, and a clear error is returned if they're not available ([#113](https://github.com/scribe-org/Scribe-Server/issues/113)). - `/contracts?lang={lang}` returns only that language's contract exactly as exported by Scribe-Data as JSON (e.g. `en.json`), keeping the order of the contract's keys. - - `/contracts` returns a `data_contracts.zip` archive with a `data_contracts` directory of JSON contracts for all languages. + - `/contracts` returns a `scribe_data_contracts.zip` archive with a `scribe_data_contracts` directory of JSON contracts for all languages. - The `update_data.sh` download command was fixed to specify the correct dump snapshot location ([#65](https://github.com/scribe-org/Scribe-Server/pull/65)). - Trusted proxies are now explicitly configured for security. - `/packs` requests with `..` in the path are rejected so they can't show whether directories outside of the packs directory exist, `/packs/sqlite/list` returns `[]` instead of `null` when there are no SQLite files, and SQLite download file names are quoted ([#91](https://github.com/scribe-org/Scribe-Server/issues/91)). diff --git a/api/handlers/contracts.go b/api/handlers/contracts.go index 93aa0d7..2b4b31f 100644 --- a/api/handlers/contracts.go +++ b/api/handlers/contracts.go @@ -19,7 +19,7 @@ import ( ) // contractsArchiveDir is the directory in the zip archive of all contracts. -const contractsArchiveDir = "data_contracts" +const contractsArchiveDir = "scribe_data_contracts" // contractExtensions are the file extensions of contracts in order of preference. var contractExtensions = []string{".yaml", ".yml"} @@ -218,7 +218,7 @@ func loadAllContracts(contractsDir string) ([]contractFile, error) { // MARK: Contracts Archive -// writeContractsZip writes a zip archive with a data_contracts directory of JSON contracts. +// writeContractsZip writes a zip archive with a scribe_data_contracts directory of JSON contracts. // It's a package-level variable to allow mocking in unit tests. var writeContractsZip = func(w io.Writer, contracts []contractFile) error { archive := zip.NewWriter(w) diff --git a/api/handlers/contracts_test.go b/api/handlers/contracts_test.go index 532b682..c442d4c 100644 --- a/api/handlers/contracts_test.go +++ b/api/handlers/contracts_test.go @@ -298,7 +298,7 @@ type failingWriter struct{} func (failingWriter) Write(_ []byte) (int, error) { return 0, errors.New("write failed") } func TestWriteContractsZip(t *testing.T) { - t.Run("writes a data_contracts directory of JSON contracts", func(t *testing.T) { + t.Run("writes a scribe_data_contracts directory of JSON contracts", func(t *testing.T) { modified := time.Date(2026, 10, 1, 12, 0, 0, 0, time.UTC) contracts := []contractFile{ {lang: "de", json: []byte(`{"prepositions": {}}`), modified: modified}, @@ -313,7 +313,7 @@ func TestWriteContractsZip(t *testing.T) { require.Len(t, reader.File, 2) for i, file := range reader.File { - assert.Equal(t, "data_contracts/"+contracts[i].lang+".json", file.Name) + assert.Equal(t, "scribe_data_contracts/"+contracts[i].lang+".json", file.Name) assert.True(t, file.Modified.Equal(modified)) content, err := file.Open() @@ -368,7 +368,7 @@ func TestGetContracts(t *testing.T) { require.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, "application/zip", rec.Header().Get("Content-Type")) - assert.Equal(t, `attachment; filename="data_contracts.zip"`, rec.Header().Get("Content-Disposition")) + assert.Equal(t, `attachment; filename="scribe_data_contracts.zip"`, rec.Header().Get("Content-Disposition")) reader, err := zip.NewReader(bytes.NewReader(rec.Body.Bytes()), int64(rec.Body.Len())) require.NoError(t, err) @@ -386,7 +386,7 @@ func TestGetContracts(t *testing.T) { lang := strings.TrimSuffix(filepath.Base(file.Name), ".json") assert.Equal(t, getContracts(router, "?lang="+lang).Body.Bytes(), data) } - assert.Equal(t, []string{"data_contracts/de.json", "data_contracts/en.json"}, names) + assert.Equal(t, []string{"scribe_data_contracts/de.json", "scribe_data_contracts/en.json"}, names) }) t.Run("400 for an invalid language code", func(t *testing.T) { diff --git a/api/handlers/language.go b/api/handlers/language.go index 4351ee2..f061fdc 100644 --- a/api/handlers/language.go +++ b/api/handlers/language.go @@ -214,13 +214,13 @@ func GetLanguageVersion(c *gin.Context) { // GetContracts returns the data contract for a language as JSON, or a zip archive of all contracts. // // @Summary Retrieve data contracts -// @Description Returns a language's contract as JSON ({lang}.json), or a zip of all contracts (data_contracts.zip) without 'lang'. +// @Description Returns a language's contract as JSON ({lang}.json), or a zip of all contracts (scribe_data_contracts.zip) without 'lang'. // @Tags Contracts // @Accept json // @Produce json,application/zip // @Param lang query string false "Language code (ISO 639-1)" example(es) // @Success 200 {file} file "The language's contract as JSON, or a zip archive of all contracts" -// @Header 200 {string} Content-Disposition "inline; filename={lang}.json, or attachment; filename=data_contracts.zip for all languages" +// @Header 200 {string} Content-Disposition "inline; filename={lang}.json, or attachment; filename=scribe_data_contracts.zip for all languages" // @Failure 400 {object} models.ErrorResponse "Invalid language code provided" // @Failure 404 {object} models.ErrorResponse "Language not supported" // @Failure 500 {object} models.ErrorResponse "Failed to load contract files" diff --git a/docs/docs.go b/docs/docs.go index 2ef069d..d8fccc9 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -26,7 +26,7 @@ const docTemplate = `{ "paths": { "/api/v1/contracts": { "get": { - "description": "Returns a language's contract as JSON ({lang}.json), or a zip of all contracts (data_contracts.zip) without 'lang'.", + "description": "Returns a language's contract as JSON ({lang}.json), or a zip of all contracts (scribe_data_contracts.zip) without 'lang'.", "consumes": [ "application/json" ], @@ -56,7 +56,7 @@ const docTemplate = `{ "headers": { "Content-Disposition": { "type": "string", - "description": "inline; filename={lang}.json, or attachment; filename=data_contracts.zip for all languages" + "description": "inline; filename={lang}.json, or attachment; filename=scribe_data_contracts.zip for all languages" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index 7f722a8..c9e8477 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -20,7 +20,7 @@ "paths": { "/api/v1/contracts": { "get": { - "description": "Returns a language's contract as JSON ({lang}.json), or a zip of all contracts (data_contracts.zip) without 'lang'.", + "description": "Returns a language's contract as JSON ({lang}.json), or a zip of all contracts (scribe_data_contracts.zip) without 'lang'.", "consumes": [ "application/json" ], @@ -50,7 +50,7 @@ "headers": { "Content-Disposition": { "type": "string", - "description": "inline; filename={lang}.json, or attachment; filename=data_contracts.zip for all languages" + "description": "inline; filename={lang}.json, or attachment; filename=scribe_data_contracts.zip for all languages" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index bf92950..a1ae4b8 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -137,7 +137,7 @@ paths: consumes: - application/json description: Returns a language's contract as JSON ({lang}.json), or a zip of - all contracts (data_contracts.zip) without 'lang'. + all contracts (scribe_data_contracts.zip) without 'lang'. parameters: - description: Language code (ISO 639-1) example: es @@ -152,7 +152,7 @@ paths: description: The language's contract as JSON, or a zip archive of all contracts headers: Content-Disposition: - description: inline; filename={lang}.json, or attachment; filename=data_contracts.zip + description: inline; filename={lang}.json, or attachment; filename=scribe_data_contracts.zip for all languages type: string schema: