diff --git a/apps/showcase/src/style/dark-theme/dark-theme.scss b/apps/showcase/src/style/dark-theme/dark-theme.scss index 7e89e1b312..09882210e5 100644 --- a/apps/showcase/src/style/dark-theme/dark-theme.scss +++ b/apps/showcase/src/style/dark-theme/dark-theme.scss @@ -80,7 +80,7 @@ --radius-5: 5px; --radius-10: 10px; --radius-25: 25px; - --spacing-0: 0px; + --spacing-0: 0; --spacing-1: 1px; --spacing-5: 5px; --spacing-10: 10px; diff --git a/apps/showcase/src/style/horizon-theme/horizon-theme.scss b/apps/showcase/src/style/horizon-theme/horizon-theme.scss index e04d42e994..a10239f58d 100644 --- a/apps/showcase/src/style/horizon-theme/horizon-theme.scss +++ b/apps/showcase/src/style/horizon-theme/horizon-theme.scss @@ -72,7 +72,7 @@ --radius-5: 5px; --radius-10: 10px; --radius-25: 25px; - --spacing-0: 0px; + --spacing-0: 0; --spacing-1: 1px; --spacing-5: 5px; --spacing-10: 10px; diff --git a/apps/showcase/src/style/theme.scss b/apps/showcase/src/style/theme.scss index f6db364301..2621fa0da2 100644 --- a/apps/showcase/src/style/theme.scss +++ b/apps/showcase/src/style/theme.scss @@ -73,7 +73,7 @@ --radius-5: 5px; --radius-10: 10px; --radius-25: 25px; - --spacing-0: 0px; + --spacing-0: 0; --spacing-1: 1px; --spacing-5: 5px; --spacing-10: 10px; diff --git a/nx.json b/nx.json index cb0a8f1165..64d02950ae 100644 --- a/nx.json +++ b/nx.json @@ -223,10 +223,14 @@ "source", "specs" ], - "dependsOn": [{ - "projects": ["test-helpers"], - "target": "build" - }], + "dependsOn": [ + { + "projects": [ + "test-helpers" + ], + "target": "build" + } + ], "outputs": [ "{projectRoot}/dist-test/junit.xml", "{projectRoot}/coverage/cobertura-coverage.xml" @@ -247,10 +251,14 @@ }, "test-int": { "executor": "@nx/jest:jest", - "dependsOn": [{ - "projects": ["test-helpers"], - "target": "build" - }], + "dependsOn": [ + { + "projects": [ + "test-helpers" + ], + "target": "build" + } + ], "inputs": [ { "env": "RUNNER_OS" @@ -732,5 +740,6 @@ "appsDir": "apps" }, "cacheDirectory": ".cache/nx", - "nxCloudId": "63e6951e043da20dd8321aec" -} + "nxCloudId": "63e6951e043da20dd8321aec", + "analytics": false +} \ No newline at end of file diff --git a/packages/@ama-openapi/create/package.json b/packages/@ama-openapi/create/package.json index 3c06f78614..eaee0ce7d3 100644 --- a/packages/@ama-openapi/create/package.json +++ b/packages/@ama-openapi/create/package.json @@ -93,7 +93,7 @@ "typescript-eslint": "~8.57.0" }, "generatorDependencies": { - "@redocly/openapi-core": "~2.24.0" + "@redocly/openapi-core": "~2.25.0" }, "engines": { "node": "^22.17.0 || ^24.0.0", diff --git a/packages/@ama-sdk/schematics/README.md b/packages/@ama-sdk/schematics/README.md index 805498570f..1e03bb1c15 100644 --- a/packages/@ama-sdk/schematics/README.md +++ b/packages/@ama-sdk/schematics/README.md @@ -200,6 +200,26 @@ The Body request parameter generated in the SDK can also be defined in the speci > [!WARNING] > This vendor extension will take precedence over the global property `requestBodyTransform`. +##### Dynamic Enums Type + +By default, enums are generated as static types. You can enable dynamic enum type generation by using the global property option `useDynamicEnumType` by adding `--global-property useDynamicEnumType=true` to the generator command. + +This option allows enums to be generated as dynamic types that can handle additional values not explicitly defined in the specification, making your SDK more resilient to API changes. + +Example: + +```shell +yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml --global-property useDynamicEnumType=true +``` + +##### Override Discriminator Type with Value + +By default, when a discriminator is used in the specification file, the children models are generated with a type that corresponds to the discriminator property and its value (for example, if the discriminator is `petType` and its value is `Dog`, the generated type for the children model will be `Dog`). You can enable the generation of the discriminator property as a type instead of its value by using the global property option `overrideDiscriminatorTypeWithValue` by adding `--global-property overrideDiscriminatorTypeWithValue=true` to the generator command. + +##### Children Model List Type Suffix + +The options `childrenModelListTypeSuffix` will add a suffix to the generated type of the list of children models when a discriminator is used in the specification file. If not specified the list of object children will not be generated. + ##### Extensible models You may be in a case in which you want to be able to extend your SDK models and therefore ensure that revivers are generated diff --git a/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/java/com/amadeus/codegen/ts/AbstractTypeScriptClientCodegen.java b/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/java/com/amadeus/codegen/ts/AbstractTypeScriptClientCodegen.java index 465f26d5a7..fbbcfd94bd 100644 --- a/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/java/com/amadeus/codegen/ts/AbstractTypeScriptClientCodegen.java +++ b/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/java/com/amadeus/codegen/ts/AbstractTypeScriptClientCodegen.java @@ -47,7 +47,10 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp private final boolean stringifyDate; private final boolean allowModelExtension; private final boolean useLegacyDateExtension; + private final boolean useDynamicEnumType; + private final boolean overrideDiscriminatorTypeWithValue; private final String requestBodyTransform; + private final String childrenModelListTypeSuffix; public AbstractTypeScriptClientCodegen() { super(); @@ -120,6 +123,12 @@ public AbstractTypeScriptClientCodegen() { stringifyDate = stringifyDateString != null ? !"false".equalsIgnoreCase(stringifyDateString) : true; String requestBodyTransformString = GlobalSettings.getProperty("requestBodyTransform"); requestBodyTransform = requestBodyTransformString != null ? requestBodyTransformString : ""; + String useDynamicEnumTypeString = GlobalSettings.getProperty("useDynamicEnumType"); + useDynamicEnumType = useDynamicEnumTypeString != null ? !"false".equalsIgnoreCase(useDynamicEnumTypeString) : false; + String overrideDiscriminatorTypeWithValueString = GlobalSettings.getProperty("overrideDiscriminatorTypeWithValue"); + overrideDiscriminatorTypeWithValue = overrideDiscriminatorTypeWithValueString != null ? !"false".equalsIgnoreCase(overrideDiscriminatorTypeWithValueString) : false; + String childrenModelListTypeSuffixString = GlobalSettings.getProperty("childrenModelListTypeSuffix"); + childrenModelListTypeSuffix = childrenModelListTypeSuffixString; typeMapping.put("DateTime", useLegacyDateExtension ? "utils.DateTime" : getDateTimeStandardTime(stringifyDate)); typeMapping.put("Date", useLegacyDateExtension ? "utils.Date" : getDateType(stringifyDate)); //TODO binary should be mapped to byte array @@ -161,6 +170,7 @@ public AbstractTypeScriptClientCodegen() { additionalProperties.put("resourceFromPath", new LambdaHelper.ResourceFromPath()); additionalProperties.put("areaFromPath", new LambdaHelper.AreaFromPath()); additionalProperties.put("noEmptyLines", new LambdaHelper.RemoveEmptyLines()); + additionalProperties.put("noMultipleEmptyLines", new LambdaHelper.RemoveDuplicateEmptyLines()); additionalProperties.put("replaceWithEmptyExportIfNeeded", new LambdaHelper.ReplaceWithTextIfEmpty("export {};")); additionalProperties.put("propertyDeclaration", new LambdaHelper.PropertyDeclaration()); additionalProperties.put("propertyAccess", new LambdaHelper.PropertyAccess()); @@ -657,6 +667,15 @@ public ModelsMap postProcessModels(ModelsMap objs) { // Set additional properties and check non model objects for (ModelMap modelMap : models) { CodegenModel model = modelMap.getModel(); + + if (model.discriminator != null) { + List discriminatorValues = new ArrayList(); + for (CodegenDiscriminator.MappedModel mm : model.discriminator.getMappedModels()) { + discriminatorValues.add(mm.getModelName()); + } + model.vendorExtensions.put("x-discriminator-mapping-values", discriminatorValues); + } + if (model.isEnum) { nonObjectModels.add(toModelName(model.name)); } @@ -744,6 +763,9 @@ private ModelsMap postProcessImports(ModelsMap objs) { @Override public Map postProcessAllModels(Map objs) { System.out.println("Non object models: " + nonObjectModels.toString()); + + Map discriminatorField = new HashMap<>(); + Map discriminatorValue = new HashMap<>(); for (Map.Entry entry : objs.entrySet()) { ModelsMap modelsMap = entry.getValue(); List modelMaps = modelsMap.getModels(); @@ -769,12 +791,43 @@ public Map postProcessAllModels(Map objs) prop.vendorExtensions.put("nonObjectDefinition", nonObjectDefinition); } } + + if (model.discriminator != null) { + for (CodegenDiscriminator.MappedModel mm : model.discriminator.getMappedModels()) { + discriminatorField.put(mm.getModelName(), model.discriminator.getPropertyName()); + discriminatorValue.put(mm.getModelName(), mm.getMappingName()); + } + } } } + objs = super.postProcessAllModels(objs); for (Map.Entry entry : objs.entrySet()) { entry.setValue(this.postProcessImports(entry.getValue())); + ModelsMap modelsMap = entry.getValue(); + List modelMaps = modelsMap.getModels(); + for (ModelMap _modelMap : modelMaps) { + CodegenModel model = _modelMap.getModel(); + // Set the useDynamicEnumType vendor extension for the model and its properties to be able to use it in the templates + model.vendorExtensions.put("x-use-dynamic-enum-type", useDynamicEnumType); + // Set the overrideDiscriminatorTypeWithValue vendor extension for the model to be able to use it in the templates + model.vendorExtensions.put("x-override-discriminator-type-with-value", overrideDiscriminatorTypeWithValue); + // Set the childrenModelListTypeSuffix vendor extension for the model to be able to use it in the templates + model.vendorExtensions.put("x-children-model-list-type-suffix", childrenModelListTypeSuffix); + for (CodegenProperty prop : model.getAllVars()) { + if (prop.isEnum) { + prop.vendorExtensions.put("x-use-dynamic-enum-type", useDynamicEnumType); + } + } + + // Set discriminator field and value as vendor extension for the model if any, to be able to use it in the templates + if (discriminatorField.containsKey(model.classname) && discriminatorValue.containsKey(model.classname)) { + model.vendorExtensions.put("x-discriminator-field", discriminatorField.get(model.classname)); + model.vendorExtensions.put("x-discriminator-value", discriminatorValue.get(model.classname)); + } + } } + // if allowModelExtension is true, we don't need to analyze the conditions since we want to ensure the generation of the revivers if (!allowModelExtension) { Predicate varRequiredReviverPredicate = var -> !(var.isPrimitiveType || var.complexType != null || var.isEnum || var.isEnumRef); diff --git a/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/java/com/amadeus/codegen/ts/LambdaHelper.java b/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/java/com/amadeus/codegen/ts/LambdaHelper.java index 20e925a443..302aae0e08 100644 --- a/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/java/com/amadeus/codegen/ts/LambdaHelper.java +++ b/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/java/com/amadeus/codegen/ts/LambdaHelper.java @@ -591,4 +591,22 @@ public String formatFragment(String fragment) { return requestBodyTransform.replace("{{bodyRequest}}", fragment); } } + + public static class RemoveDuplicateEmptyLines extends CustomLambda { + + final String whitespaceTransform = "(\\n\\r?){3,}"; + final String trailingWhitespaceTransform = "(\\n\\r?){2,}$"; + + public RemoveDuplicateEmptyLines() { + } + + @Override + public String formatFragment(String fragment) { + if (fragment == null || fragment.equals("")) { + return fragment; + } + fragment = fragment.replaceAll(whitespaceTransform, "\n"); + return fragment.replaceAll(trailingWhitespaceTransform, "\n"); + } + } } diff --git a/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch/api/api.mustache b/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch/api/api.mustache index bed5f79333..a497512c1f 100644 --- a/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch/api/api.mustache +++ b/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch/api/api.mustache @@ -1,6 +1,6 @@ {{#noUnusedImport}} {{#imports}} -import { {{import}} } from '../../models/base/{{#kebabCase}}{{import}}{{/kebabCase}}/index'; +import type { {{import}} } from '../../models/base/{{#kebabCase}}{{import}}{{/kebabCase}}/index'; {{#keepRevivers}} import { revive{{import}} } from '../../models/base/{{#kebabCase}}{{import}}{{/kebabCase}}/{{#kebabCase}}{{import}}{{/kebabCase}}.reviver'; {{/keepRevivers}} diff --git a/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch/model/model.mustache b/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch/model/model.mustache index 36f6f43411..1ad315abe6 100644 --- a/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch/model/model.mustache +++ b/packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch/model/model.mustache @@ -1,3 +1,4 @@ +{{#noMultipleEmptyLines}} {{#noUnusedImport}} /** * Model: {{classname}} @@ -15,7 +16,7 @@ import {utils} from '@ama-sdk/core'; {{/models}} {{#imports}} -import { {{import}} } from '../{{#kebabCase}}{{import}}{{/kebabCase}}'; +import type { {{import}} } from '../{{#kebabCase}}{{import}}{{/kebabCase}}'; {{/imports}} {{#models}} @@ -69,6 +70,10 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{/x-map-name}} {{/vendorExtensions}} {{/vars}} +{{#parent}}{{#vendorExtensions}}{{#x-discriminator-field}}{{#x-override-discriminator-type-with-value}} + /** @see {{parent}}.{{x-discriminator-field}} */ + {{x-discriminator-field}}: '{{x-discriminator-value}}'; +{{/x-override-discriminator-type-with-value}}{{/x-discriminator-field}}{{/vendorExtensions}}{{/parent}} } {{/oneOf}} {{#oneOf}} @@ -84,7 +89,11 @@ export type {{classname}} = {{#oneOf}}{{.}}{{^-last}} | {{/-last}}{{/oneOf}}; export const {{#upperSnakeCase}}list{{#removeBrackets}}{{{datatypeWithEnum}}}{{/removeBrackets}}{{/upperSnakeCase}} = [{{#trimComma}}{{#vendorExtensions}}{{#x-sanitized-allowable-values}}'{{.}}'{{^-last}}, {{/-last}}{{/x-sanitized-allowable-values}}{{/vendorExtensions}}{{/trimComma}}] as const; /** List of available values for {{#removeBrackets}}{{{datatypeWithEnum}}}{{/removeBrackets}} */ +{{#vendorExtensions}}{{#x-use-dynamic-enum-type}} +export type {{#removeBrackets}}{{{datatypeWithEnum}}}{{/removeBrackets}} = typeof {{#upperSnakeCase}}list{{#removeBrackets}}{{{datatypeWithEnum}}}{{/removeBrackets}}{{/upperSnakeCase}}[number]; +{{/x-use-dynamic-enum-type}}{{^x-use-dynamic-enum-type}} export type {{#removeBrackets}}{{{datatypeWithEnum}}}{{/removeBrackets}} = {{#trimPipe}}{{#allowableValues}}{{#values}}'{{.}}' | {{/values}}{{/allowableValues}}{{/trimPipe}}; +{{/x-use-dynamic-enum-type}}{{/vendorExtensions}} {{/isEnum}} {{/allVars}} {{/hasEnums}} @@ -97,12 +106,34 @@ export const {{baseName}}Pattern = {{#parseRegexp}}{{{pattern}}}{{/parseRegexp}} {{/vars}} {{/isEnum}} {{#isEnum}} -/** Array of {{classname}} items */ -export const {{#upperSnakeCase}}list{{classname}}{{/upperSnakeCase}} = [{{#trimComma}}{{#allowableValues}}{{#values}}'{{.}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}{{/trimComma}}] as const; +/** @inheritDoc */ +export const {{#upperSnakeCase}}list{{classname}}{{/upperSnakeCase}} = [{{#trimComma}}{{#allowableValues}}{{#values}}'{{.}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}{{/trimComma}}] as const satisfies {{classname}}[]; /** List of available values for {{classname}} */ -export type {{classname}} = {{#trimPipe}}{{#allowableValues}}{{#values}}'{{.}}' | {{/values}}{{/allowableValues}}{{/trimPipe}}; +{{#vendorExtensions}}{{#x-use-dynamic-enum-type}} +export type {{classname}} = typeof {{#upperSnakeCase}}list{{classname}}{{/upperSnakeCase}}[number]; +{{/x-use-dynamic-enum-type}}{{^x-use-dynamic-enum-type}} +export type {{classname}} = {{#trimPipe}}{{#allowableValues}}{{#values}}'{{.}}'{{^-last}} | {{/-last}}{{/values}}{{/allowableValues}}{{/trimPipe}}; +{{/x-use-dynamic-enum-type}}{{/vendorExtensions}} {{/isEnum}} + +{{#vendorExtensions}}{{#discriminator}}{{#x-children-model-list-type-suffix}} +/** Mapping between discriminator values and their corresponding types for {{classname}} */ +export type {{classname}}{{x-children-model-list-type-suffix}} = {{#x-discriminator-mapping-values}}{{.}}{{^-last}} | {{/-last}}{{/x-discriminator-mapping-values}}; +{{/x-children-model-list-type-suffix}}{{/discriminator}}{{/vendorExtensions}} + +{{#parent}}{{#vendorExtensions}}{{#x-discriminator-field}} +/** + * Type guard for {{classname}} implementing the discriminator logic + * @param data The data to check + * @returns True if the data is of type {{classname}}, false otherwise + */ +export const is{{classname}} = (data: {{parent}}): data is {{classname}} => { + return data['{{x-discriminator-field}}'] === '{{x-discriminator-value}}'; +}; +{{/x-discriminator-field}}{{/vendorExtensions}}{{/parent}} + {{/model}} {{/models}} {{/noUnusedImport}} +{{/noMultipleEmptyLines}} diff --git a/packages/@ama-sdk/schematics/schematics/typescript/shell/templates/base/openapitools.json.template b/packages/@ama-sdk/schematics/schematics/typescript/shell/templates/base/openapitools.json.template index 5ea87905b0..3138aeef9b 100644 --- a/packages/@ama-sdk/schematics/schematics/typescript/shell/templates/base/openapitools.json.template +++ b/packages/@ama-sdk/schematics/schematics/typescript/shell/templates/base/openapitools.json.template @@ -6,6 +6,7 @@ "storageDir": ".openapi-generator", "generators": { "<%=projectName%>-<%=projectPackageName%>": { + "useDynamicEnumType": true, "generatorName": "typescriptFetch", "output": ".", "inputSpec": "" diff --git a/packages/@ama-styling/figma-extractor/package.json b/packages/@ama-styling/figma-extractor/package.json index cb71bb52c0..d20688e73f 100644 --- a/packages/@ama-styling/figma-extractor/package.json +++ b/packages/@ama-styling/figma-extractor/package.json @@ -22,7 +22,7 @@ "bin": "./cli/figma-extract.js", "generatorDependencies": { "@ama-styling/style-dictionary": "workspace:~", - "style-dictionary": "~5.3.0" + "style-dictionary": "~5.4.0" }, "peerDependencies": { "@ama-sdk/client-fetch": "workspace:~", diff --git a/packages/@o3r-training/showcase-sdk/open-api.yaml b/packages/@o3r-training/showcase-sdk/open-api.yaml index c6e3d4bb21..cc652bfe8d 100644 --- a/packages/@o3r-training/showcase-sdk/open-api.yaml +++ b/packages/@o3r-training/showcase-sdk/open-api.yaml @@ -41,6 +41,20 @@ tags: - name: user description: Operations about user paths: + /animal: + get: + tags: + - "dummy" + summary: Animal get + description: Get an animal + operationId: animalGet + responses: + 200: + description: "Successful operation" + content: + application/json: + schema: + $ref: '#/components/schemas/Animal' /pet: post: servers: @@ -630,6 +644,38 @@ externalDocs: url: 'http://swagger.io' components: schemas: + Animal: + type: object + required: + - petType + properties: + petType: + type: string + enum: [cat, dog] # <- optional enum, can be forgotten in the declaration without changing generated code + discriminator: + propertyName: petType + mapping: # <- mandatory + dog: "#/components/schemas/Dog" + cat: "#/components/schemas/Cat" + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + bark: + type: boolean + breed: + type: string + enum: [Dingo, Husky, Retriever, Shepherd] + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + hunts: + type: boolean + age: + type: integer Order: x-swagger-router-model: io.swagger.petstore.model.Order properties: diff --git a/packages/@o3r-training/showcase-sdk/openapitools.json b/packages/@o3r-training/showcase-sdk/openapitools.json index 25f3be1c08..524b1cbab0 100644 --- a/packages/@o3r-training/showcase-sdk/openapitools.json +++ b/packages/@o3r-training/showcase-sdk/openapitools.json @@ -10,7 +10,10 @@ "output": ".", "inputSpec": "./open-api.yaml", "globalProperty": { + "overrideDiscriminatorTypeWithValue": true, + "useDynamicEnumType": true, "stringifyDate": true, + "childrenModelListTypeSuffix": "Children", "requestBodyTransform": "content{{bodyRequest}}" } } diff --git a/packages/@o3r-training/showcase-sdk/package.json b/packages/@o3r-training/showcase-sdk/package.json index e574756c39..5e62e2e727 100644 --- a/packages/@o3r-training/showcase-sdk/package.json +++ b/packages/@o3r-training/showcase-sdk/package.json @@ -50,7 +50,7 @@ "build:esm2015": "swc src -d dist/esm2015 -C module.type=es6 -q", "build:esm2020": "tsc -b tsconfigs/esm2020", "resolve": "node -e 'process.stdout.write(require.resolve(process.argv[1]));'", - "generate": "schematics ../../@ama-sdk/schematics:typescript-core --generator-key training-showcase-sdk", + "generate": "schematics ../../@ama-sdk/schematics/dist:typescript-core --generator-key training-showcase-sdk", "spec:regen": "yarn run generate --no-dry-run && amasdk-clear-index", "files:pack": "yarn amasdk-files-pack", "test": "jest --passWithNoTests", diff --git a/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.fixture.ts b/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.fixture.ts new file mode 100644 index 0000000000..80f65a3259 --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.fixture.ts @@ -0,0 +1,12 @@ +import { DummyApi } from './dummy-api'; + +export class DummyApiFixture implements Partial> { + + /** @inheritDoc */ + public readonly apiName = 'DummyApi'; + + /** + * Fixture associated to function animalGet + */ + public animalGet: jasmine.Spy = jasmine.createSpy('animalGet'); +} diff --git a/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.jasmine.fixture.ts b/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.jasmine.fixture.ts new file mode 100644 index 0000000000..80f65a3259 --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.jasmine.fixture.ts @@ -0,0 +1,12 @@ +import { DummyApi } from './dummy-api'; + +export class DummyApiFixture implements Partial> { + + /** @inheritDoc */ + public readonly apiName = 'DummyApi'; + + /** + * Fixture associated to function animalGet + */ + public animalGet: jasmine.Spy = jasmine.createSpy('animalGet'); +} diff --git a/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.jest.fixture.ts b/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.jest.fixture.ts new file mode 100644 index 0000000000..9d52be744e --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.jest.fixture.ts @@ -0,0 +1,15 @@ +import { Animal } from '../../models/base/animal/index'; + +import { DummyApi, DummyApiAnimalGetRequestData } from './dummy-api'; + +export class DummyApiFixture implements Partial> { + + /** @inheritDoc */ + public readonly apiName = 'DummyApi'; + + /** + * Fixture associated to function animalGet + */ + public animalGet: jest.Mock, [DummyApiAnimalGetRequestData]> = jest.fn(); +} + diff --git a/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.ts b/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.ts new file mode 100644 index 0000000000..37792bd5d8 --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/api/dummy/dummy-api.ts @@ -0,0 +1,77 @@ +import type { Animal } from '../../models/base/animal/index'; +import { Api, ApiClient, ApiTypes, computePiiParameterTokens, ParamSerializationOptions, RequestBody, RequestMetadata, Server, selectServerBasePath, } from '@ama-sdk/core'; +import { SDK_SERVERS } from '../../constants/servers'; +/** Parameters object to DummyApi's animalGet function */ +export interface DummyApiAnimalGetRequestData { +} +export class DummyApi implements Api { + + /** API name */ + public static readonly apiName = 'DummyApi'; + + /** @inheritDoc */ + public readonly apiName = DummyApi.apiName; + + /** Tokens of the parameters containing PII */ + public readonly piiParamTokens: { [key: string]: string } = computePiiParameterTokens([]); + + /** @inheritDoc */ + public client: ApiClient; + + /** + * Initialize your interface + * + * @param apiClient Client used to process call to the API + */ + constructor(apiClient: ApiClient) { + this.client = apiClient; + } + + /** + * Animal get + * Get an animal + * @param data Data to provide to the API call + * @param metadata Metadata to pass to the API call + */ + public async animalGet(data: DummyApiAnimalGetRequestData, metadata?: RequestMetadata): Promise { + const metadataHeaderAccept = metadata?.headerAccept || 'application/json'; + const headers: { [key: string]: string | undefined } = { + 'Content-Type': metadata?.headerContentType || 'application/json', + ...(metadataHeaderAccept ? {'Accept': metadataHeaderAccept} : {}) + }; + + const operationServers = [ +] as const satisfies Server[]; + + const serverBasePath = selectServerBasePath(this.client.options, operationServers.length > 0 ? operationServers : SDK_SERVERS, this.client.options.logger); + + let body: RequestBody = ''; + + let queryParams = {}; + const paramSerializationOptions: ParamSerializationOptions = { + enableParameterSerialization: this.client.options.enableParameterSerialization + }; + const basePath = `${serverBasePath}/animal`; + const tokenizedUrl = `${serverBasePath}/animal`; + const tokenizedOptions = this.client.tokenizeRequestOptions(tokenizedUrl, queryParams, this.piiParamTokens, data); + + const requestOptions = { + headers, + method: 'GET', + basePath, + queryParams, + paramSerializationOptions, + body: body || undefined, + metadata, + tokenizedOptions, + api: this + }; + + const options = await this.client.getRequestOptions(requestOptions); + const url = this.client.options.enableParameterSerialization ? this.client.prepareUrlWithQueryParams(options.basePath, options.queryParams) : this.client.prepareUrl(options.basePath, options.queryParams); + + const ret = this.client.processCall(url, options, ApiTypes.DEFAULT, DummyApi.apiName, undefined, 'animalGet'); + return ret; + } + +} diff --git a/packages/@o3r-training/showcase-sdk/src/api/dummy/index.ts b/packages/@o3r-training/showcase-sdk/src/api/dummy/index.ts new file mode 100644 index 0000000000..ce1e832175 --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/api/dummy/index.ts @@ -0,0 +1 @@ +export * from './dummy-api'; diff --git a/packages/@o3r-training/showcase-sdk/src/api/fixtures.jasmine.ts b/packages/@o3r-training/showcase-sdk/src/api/fixtures.jasmine.ts index 6e8f20f5e3..1348a0ae47 100644 --- a/packages/@o3r-training/showcase-sdk/src/api/fixtures.jasmine.ts +++ b/packages/@o3r-training/showcase-sdk/src/api/fixtures.jasmine.ts @@ -1,3 +1,4 @@ +export { DummyApiFixture } from './dummy/dummy-api.jasmine.fixture'; export { PetApiFixture } from './pet/pet-api.jasmine.fixture'; export { StoreApiFixture } from './store/store-api.jasmine.fixture'; export { UserApiFixture } from './user/user-api.jasmine.fixture'; diff --git a/packages/@o3r-training/showcase-sdk/src/api/fixtures.jest.ts b/packages/@o3r-training/showcase-sdk/src/api/fixtures.jest.ts index ee20fb6ee7..9f68b8594f 100644 --- a/packages/@o3r-training/showcase-sdk/src/api/fixtures.jest.ts +++ b/packages/@o3r-training/showcase-sdk/src/api/fixtures.jest.ts @@ -1,3 +1,4 @@ +export { DummyApiFixture } from './dummy/dummy-api.jest.fixture'; export { PetApiFixture } from './pet/pet-api.jest.fixture'; export { StoreApiFixture } from './store/store-api.jest.fixture'; export { UserApiFixture } from './user/user-api.jest.fixture'; diff --git a/packages/@o3r-training/showcase-sdk/src/api/fixtures.ts b/packages/@o3r-training/showcase-sdk/src/api/fixtures.ts index c53d75bb2f..c7a79e93c2 100644 --- a/packages/@o3r-training/showcase-sdk/src/api/fixtures.ts +++ b/packages/@o3r-training/showcase-sdk/src/api/fixtures.ts @@ -1,5 +1,6 @@ /* @deprecated use fixtures.jasmine file instead */ +export { DummyApiFixture } from './dummy/dummy-api.fixture'; export { PetApiFixture } from './pet/pet-api.fixture'; export { StoreApiFixture } from './store/store-api.fixture'; export { UserApiFixture } from './user/user-api.fixture'; diff --git a/packages/@o3r-training/showcase-sdk/src/api/index.ts b/packages/@o3r-training/showcase-sdk/src/api/index.ts index 506deddeda..2a92cca5e2 100644 --- a/packages/@o3r-training/showcase-sdk/src/api/index.ts +++ b/packages/@o3r-training/showcase-sdk/src/api/index.ts @@ -1,3 +1,5 @@ +export type { DummyApiAnimalGetRequestData } from './dummy/index'; +export { DummyApi } from './dummy/index'; export type { PetApiAddPetRequestData, PetApiDeletePetRequestData, PetApiFindPetsByStatusRequestData, PetApiFindPetsByTagsRequestData, PetApiGetPetByIdRequestData, PetApiUpdatePetRequestData, PetApiUpdatePetWithFormRequestData, PetApiUploadFileRequestData } from './pet/index'; export { PetApi } from './pet/index'; export type { StoreApiDeleteOrderRequestData, StoreApiGetInventoryRequestData, StoreApiGetOrderByIdRequestData, StoreApiPlaceOrderRequestData } from './store/index'; diff --git a/packages/@o3r-training/showcase-sdk/src/api/pet/pet-api.ts b/packages/@o3r-training/showcase-sdk/src/api/pet/pet-api.ts index 961109ae51..1eb484b9dc 100644 --- a/packages/@o3r-training/showcase-sdk/src/api/pet/pet-api.ts +++ b/packages/@o3r-training/showcase-sdk/src/api/pet/pet-api.ts @@ -1,5 +1,5 @@ -import { ApiResponse } from '../../models/base/api-response/index'; -import { Pet } from '../../models/base/pet/index'; +import type { ApiResponse } from '../../models/base/api-response/index'; +import type { Pet } from '../../models/base/pet/index'; import { Api, ApiClient, ApiTypes, computePiiParameterTokens, isJsonMimeType, ParamSerializationOptions, RequestBody, RequestMetadata, Server, selectServerBasePath, } from '@ama-sdk/core'; import { SDK_SERVERS } from '../../constants/servers'; /** Enum status used in the PetApi's findPetsByStatus function parameter */ diff --git a/packages/@o3r-training/showcase-sdk/src/api/store/store-api.ts b/packages/@o3r-training/showcase-sdk/src/api/store/store-api.ts index bf4b6fe432..d964571c2e 100644 --- a/packages/@o3r-training/showcase-sdk/src/api/store/store-api.ts +++ b/packages/@o3r-training/showcase-sdk/src/api/store/store-api.ts @@ -1,4 +1,4 @@ -import { Order } from '../../models/base/order/index'; +import type { Order } from '../../models/base/order/index'; import { Api, ApiClient, ApiTypes, computePiiParameterTokens, isJsonMimeType, ParamSerializationOptions, RequestBody, RequestMetadata, Server, selectServerBasePath, } from '@ama-sdk/core'; import { SDK_SERVERS } from '../../constants/servers'; /** Parameters object to StoreApi's deleteOrder function */ diff --git a/packages/@o3r-training/showcase-sdk/src/api/user/user-api.ts b/packages/@o3r-training/showcase-sdk/src/api/user/user-api.ts index b1a402cb6f..64c20324a6 100644 --- a/packages/@o3r-training/showcase-sdk/src/api/user/user-api.ts +++ b/packages/@o3r-training/showcase-sdk/src/api/user/user-api.ts @@ -1,4 +1,4 @@ -import { User } from '../../models/base/user/index'; +import type { User } from '../../models/base/user/index'; import { Api, ApiClient, ApiTypes, computePiiParameterTokens, isJsonMimeType, ParamSerializationOptions, RequestBody, RequestMetadata, Server, selectServerBasePath, } from '@ama-sdk/core'; import { SDK_SERVERS } from '../../constants/servers'; /** Parameters object to UserApi's createUser function */ diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/address/address.ts b/packages/@o3r-training/showcase-sdk/src/models/base/address/address.ts index 842b925aa0..d614b2c0fc 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/address/address.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/address/address.ts @@ -4,14 +4,10 @@ * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ - - - export interface Address { street?: string; city?: string; state?: string; zip?: string; -} - +} diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/animal/animal.ts b/packages/@o3r-training/showcase-sdk/src/models/base/animal/animal.ts new file mode 100644 index 0000000000..e1c5871b13 --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/models/base/animal/animal.ts @@ -0,0 +1,23 @@ +/** + * Model: Animal + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ +import type { Cat } from '../cat'; +import type { Dog } from '../dog'; + +export interface Animal { + /** @see PetTypeEnum */ + petType: PetTypeEnum; + +} + +/** Array of PetTypeEnum items */ +export const LIST_PET_TYPE_ENUM = ['cat', 'dog'] as const; + +/** List of available values for PetTypeEnum */ + +export type PetTypeEnum = typeof LIST_PET_TYPE_ENUM[number]; +/** Mapping between discriminator values and their corresponding types for Animal */ +export type AnimalChildren = Cat | Dog; diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/animal/index.ts b/packages/@o3r-training/showcase-sdk/src/models/base/animal/index.ts new file mode 100644 index 0000000000..0da137f3d5 --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/models/base/animal/index.ts @@ -0,0 +1,2 @@ +export type { Animal } from './animal'; + diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/api-response/api-response.ts b/packages/@o3r-training/showcase-sdk/src/models/base/api-response/api-response.ts index 88de9cd74f..5893915844 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/api-response/api-response.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/api-response/api-response.ts @@ -4,13 +4,9 @@ * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ - - - export interface ApiResponse { code?: number; type?: string; message?: string; -} - +} diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/cat/cat.ts b/packages/@o3r-training/showcase-sdk/src/models/base/cat/cat.ts new file mode 100644 index 0000000000..f9b08350e0 --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/models/base/cat/cat.ts @@ -0,0 +1,31 @@ +/** + * Model: Cat + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ +import type { Animal } from '../animal'; + +export interface Cat extends Animal { + hunts?: boolean; + age?: number; + + /** @see Animal.petType */ + petType: 'cat'; + +} + +/** Array of PetTypeEnum items */ +export const LIST_PET_TYPE_ENUM = ['cat', 'dog'] as const; + +/** List of available values for PetTypeEnum */ + +export type PetTypeEnum = typeof LIST_PET_TYPE_ENUM[number]; +/** + * Type guard for Cat implementing the discriminator logic + * @param data The data to check + * @returns True if the data is of type Cat, false otherwise + */ +export const isCat = (data: Animal): data is Cat => { + return data['petType'] === 'cat'; +}; diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/cat/index.ts b/packages/@o3r-training/showcase-sdk/src/models/base/cat/index.ts new file mode 100644 index 0000000000..adf67054ae --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/models/base/cat/index.ts @@ -0,0 +1,2 @@ +export type { Cat } from './cat'; + diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/category/category.ts b/packages/@o3r-training/showcase-sdk/src/models/base/category/category.ts index 82fdfd1834..63818d8403 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/category/category.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/category/category.ts @@ -4,12 +4,8 @@ * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ - - - export interface Category { id?: number; name?: string; -} - +} diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/customer/customer.ts b/packages/@o3r-training/showcase-sdk/src/models/base/customer/customer.ts index 713b471f06..c8d9b53efd 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/customer/customer.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/customer/customer.ts @@ -4,15 +4,12 @@ * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ - - -import { Address } from '../address'; +import type { Address } from '../address'; export interface Customer { id?: number; username?: string; /** List of Addresss */ address?: Address[]; -} - +} diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/dog/dog.ts b/packages/@o3r-training/showcase-sdk/src/models/base/dog/dog.ts new file mode 100644 index 0000000000..354407af13 --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/models/base/dog/dog.ts @@ -0,0 +1,39 @@ +/** + * Model: Dog + * + * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. + * + */ +import type { Animal } from '../animal'; + +export interface Dog extends Animal { + bark?: boolean; + /** @see BreedEnum */ + breed?: BreedEnum; + + /** @see Animal.petType */ + petType: 'dog'; + +} + +/** Array of PetTypeEnum items */ +export const LIST_PET_TYPE_ENUM = ['cat', 'dog'] as const; + +/** List of available values for PetTypeEnum */ + +export type PetTypeEnum = typeof LIST_PET_TYPE_ENUM[number]; + +/** Array of BreedEnum items */ +export const LIST_BREED_ENUM = ['Dingo', 'Husky', 'Retriever', 'Shepherd'] as const; + +/** List of available values for BreedEnum */ + +export type BreedEnum = typeof LIST_BREED_ENUM[number]; +/** + * Type guard for Dog implementing the discriminator logic + * @param data The data to check + * @returns True if the data is of type Dog, false otherwise + */ +export const isDog = (data: Animal): data is Dog => { + return data['petType'] === 'dog'; +}; diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/dog/index.ts b/packages/@o3r-training/showcase-sdk/src/models/base/dog/index.ts new file mode 100644 index 0000000000..6cfc0450a1 --- /dev/null +++ b/packages/@o3r-training/showcase-sdk/src/models/base/dog/index.ts @@ -0,0 +1,2 @@ +export type { Dog } from './dog'; + diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/enums.ts b/packages/@o3r-training/showcase-sdk/src/models/base/enums.ts index 56a496359c..b4a5166046 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/enums.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/enums.ts @@ -1,6 +1,10 @@ +export { LIST_PET_TYPE_ENUM as ANIMAL_LIST_PET_TYPE_ENUM } from './animal/animal'; +export { LIST_BREED_ENUM as DOG_LIST_BREED_ENUM } from './dog/dog'; export { LIST_STATUS_ENUM as ORDER_LIST_STATUS_ENUM } from './order/order'; export { LIST_STATUS_ENUM as PET_LIST_STATUS_ENUM } from './pet/pet'; +export type { PetTypeEnum as AnimalPetTypeEnum } from './animal/animal'; +export type { BreedEnum as DogBreedEnum } from './dog/dog'; export type { StatusEnum as OrderStatusEnum } from './order/order'; export type { StatusEnum as PetStatusEnum } from './pet/pet'; diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/index.ts b/packages/@o3r-training/showcase-sdk/src/models/base/index.ts index de1b043457..362e0dd02d 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/index.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/index.ts @@ -1,7 +1,10 @@ export * from './address'; +export * from './animal'; export * from './api-response'; +export * from './cat'; export * from './category'; export * from './customer'; +export * from './dog'; export * from './order'; export * from './pet'; export * from './tag'; diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/order/order.ts b/packages/@o3r-training/showcase-sdk/src/models/base/order/order.ts index 0148bd0eba..6494f4c3f1 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/order/order.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/order/order.ts @@ -4,9 +4,6 @@ * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ - - - export interface Order { id?: number; petId?: number; @@ -15,11 +12,12 @@ export interface Order { /** Order Status */ status?: StatusEnum; complete?: boolean; + } /** Array of StatusEnum items */ export const LIST_STATUS_ENUM = ['placed', 'approved', 'delivered'] as const; /** List of available values for StatusEnum */ -export type StatusEnum = 'placed' | 'approved' | 'delivered'; +export type StatusEnum = typeof LIST_STATUS_ENUM[number]; diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/pet/pet.ts b/packages/@o3r-training/showcase-sdk/src/models/base/pet/pet.ts index d355d5c6a3..7c10aee5e1 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/pet/pet.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/pet/pet.ts @@ -4,10 +4,8 @@ * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ - - -import { Category } from '../category'; -import { Tag } from '../tag'; +import type { Category } from '../category'; +import type { Tag } from '../tag'; export interface Pet { id?: number; @@ -20,11 +18,12 @@ export interface Pet { tags?: Tag[]; /** pet status in the store */ status?: StatusEnum; + } /** Array of StatusEnum items */ export const LIST_STATUS_ENUM = ['available', 'pending', 'sold'] as const; /** List of available values for StatusEnum */ -export type StatusEnum = 'available' | 'pending' | 'sold'; +export type StatusEnum = typeof LIST_STATUS_ENUM[number]; diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/tag/tag.ts b/packages/@o3r-training/showcase-sdk/src/models/base/tag/tag.ts index d7a78a4318..4d417a5f56 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/tag/tag.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/tag/tag.ts @@ -4,12 +4,8 @@ * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ - - - export interface Tag { id?: number; name?: string; -} - +} diff --git a/packages/@o3r-training/showcase-sdk/src/models/base/user/user.ts b/packages/@o3r-training/showcase-sdk/src/models/base/user/user.ts index c9dc52d1ba..2290fb0ae5 100644 --- a/packages/@o3r-training/showcase-sdk/src/models/base/user/user.ts +++ b/packages/@o3r-training/showcase-sdk/src/models/base/user/user.ts @@ -4,9 +4,6 @@ * THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. * */ - - - export interface User { id?: number; username?: string; @@ -17,6 +14,5 @@ export interface User { phone?: string; /** User Status */ userStatus?: number; -} - +} diff --git a/packages/@o3r-training/showcase-sdk/src/spec/api-mock.ts b/packages/@o3r-training/showcase-sdk/src/spec/api-mock.ts index 5bbd6e66d1..52f971e0ba 100644 --- a/packages/@o3r-training/showcase-sdk/src/spec/api-mock.ts +++ b/packages/@o3r-training/showcase-sdk/src/spec/api-mock.ts @@ -8,6 +8,7 @@ import * as api from '../api'; export const MOCK_SERVER_BASE_PATH = 'http://localhost:10010/v2'; export interface Api { + dummyApi: api.DummyApi; petApi: api.PetApi; storeApi: api.StoreApi; userApi: api.UserApi; @@ -25,6 +26,7 @@ export interface Api { */ export function getMockedApi(apiClient: ApiClient): Api { return { + dummyApi: new api.DummyApi(apiClient), petApi: new api.PetApi(apiClient), storeApi: new api.StoreApi(apiClient), userApi: new api.UserApi(apiClient) diff --git a/packages/@o3r-training/showcase-sdk/src/spec/operation-adapter.ts b/packages/@o3r-training/showcase-sdk/src/spec/operation-adapter.ts index 3eeb5f51c0..e215c9d9c1 100644 --- a/packages/@o3r-training/showcase-sdk/src/spec/operation-adapter.ts +++ b/packages/@o3r-training/showcase-sdk/src/spec/operation-adapter.ts @@ -2,6 +2,8 @@ import {PathObject} from '@ama-sdk/core'; /* eslint-disable max-len */ export const OPERATION_ADAPTER: PathObject[] = [{ + path: "/animal",urlPattern: "/animal(?:/(?=$))?$",regexp: new RegExp('^/animal(?:/(?=$))?$'),operations: [{"method":"get","operationId":"animalGet"}] + },{ path: "/pet",urlPattern: "/pet(?:/(?=$))?$",regexp: new RegExp('^/pet(?:/(?=$))?$'),operations: [{"method":"post","operationId":"addPet"},{"method":"put","operationId":"updatePet"}] },{ path: "/pet/findByStatus",urlPattern: "/pet/findByStatus(?:/(?=$))?$",regexp: new RegExp('^/pet/findByStatus(?:/(?=$))?$'),operations: [{"method":"get","operationId":"findPetsByStatus"}] diff --git a/packages/@o3r-training/training-sdk/package.json b/packages/@o3r-training/training-sdk/package.json index ed617452ed..6c03cab0d5 100644 --- a/packages/@o3r-training/training-sdk/package.json +++ b/packages/@o3r-training/training-sdk/package.json @@ -43,7 +43,7 @@ "build:esm2020": "tsc -b tsconfigs/esm2020", "set:version": "npm version", "resolve": "node -e 'process.stdout.write(require.resolve(process.argv[1]));'", - "generate": "schematics ../../@ama-sdk/schematics:typescript-core --no-dry-run", + "generate": "schematics ../../@ama-sdk/schematics/dist:typescript-core --no-dry-run", "spec:regen": "yarn run generate --generator-key training-project-training-sdk && amasdk-clear-index", "spec:upgrade": "yarn run spec:regen", "files:pack": "amasdk-files-pack", diff --git a/packages/@o3r-training/training-sdk/src/api/dummy/dummy-api.ts b/packages/@o3r-training/training-sdk/src/api/dummy/dummy-api.ts index a7efbc1443..c1c2253c29 100644 --- a/packages/@o3r-training/training-sdk/src/api/dummy/dummy-api.ts +++ b/packages/@o3r-training/training-sdk/src/api/dummy/dummy-api.ts @@ -1,4 +1,4 @@ -import { Flight } from '../../models/base/flight/index'; +import type { Flight } from '../../models/base/flight/index'; import { reviveFlight } from '../../models/base/flight/flight.reviver'; import { Api, ApiClient, ApiTypes, computePiiParameterTokens, ParamSerializationOptions, RequestBody, RequestMetadata, Server, selectServerBasePath, } from '@ama-sdk/core'; import { SDK_SERVERS } from '../../constants/servers'; diff --git a/packages/@o3r-training/training-sdk/src/models/base/flight/flight.ts b/packages/@o3r-training/training-sdk/src/models/base/flight/flight.ts index fed27f016d..fbe1826a42 100644 --- a/packages/@o3r-training/training-sdk/src/models/base/flight/flight.ts +++ b/packages/@o3r-training/training-sdk/src/models/base/flight/flight.ts @@ -6,8 +6,6 @@ */ import {utils} from '@ama-sdk/core'; - - export interface Flight { originLocationCode: string; destinationLocationCode: string; @@ -15,6 +13,5 @@ export interface Flight { departureDateTime: utils.DateTime; /** @see Date */ paymentExpirationDate: Date; -} - +} diff --git a/packages/@o3r/core/package.json b/packages/@o3r/core/package.json index 81cf917e3e..12e7c46d6c 100644 --- a/packages/@o3r/core/package.json +++ b/packages/@o3r/core/package.json @@ -157,11 +157,11 @@ }, "generatorDependencies": { "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0", - "@ngrx/effects": "~21.0.0", - "@ngrx/entity": "~21.0.0", - "@ngrx/router-store": "~21.0.0", - "@ngrx/store": "~21.0.0", - "@ngrx/store-devtools": "~21.0.0", + "@ngrx/effects": "~21.1.0", + "@ngrx/entity": "~21.1.0", + "@ngrx/router-store": "~21.1.0", + "@ngrx/store": "~21.1.0", + "@ngrx/store-devtools": "~21.1.0", "@nx/eslint-plugin": "~22.6.0", "@o3r/store-sync": "workspace:~", "@stylistic/eslint-plugin": "~5.10.0",