-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): rename swagger-spec.yaml to open-api.yaml
- Loading branch information
Showing
12 changed files
with
133 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
packages/@ama-sdk/schematics/schematics/helpers/generators.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
// TODO: Change to `openapi` in v11 (ref: #1745) | ||
/** Name of the specification file copied locally (without extension) */ | ||
export const LOCAL_SPEC_FILENAME = 'swagger-spec'; | ||
export const LOCAL_SPEC_FILENAME = 'open-api'; | ||
|
||
/** Extension of the Specification file in YAML format */ | ||
export const SPEC_YAML_EXTENSION = 'yaml'; | ||
|
||
// TODO: Change to `json` in v11 (ref: #1745) | ||
/** Extension of the Specification file in JSON format */ | ||
export const SPEC_JSON_EXTENSION = 'yaml'; | ||
export const SPEC_JSON_EXTENSION = 'json'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/@ama-sdk/schematics/schematics/ng-update/typescript/v11.0/update-openapitools.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Rule } from '@angular-devkit/schematics'; | ||
import { findFilesInTree } from '@o3r/schematics'; | ||
import { LOCAL_SPEC_FILENAME } from '../../../helpers/generators'; | ||
|
||
/** | ||
* Update Regen Script to base remove 'swagger' keyword | ||
* @param tree | ||
*/ | ||
export const updateOpenapitoolsFile: Rule = (tree) => { | ||
const files = findFilesInTree(tree.root, (p) => p.endsWith('openapitools.json')); | ||
|
||
files.forEach((file) => { | ||
const configFileContent = tree.readText(file.path); | ||
|
||
if (configFileContent.includes('swagger-spec.yaml')) { | ||
tree.overwrite(file.path, configFileContent.replace(/swagger-spec\.yaml/g, `${LOCAL_SPEC_FILENAME}.yaml`)); | ||
} | ||
}); | ||
}; |
32 changes: 32 additions & 0 deletions
32
packages/@ama-sdk/schematics/schematics/ng-update/typescript/v11.0/update-regen-script.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Rule } from '@angular-devkit/schematics'; | ||
import { findFilesInTree } from '@o3r/schematics'; | ||
import type { PackageJson } from 'type-fest'; | ||
import { LOCAL_SPEC_FILENAME } from '../../../helpers/generators'; | ||
|
||
const SCRIPT_REGEN_LABEL = 'spec:regen'; | ||
|
||
/** | ||
* Update Regen Script to base remove 'swagger' keyword | ||
* @param tree | ||
*/ | ||
export const updateRegenScript: Rule = (tree) => { | ||
const files = findFilesInTree(tree.root, (p) => p.endsWith('package.json')); | ||
|
||
files.forEach((file) => { | ||
const packageJson = tree.readJson(file.path) as PackageJson; | ||
if (!packageJson.scripts || !Object.keys(packageJson.scripts).includes(SCRIPT_REGEN_LABEL)) { | ||
return; | ||
} | ||
|
||
const swaggerFilePath = file.path.replace(/package\.json$/, 'swagger-spec.yaml'); | ||
if (!tree.exists(swaggerFilePath)) { | ||
return; | ||
} | ||
|
||
packageJson.scripts[SCRIPT_REGEN_LABEL] = packageJson.scripts[SCRIPT_REGEN_LABEL]!.replace(/swagger-spec\.yaml/g, `${LOCAL_SPEC_FILENAME}.yaml`); | ||
tree.overwrite(file.path, JSON.stringify(packageJson, null, 2)); | ||
|
||
const openApiFilePath = file.path.replace(/package\.json$/, `${LOCAL_SPEC_FILENAME}.yaml`); | ||
tree.rename(swaggerFilePath, openApiFilePath); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters