diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api_test.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api_test.mustache index 32eb2b769f31..f69bf0bceef5 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api_test.mustache @@ -42,7 +42,12 @@ namespace {{packageName}}.Test.{{apiPackage}} {{#dataType}} var response = await _instance.{{operationId}}Async({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); var model = response.{{vendorExtensions.x-http-status}}(); + {{#isModel}} + Assert.IsType<{{packageName}}.{{modelPackage}}.{{{.}}}>(model); + {{/isModel}} + {{^isModel}} Assert.IsType<{{{.}}}>(model); + {{/isModel}} {{/dataType}} {{^dataType}} await _instance.{{operationId}}Async({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/model-name-collision.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/model-name-collision.yaml new file mode 100644 index 000000000000..d3c243a8a61c --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/csharp/model-name-collision.yaml @@ -0,0 +1,36 @@ +openapi: 3.0.0 +info: + title: Model Name Collision Test + description: >- + Tests that generated test code uses fully-qualified type names for model + return types to avoid collisions with standard library classes (e.g. a + model named "Attributes" would conflict with System.Attribute). + version: 1.0.0 + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +paths: + /resources: + get: + operationId: GetResources + tags: + - Resources + responses: + '200': + description: Returns a resource with attributes + content: + application/json: + schema: + $ref: '#/components/schemas/Attributes' +servers: + - url: 'http://localhost' +components: + schemas: + Attributes: + type: object + properties: + id: + type: integer + format: int32 + name: + type: string