Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/samples-dotnet9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
matrix:
sample:
- samples/client/petstore/csharp/generichost/latest/ComposedEnum
- samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf
- samples/client/petstore/csharp/generichost/latest/Tags
- samples/client/petstore/csharp/generichost/latest/HelloWorld
- samples/client/petstore/csharp/generichost/latest/OneOfList
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ build_script:

test_script:
- dotnet test samples\client\petstore\csharp\generichost\latest\ComposedEnum\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\latest\InlineEnumAnyOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\latest\Tags\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\latest\HelloWorld\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
- dotnet test samples\client\petstore\csharp\generichost\latest\OneOfList\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
Expand Down
12 changes: 12 additions & 0 deletions bin/configs/csharp-generichost-latest-inlineEnumAnyOf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/inline-enum-any-of.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
modelPropertySorting: alphabetical
operationParameterSorting: alphabetical
validateSpec: false
inlineSchemaOptions:
RESOLVE_INLINE_ENUMS: true
Original file line number Diff line number Diff line change
Expand Up @@ -626,18 +626,18 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
List<CodegenProperty> allOf = composedSchemas.getAllOf();
if (allOf != null) {
for (CodegenProperty property : allOf) {
patchProperty(enumRefs, model, property);
property.name = patchPropertyName(model, property, camelize(property.baseType), composedPropertyNames);
patchPropertyVendorExtensions(property);
}
}

List<CodegenProperty> anyOf = composedSchemas.getAnyOf();
if (anyOf != null) {
removePropertiesDeclaredInComposedTypes(objs, model, anyOf);
for (CodegenProperty property : anyOf) {
patchProperty(enumRefs, model, property);
property.name = patchPropertyName(model, property, camelize(property.baseType), composedPropertyNames);
property.isNullable = true;
patchPropertyVendorExtensions(property);
property.vendorExtensions.put("x-base-name", model.name.substring(model.name.lastIndexOf('_') + 1));
}
}
Expand All @@ -646,18 +646,10 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
if (oneOf != null) {
removePropertiesDeclaredInComposedTypes(objs, model, oneOf);
for (CodegenProperty property : oneOf) {
patchProperty(enumRefs, model, property);
property.name = patchPropertyName(model, property, camelize(property.baseType), composedPropertyNames);
property.isNullable = true;
patchPropertyVendorExtensions(property);
property.vendorExtensions.put("x-base-name", model.name.substring(model.name.lastIndexOf('_') + 1));

if (!property.isEnum) {
CodegenModel composedOf = ModelUtils.getModelByName(property.name, processed);
if (composedOf != null) {
property.isEnum = composedOf.isEnum;
patchPropertyVendorExtensions(property);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
if (!suppressDefaultLog)
Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path);
Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path);
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,17 @@
{{#isNumeric}}
writer.WriteNumber("{{vendorExtensions.x-base-name}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value.Value);
{{/isNumeric}}
{{#isEnum}}
{
{{datatypeWithEnum}}JsonConverter {{#lambda.camelcase}}{{datatypeWithEnum}}{{/lambda.camelcase}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}.GetType()));
{{#lambda.camelcase}}{{datatypeWithEnum}}{{/lambda.camelcase}}JsonConverter.Write{{^isEnumRef}}Properties{{/isEnumRef}}(writer, {{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}, jsonSerializerOptions);
}
{{/isEnum}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{
{{datatypeWithEnum}}JsonConverter {{datatypeWithEnum}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}.GetType()));
{{datatypeWithEnum}}JsonConverter.Write{{^isEnumRef}}Properties{{/isEnumRef}}(writer, {{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}, jsonSerializerOptions);
{{datatypeWithEnum}}JsonConverter {{#lambda.camelcase}}{{datatypeWithEnum}}{{/lambda.camelcase}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}.GetType()));
{{#lambda.camelcase}}{{datatypeWithEnum}}{{/lambda.camelcase}}JsonConverter.Write{{^isEnumRef}}Properties{{/isEnumRef}}(writer, {{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}, jsonSerializerOptions);
}
{{/isPrimitiveType}}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
openapi: 3.0.0
info:
description: >-
This spec is mainly for testing Petstore server and contains fake endpoints,
models. Please do not use this for any other purpose. Special characters: "
\
version: 1.0.0
title: OpenAPI Petstore
license:
name: Apache-2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
- name: user
description: Operations about user
paths:
'/icons':
get:
description: Returns a forecast icon. Icon services in API are deprecated.
operationId: icons
responses:
default:
description: response
content:
application/json:
schema:
type: object
properties:
string:
$ref: '#/components/schemas/Foo'
parameters:
- name: size
in: query
description: Font size
schema:
anyOf:
- enum:
- small
- medium
- large
type: string
- maximum: 500
minimum: 10
type: integer
servers:
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
variables:
server:
enum:
- 'petstore'
- 'qa-petstore'
- 'dev-petstore'
default: 'petstore'
port:
enum:
- 80
- 8080
default: 80
- url: https://localhost:8080/{version}
description: The local server
variables:
version:
enum:
- 'v1'
- 'v2'
default: 'v2'
- url: https://127.0.0.1/no_variable
description: The local server without variables
components:
schemas:
Foo:
type: object
properties:
bar:
$ref: '#/components/schemas/Bar'
Bar:
type: string
default: bar
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ private void AfterHelloWorldPostDefaultImplementation(IHelloWorldPostApiResponse
bool suppressDefaultLog = false;
AfterHelloWorldPost(ref suppressDefaultLog, apiResponseLocalVar, helloWorldPostRequest);
if (!suppressDefaultLog)
Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); }
Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path);
}

/// <summary>
/// Processes the server response
Expand Down
Loading
Loading