diff --git a/bin/configs/dart-next-petstore-client.yaml b/bin/configs/dart-next-petstore-client.yaml new file mode 100644 index 000000000000..527b6d0da43b --- /dev/null +++ b/bin/configs/dart-next-petstore-client.yaml @@ -0,0 +1,19 @@ +generatorName: dart-next +outputDir: samples/openapi3/client/petstore/dart/next +inputSpec: modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/dart-next +additionalProperties: + hideGenerationTimestamp: "true" + pubName: petstore_api +nameMappings: + _type: $type + type_: type$ +parameterNameMappings: + _type: $type + type_: type$ +enumNameMappings: + s: LOWER_CASE_S + S: UPPER_CASE_S +operationIdNameMappings: + getArrayOfEnums: getFakeArrayofenums + fakeHealthGet: getFakeHealth \ No newline at end of file diff --git a/docs/generators/dart-next.md b/docs/generators/dart-next.md new file mode 100644 index 000000000000..dd0df76e5d6e --- /dev/null +++ b/docs/generators/dart-next.md @@ -0,0 +1,258 @@ +--- +title: Documentation for the dart-next Generator +--- + +## METADATA + +| Property | Value | Notes | +| -------- | ----- | ----- | +| generator name | dart-next | pass this to the generate command after -g | +| generator stability | EXPERIMENTAL | | +| generator type | CLIENT | | +| generator language | Java | | +| generator default templating engine | mustache | | +| helpTxt | Generates a dart-next client. | | + +## CONFIG OPTIONS +These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details. + +| Option | Description | Values | Default | +| ------ | ----------- | ------ | ------- | +|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| +|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true| +|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| +|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| +|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| +|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| +|pubAuthor|Author name in generated pubspec| |Author| +|pubAuthorEmail|Email address of the author in generated pubspec| |author@homepage| +|pubDescription|Description in generated pubspec| |OpenAPI API client| +|pubHomepage|Homepage in generated pubspec| |homepage| +|pubLibrary|Library name in generated code| |openapi.api| +|pubName|Name in generated pubspec| |openapi| +|pubPublishTo|Publish_to in generated pubspec| |null| +|pubRepository|Repository in generated pubspec| |null| +|pubVersion|Version in generated pubspec| |1.0.0| +|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| +|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| +|sourceFolder|source folder for generated code| |src| +|useEnumExtension|Allow the 'x-enum-values' extension for enums| |false| + +## IMPORT MAPPING + +| Type/Alias | Imports | +| ---------- | ------- | + + +## INSTANTIATION TYPES + +| Type/Alias | Instantiated By | +| ---------- | --------------- | + + +## LANGUAGE PRIMITIVES + + + +## RESERVED WORDS + + + +## FEATURE SET + + +### Client Modification Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|BasePath|✓|ToolingExtension +|Authorizations|✗|ToolingExtension +|UserAgent|✗|ToolingExtension +|MockServer|✗|ToolingExtension + +### Data Type Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Custom|✓|OAS2,OAS3 +|Int32|✓|OAS2,OAS3 +|Int64|✓|OAS2,OAS3 +|Float|✓|OAS2,OAS3 +|Double|✓|OAS2,OAS3 +|Decimal|✓|ToolingExtension +|String|✓|OAS2,OAS3 +|Byte|✓|OAS2,OAS3 +|Binary|✓|OAS2,OAS3 +|Boolean|✓|OAS2,OAS3 +|Date|✓|OAS2,OAS3 +|DateTime|✓|OAS2,OAS3 +|Password|✓|OAS2,OAS3 +|File|✓|OAS2 +|Uuid|✗| +|Array|✓|OAS2,OAS3 +|Null|✗|OAS3 +|AnyType|✓|OAS2,OAS3 +|Object|✓|OAS2,OAS3 +|Maps|✓|ToolingExtension +|CollectionFormat|✓|OAS2 +|CollectionFormatMulti|✓|OAS2 +|Enum|✓|OAS2,OAS3 +|ArrayOfEnum|✓|ToolingExtension +|ArrayOfModel|✓|ToolingExtension +|ArrayOfCollectionOfPrimitives|✓|ToolingExtension +|ArrayOfCollectionOfModel|✓|ToolingExtension +|ArrayOfCollectionOfEnum|✓|ToolingExtension +|MapOfEnum|✓|ToolingExtension +|MapOfModel|✓|ToolingExtension +|MapOfCollectionOfPrimitives|✓|ToolingExtension +|MapOfCollectionOfModel|✓|ToolingExtension +|MapOfCollectionOfEnum|✓|ToolingExtension + +### Documentation Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Readme|✓|ToolingExtension +|Model|✓|ToolingExtension +|Api|✓|ToolingExtension + +### Global Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Host|✓|OAS2,OAS3 +|BasePath|✓|OAS2,OAS3 +|Info|✓|OAS2,OAS3 +|Schemes|✗|OAS2,OAS3 +|PartialSchemes|✓|OAS2,OAS3 +|Consumes|✓|OAS2 +|Produces|✓|OAS2 +|ExternalDocumentation|✓|OAS2,OAS3 +|Examples|✓|OAS2,OAS3 +|XMLStructureDefinitions|✗|OAS2,OAS3 +|MultiServer|✗|OAS3 +|ParameterizedServer|✗|OAS3 +|ParameterStyling|✗|OAS3 +|Callbacks|✗|OAS3 +|LinkObjects|✗|OAS3 + +### Parameter Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Path|✓|OAS2,OAS3 +|Query|✓|OAS2,OAS3 +|Header|✓|OAS2,OAS3 +|Body|✓|OAS2 +|FormUnencoded|✓|OAS2 +|FormMultipart|✓|OAS2 +|Cookie|✓|OAS3 + +### Schema Support Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|Simple|✓|OAS2,OAS3 +|Composite|✓|OAS2,OAS3 +|Polymorphism|✓|OAS2,OAS3 +|Union|✓|OAS3 +|allOf|✓|OAS2,OAS3 +|anyOf|✓|OAS3 +|oneOf|✓|OAS3 +|not|✗|OAS3 + +### Security Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|BasicAuth|✓|OAS2,OAS3 +|ApiKey|✓|OAS2,OAS3 +|OpenIDConnect|✗|OAS3 +|BearerToken|✓|OAS3 +|OAuth2_Implicit|✓|OAS2,OAS3 +|OAuth2_Password|✗|OAS2,OAS3 +|OAuth2_ClientCredentials|✗|OAS2,OAS3 +|OAuth2_AuthorizationCode|✗|OAS2,OAS3 +|SignatureAuth|✗|OAS3 +|AWSV4Signature|✗|ToolingExtension + +### Wire Format Feature +| Name | Supported | Defined By | +| ---- | --------- | ---------- | +|JSON|✓|OAS2,OAS3 +|XML|✓|OAS2,OAS3 +|PROTOBUF|✗|ToolingExtension +|Custom|✓|OAS2,OAS3 diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 434983fb5e06..755b1eb46475 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -553,7 +553,7 @@ public Map postProcessAllModels(Map objs) private boolean codegenPropertyIsNew(CodegenModel model, CodegenProperty property) { return model.parentModel == null ? false - : model.parentModel.allVars.stream().anyMatch(p -> + : model.parentModel.allVars.stream().anyMatch(p -> p.name.equals(property.name) && (p.dataType.equals(property.dataType) == false || p.datatypeWithEnum.equals(property.datatypeWithEnum) == false || p.isDiscriminator)); } @@ -793,35 +793,35 @@ public ModelsMap postProcessModelsEnum(ModelsMap objs) { // update codegen property enum with proper naming convention // and handling of numbers, special characters for (CodegenProperty var : cm.vars) { - updateCodegenPropertyEnum(var); + updateCodegenPropertyEnum(var,cm); } for (CodegenProperty var : cm.allVars) { - updateCodegenPropertyEnum(var); + updateCodegenPropertyEnum(var,cm); } for (CodegenProperty var : cm.nonNullableVars) { - updateCodegenPropertyEnum(var); + updateCodegenPropertyEnum(var,cm); } for (CodegenProperty var : cm.requiredVars) { - updateCodegenPropertyEnum(var); + updateCodegenPropertyEnum(var,cm); } for (CodegenProperty var : cm.optionalVars) { - updateCodegenPropertyEnum(var); + updateCodegenPropertyEnum(var,cm); } for (CodegenProperty var : cm.parentVars) { - updateCodegenPropertyEnum(var); + updateCodegenPropertyEnum(var,cm); } for (CodegenProperty var : cm.readOnlyVars) { - updateCodegenPropertyEnum(var); + updateCodegenPropertyEnum(var,cm); } for (CodegenProperty var : cm.readWriteVars) { - updateCodegenPropertyEnum(var); + updateCodegenPropertyEnum(var,cm); } } @@ -6694,6 +6694,17 @@ public void updateCodegenPropertyEnum(CodegenProperty var) { } } + /** + * Update codegen property's enum by adding "enumVars" (with name and value), + * This method also has access to the parent CodegenModel. + * + * @param var list of CodegenProperty + * @param model parent CodegenModel + */ + public void updateCodegenPropertyEnum(CodegenProperty var, CodegenModel model) { + updateCodegenPropertyEnum(var); + } + protected String getEnumDefaultValue(String defaultValue, String dataType) { final String enumDefaultValue; if (isDataTypeString(dataType)) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartNextClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartNextClientCodegen.java new file mode 100644 index 000000000000..a715a9fff09c --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartNextClientCodegen.java @@ -0,0 +1,1340 @@ +package org.openapitools.codegen.languages; + +import static org.openapitools.codegen.CodegenConstants.SKIP_FORM_MODEL; +import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_CHAR; +import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER; +import static org.openapitools.codegen.utils.StringUtils.camelize; +import static org.openapitools.codegen.utils.StringUtils.escape; +import static org.openapitools.codegen.utils.StringUtils.underscore; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.CodegenModel; +import org.openapitools.codegen.CodegenParameter; +import org.openapitools.codegen.CodegenProperty; +import org.openapitools.codegen.CodegenType; +import org.openapitools.codegen.DefaultCodegen; +import org.openapitools.codegen.SupportingFile; +import org.openapitools.codegen.config.GlobalSettings; +import org.openapitools.codegen.meta.GeneratorMetadata; +import org.openapitools.codegen.meta.Stability; +import org.openapitools.codegen.meta.features.ClientModificationFeature; +import org.openapitools.codegen.meta.features.DataTypeFeature; +import org.openapitools.codegen.meta.features.DocumentationFeature; +import org.openapitools.codegen.meta.features.GlobalFeature; +import org.openapitools.codegen.meta.features.ParameterFeature; +import org.openapitools.codegen.meta.features.SchemaSupportFeature; +import org.openapitools.codegen.meta.features.SecurityFeature; +import org.openapitools.codegen.meta.features.WireFormatFeature; +import org.openapitools.codegen.model.ModelMap; +import org.openapitools.codegen.model.ModelsMap; +import org.openapitools.codegen.model.OperationsMap; +import org.openapitools.codegen.utils.ModelUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.collect.Sets; +import com.samskivert.mustache.DefaultCollector; +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.Mustache.Compiler; + +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.parameters.Parameter; +import lombok.Getter; +import lombok.Setter; + +public class DartNextClientCodegen extends DefaultCodegen { + public static final String PROJECT_NAME = "projectName"; + + private final Logger LOGGER = LoggerFactory.getLogger(DartNextClientCodegen.class); + + public static final String PUB_LIBRARY = "pubLibrary"; + public static final String PUB_NAME = "pubName"; + public static final String PUB_VERSION = "pubVersion"; + public static final String PUB_DESCRIPTION = "pubDescription"; + public static final String PUB_AUTHOR = "pubAuthor"; + public static final String PUB_AUTHOR_EMAIL = "pubAuthorEmail"; + public static final String PUB_HOMEPAGE = "pubHomepage"; + public static final String PUB_REPOSITORY = "pubRepository"; + public static final String PUB_PUBLISH_TO = "pubPublishTo"; + public static final String USE_ENUM_EXTENSION = "useEnumExtension"; + private static final String CLIENT_NAME = "clientName"; + + @Getter + @Setter + private String clientName; + @Setter + protected String pubLibrary = "openapi.api"; + @Setter + protected String pubName = "openapi"; + @Setter + protected String pubVersion = "1.0.0"; + @Setter + protected String pubDescription = "OpenAPI API client"; + @Setter + protected String pubAuthor = "Author"; + @Setter + protected String pubAuthorEmail = "author@homepage"; + @Setter + protected String pubHomepage = "homepage"; + @Setter + protected String pubRepository = null; + @Setter + protected String pubPublishTo = null; + @Setter + protected boolean useEnumExtension = false; + @Setter + protected String sourceFolder = "src"; + @Setter + protected boolean camelCaseDollarSign = false; + + protected String libPath = "lib" + File.separator; + + protected String srcPath() { + return libPath + sourceFolder + File.separator; + } + + protected String testPath() { + return "test" + File.separator; + } + + protected String modelsPath() { + return srcPath() + modelPackage(); + } + + protected String apisPath() { + return srcPath() + apiPackage(); + } + + protected String networkingPath() { + return srcPath() + "networking" + File.separator; + } + + protected String serializationPath() { + return srcPath() + "serialization" + File.separator; + } + + protected String apiDocFolder = "doc" + File.separator; + protected String modelDocFolder = "doc" + File.separator; + protected String apiTestFolder = "test" + File.separator + "apis" + File.separator; + protected String modelTestFolder = "test" + File.separator + "models" + File.separator; + + protected Map imports = new HashMap<>(); + + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + public String getName() { + return "dart-next"; + } + + public String getHelp() { + return "Generates a dart-next client."; + } + + public DartNextClientCodegen() { + super(); + + outputFolder = "generated-code" + File.separator + "dart-next"; + + embeddedTemplateDir = templateDir = "dart-next"; + apiPackage = "apis"; + modelPackage = "models"; + + generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) + .stability(Stability.EXPERIMENTAL) + .build(); + + supportsMixins = true; + supportsInheritance = true; + supportsMultipleInheritance = true; + legacyDiscriminatorBehavior = false; + supportsAdditionalPropertiesWithComposedSchema = true; + disallowAdditionalPropertiesIfNotPresent = false; + modifyFeatureSet(features -> features + .includeDataTypeFeatures(DataTypeFeature.AnyType, DataTypeFeature.Custom) + .includeDocumentationFeatures(DocumentationFeature.Readme) + .includeSchemaSupportFeatures( + SchemaSupportFeature.Polymorphism, + SchemaSupportFeature.Union, + SchemaSupportFeature.Composite, + SchemaSupportFeature.allOf, + SchemaSupportFeature.oneOf, + SchemaSupportFeature.anyOf) + + .securityFeatures(EnumSet.of( + SecurityFeature.OAuth2_Implicit, + SecurityFeature.BasicAuth, + SecurityFeature.BearerToken, + SecurityFeature.ApiKey)) + .excludeGlobalFeatures( + GlobalFeature.XMLStructureDefinitions, + GlobalFeature.Callbacks, + GlobalFeature.LinkObjects, + GlobalFeature.ParameterStyling) + .includeParameterFeatures( + ParameterFeature.Cookie) + .includeClientModificationFeatures( + ClientModificationFeature.BasePath) + .includeWireFormatFeatures(WireFormatFeature.Custom)); + + // modelDocTemplateFiles.put("object_doc.mustache", ".md"); + // apiDocTemplateFiles.put("api_doc.mustache", ".md"); + + // modelTestTemplateFiles.put("model_test.mustache", ".dart"); + // apiTestTemplateFiles.put("api_test.mustache", ".dart"); + + final List reservedWordsList = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"), + StandardCharsets.UTF_8))) { + while (reader.ready()) { + reservedWordsList.add(reader.readLine()); + } + } catch (Exception e) { + LOGGER.error("Error reading dart keywords. Exception: {}", e.getMessage()); + } + setReservedWordsLowerCase(reservedWordsList); + + // These types return isPrimitive=true in templates + languageSpecificPrimitives = Sets.newHashSet( + "String", + "bool", + "int", + "num", + "double"); + + typeMapping = new HashMap<>(); + typeMapping.put("Array", "List"); + typeMapping.put("array", "List"); + typeMapping.put("map", "Map"); + typeMapping.put("List", "List"); + typeMapping.put("set", "Set"); + typeMapping.put("boolean", "bool"); + typeMapping.put("string", "String"); + typeMapping.put("char", "String"); + typeMapping.put("int", "int"); + typeMapping.put("long", "int"); + typeMapping.put("short", "int"); + typeMapping.put("number", "num"); + typeMapping.put("float", "double"); + typeMapping.put("double", "double"); + typeMapping.put("decimal", "double"); + typeMapping.put("integer", "int"); + typeMapping.put("Date", "DateTime"); + typeMapping.put("date", "DateTime"); + typeMapping.put("DateTime", "DateTime"); + typeMapping.put("file", "XFile"); + typeMapping.put("binary", "Uint8List"); + typeMapping.put("UUID", "String"); + typeMapping.put("URI", "Uri"); + typeMapping.put("ByteArray", "Uint8List"); + typeMapping.put("object", "$FreeFormObject"); + typeMapping.put("AnyType", "Object"); + + // Data types of the above values which are automatically imported + defaultIncludes = Sets.newHashSet( + "String", + "bool", + "int", + "num", + "double", + "List", + "Set", + "Map", + "DateTime", + "Object"); + + imports.put("String", "dart:core"); + imports.put("bool", "dart:core"); + imports.put("int", "dart:core"); + imports.put("num", "dart:core"); + imports.put("double", "dart:core"); + imports.put("List", "dart:core"); + imports.put("Set", "dart:core"); + imports.put("Map", "dart:core"); + imports.put("DateTime", "dart:core"); + imports.put("Object", "dart:core"); + // imports.put("MultipartFile", "package:http/http.dart"); + + addOption(PUB_LIBRARY, "Library name in generated code", pubLibrary); + addOption(PUB_NAME, "Name in generated pubspec", pubName); + addOption(PUB_VERSION, "Version in generated pubspec", pubVersion); + addOption(PUB_DESCRIPTION, "Description in generated pubspec", pubDescription); + addOption(PUB_AUTHOR, "Author name in generated pubspec", pubAuthor); + addOption(PUB_AUTHOR_EMAIL, "Email address of the author in generated pubspec", pubAuthorEmail); + addOption(PUB_HOMEPAGE, "Homepage in generated pubspec", pubHomepage); + addOption(PUB_REPOSITORY, "Repository in generated pubspec", pubRepository); + addOption(PUB_PUBLISH_TO, "Publish_to in generated pubspec", pubPublishTo); + addOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums", + String.valueOf(useEnumExtension)); + addOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC, sourceFolder); + } + + @Override + public Compiler processCompiler(Compiler compiler) { + + // see https://github.com/samskivert/jmustache/issues/82#issuecomment-226284364 + return super.processCompiler(compiler).withCollector(new DefaultCollector() { + @Override + public Mustache.VariableFetcher createFetcher(Object ctx, String name) { + if (ctx instanceof Map && name.equals("entrySet")) { + return new Mustache.VariableFetcher() { + public Object get(Object ctx, String name) throws Exception { + return ((Map) ctx).entrySet(); + } + }; + } else if (ctx instanceof Map.Entry) { + if (name.equals("key")) { + return new Mustache.VariableFetcher() { + public Object get(Object ctx, String name) throws Exception { + return ((Map.Entry) ctx).getKey(); + } + }; + } else if (name.equals("value")) { + return new Mustache.VariableFetcher() { + public Object get(Object ctx, String name) throws Exception { + return ((Map.Entry) ctx).getValue(); + } + }; + } + } + return super.createFetcher(ctx, name); + } + }); + } + + @Override + protected String toMediaTypeSchemaName(String contentType, String mediaTypeSchemaSuffix) { + contentType = contentType.replaceAll("\\*", "Any"); + return toModelName(contentType); + } + + @Override + public void processOpts() { + super.processOpts(); + allowUnicodeIdentifiers = true; + + // Since we generate models for apis anyway, we need to always enable this. + GlobalSettings.setProperty(SKIP_FORM_MODEL, "false"); + + // Fix a couple Java notation properties + modelPackage = modelPackage.replace('.', '/'); + apiPackage = apiPackage.replace('.', '/'); + // And overwrite them in the additional properties + additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); + additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); + + if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) { + LOGGER.info( + "Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"dart format\"` (Linux/Mac)"); + LOGGER.info( + "NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); + } + + if (additionalProperties.containsKey(PUB_NAME)) { + this.setPubName((String) additionalProperties.get(PUB_NAME)); + } else { + // not set, use to be passed to template + additionalProperties.put(PUB_NAME, pubName); + } + + if (additionalProperties.containsKey(PUB_LIBRARY)) { + this.setPubLibrary((String) additionalProperties.get(PUB_LIBRARY)); + } else { + // not set, use to be passed to template + additionalProperties.put(PUB_LIBRARY, pubLibrary); + } + + if (additionalProperties.containsKey(PUB_VERSION)) { + this.setPubVersion((String) additionalProperties.get(PUB_VERSION)); + } else { + // not set, use to be passed to template + additionalProperties.put(PUB_VERSION, pubVersion); + } + + if (additionalProperties.containsKey(PUB_DESCRIPTION)) { + this.setPubDescription((String) additionalProperties.get(PUB_DESCRIPTION)); + } else { + // not set, use to be passed to template + additionalProperties.put(PUB_DESCRIPTION, pubDescription); + } + + if (additionalProperties.containsKey(PUB_AUTHOR)) { + this.setPubAuthor((String) additionalProperties.get(PUB_AUTHOR)); + } else { + // not set, use to be passed to template + additionalProperties.put(PUB_AUTHOR, pubAuthor); + } + + if (additionalProperties.containsKey(PUB_AUTHOR_EMAIL)) { + this.setPubAuthorEmail((String) additionalProperties.get(PUB_AUTHOR_EMAIL)); + } else { + // not set, use to be passed to template + additionalProperties.put(PUB_AUTHOR_EMAIL, pubAuthorEmail); + } + + if (additionalProperties.containsKey(PUB_HOMEPAGE)) { + this.setPubHomepage((String) additionalProperties.get(PUB_HOMEPAGE)); + } else { + // not set, use to be passed to template + additionalProperties.put(PUB_HOMEPAGE, pubHomepage); + } + + if (additionalProperties.containsKey(PUB_REPOSITORY)) { + this.setPubRepository((String) additionalProperties.get(PUB_REPOSITORY)); + } else { + // not set, use to be passed to template + additionalProperties.put(PUB_REPOSITORY, pubRepository); + } + + if (additionalProperties.containsKey(PUB_PUBLISH_TO)) { + this.setPubPublishTo((String) additionalProperties.get(PUB_PUBLISH_TO)); + } else { + // not set, use to be passed to template + additionalProperties.put(PUB_PUBLISH_TO, pubPublishTo); + } + + if (additionalProperties.containsKey(USE_ENUM_EXTENSION)) { + this.setUseEnumExtension(convertPropertyToBooleanAndWriteBack(USE_ENUM_EXTENSION)); + } else { + // Not set, use to be passed to template. + additionalProperties.put(USE_ENUM_EXTENSION, useEnumExtension); + } + + if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { + String srcFolder = (String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER); + this.setSourceFolder(srcFolder.replace('/', File.separatorChar)); + } + additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder); + + if (!additionalProperties.containsKey(CLIENT_NAME)) { + final String name = org.openapitools.codegen.utils.StringUtils.camelize(pubName); + additionalProperties.put(CLIENT_NAME, name); + LOGGER.debug("Client name not set, using default {}", name); + } + setClientName(additionalProperties.get(CLIENT_NAME).toString()); + + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocFolder); + additionalProperties.put("modelDocPath", modelDocFolder); + + // check to not overwrite a custom templateDir + if (templateDir == null) { + embeddedTemplateDir = templateDir = "dart-next"; + } + + String apisMustache = "lib/src/apis/"; + String modelsMustache = "lib/src/models/"; + String testsMustache = "test/"; + String modelsTestsMustache = testsMustache + "models/"; + String apisTestsMustache = testsMustache + "apis/"; + + modelTemplateFiles.put(modelsMustache + "model.mustache", ".dart"); + modelTemplateFiles.put(modelsMustache + "model.reflection.mustache", ".reflection.dart"); + // modelTemplateFiles.put(modelsMustache + "model.serialization.mustache", ".serialization.dart"); + + modelTestTemplateFiles.put(modelsTestsMustache + "model_tests.mustache", ".dart"); + apiTestTemplateFiles.put(apisTestsMustache + "api_tests.mustache", ".dart"); + + apiTemplateFiles.put(apisMustache + "api.mustache", ".dart"); + apiTemplateFiles.put(apisMustache + "api_requests.mustache", ".requests.dart"); + apiTemplateFiles.put(apisMustache + "api_responses.mustache", ".responses.dart"); + + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md").doNotOverwrite()); + supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml").doNotOverwrite()); + supportingFiles.add(new SupportingFile("CHANGELOG.md", "", "CHANGELOG.md").doNotOverwrite()); + supportingFiles.add(new SupportingFile("lib/internal_exports.mustache", "lib", "_internal.dart")); + supportingFiles.add(new SupportingFile("lib/public_exports.mustache", "lib", pubName + ".dart")); + supportingFiles.add(new SupportingFile("lib/src/facade.mustache", srcPath(), "api_facade.dart")); + supportingFiles.add(new SupportingFile(modelsMustache + "_exports.mustache", modelsPath(), "_exports.dart")); + supportingFiles.add(new SupportingFile(apisMustache + "_exports.mustache", apisPath(), "_exports.dart")); + + supportingFiles.add(new SupportingFile(testsMustache + "utils.mustache", testPath(), "utils.dart")); + + String networkingMustache = "lib/src/networking/"; + supportingFiles + .add(new SupportingFile(networkingMustache + "_exports.mustache", networkingPath(), "_exports.dart")); + supportingFiles + .add(new SupportingFile(networkingMustache + "_internal.mustache", networkingPath(), "_internal.dart")); + supportingFiles + .add(new SupportingFile(networkingMustache + "helpers.mustache", networkingPath(), "helpers.dart")); + supportingFiles + .add(new SupportingFile(networkingMustache + "property_encoding_rule.mustache", networkingPath(), + "property_encoding_rule.dart")); + supportingFiles + .add(new SupportingFile(networkingMustache + "wire_serialization_options.mustache", networkingPath(), + "wire_serialization_options.dart")); + supportingFiles + .add(new SupportingFile(networkingMustache + "multipart.mustache", networkingPath(), "multipart.dart")); + supportingFiles + .add(new SupportingFile(networkingMustache + "package_http_client.mustache", networkingPath(), + "package_http_client.dart")); + supportingFiles + .add(new SupportingFile(testsMustache + "networking/helpers_test.mustache", + testPath() + File.separator + "networking", + "helpers_test.dart")); + + String serializationMustache = "lib/src/serialization/"; + supportingFiles + .add(new SupportingFile(serializationMustache + "_exports.mustache", serializationPath(), + "_exports.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "_internal.mustache", serializationPath(), + "_internal.dart")); + + supportingFiles + .add(new SupportingFile(serializationMustache + "additional_properties.mustache", serializationPath(), + "additional_properties.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "examples.mustache", serializationPath(), + "examples.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "open_api_object.mustache", serializationPath(), + "open_api_object.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "parameter_serialization.mustache", serializationPath(), + "parameter_serialization.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "json_extensions.mustache", serializationPath(), + "json_extensions.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "reflection.mustache", serializationPath(), + "reflection.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "model_reflection.mustache", serializationPath(), + "model_reflection.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "container_reflection.mustache", serializationPath(), + "container_reflection.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "generated_reflections.mustache", serializationPath(), + "generated_reflections.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "primitive_reflection.mustache", serializationPath(), + "primitive_reflection.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "context.mustache", serializationPath(), + "context.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "xml_extensions.mustache", serializationPath(), + "xml_extensions.dart")); + supportingFiles + .add(new SupportingFile(serializationMustache + "xml_reflection.mustache", serializationPath(), + "xml_reflection.dart")); + supportingFiles + .add(new SupportingFile(testsMustache + "serialization/helpers_test.mustache", + testPath() + File.separator + "serialization", + "helpers_test.dart")); + // TODO: add all files inside shared_infrastructure to root folder of generated + // addSharedInfrastructureFiles(); + } + + private final String kIsChild = "x-is-child"; + private final String kIsParent = "x-is-parent"; + private final String kIsPure = "x-is-pure"; + private final String kSelfOnlyProps = "x-self-only-props"; + private final String kHasSelfOnlyProps = "x-has-self-only-props"; + private final String kAncestorOnlyProps = "x-ancestor-only-props"; + private final String kHasAncestorOnlyProps = "x-has-ancestor-only-props"; + private final String kSelfAndAncestorOnlyProps = "x-self-and-ancestor-only-props"; + private final String kHasSelfAndAncestorOnlyProps = "x-has-self-and-ancestor-only-props"; + /// Whether the model has any variable at all. + /// If this is false, the modal MUST be serialized to a scalar value via oneOf or anyOf. + private final String kHasAnyVars = "x-has-any-vars"; + private final String kParentDiscriminator = "x-parent-discriminator"; + + Map getInheritanceVariablesLocation(CodegenModel mo) { + return mo.vendorExtensions; + } + + + // Workaround weird case in DefaultCodegen where parameter can have isInteger but isNumeric == false. + @Override + public CodegenParameter fromParameter(Parameter parameter, Set imports) { + var result = super.fromParameter(parameter, imports); + if (result!=null) { + if (result.isInteger || result.isFloat || result.isDouble || result.isLong || result.isShort) { + result.isNumeric = true; + } + } + return result; + } + + // adapts codegen models and property to dart rules of inheritance + private Map adaptToDartInheritance(Map objs) { + // get all models + Map allModels = new HashMap<>(); + for (ModelsMap modelsEntries : objs.values()) { + for (ModelMap modelsMap : modelsEntries.getModels()) { + CodegenModel model = modelsMap.getModel(); + var hasAnyOfOrOneOf = ((model.anyOf != null && !model.anyOf.isEmpty()) + || (model.oneOf != null && !model.oneOf.isEmpty())); + model.vendorExtensions.put("hasAnyOfOrOneOf", hasAnyOfOrOneOf); + // if (model.discriminator != null) { + // //if there is a discriminator, make sure it exists in vars. + // var discriminatorPropertyResult = model.requiredVars.stream() + // .filter(t -> + // t.baseName.equals(model.discriminator.getPropertyBaseName())).findFirst(); + + // if (discriminatorPropertyResult.isPresent()) { + // final CodegenProperty discriminatorProperty = + // discriminatorPropertyResult.get(); + // if (!model.vars.stream().anyMatch(v -> + // v.baseName.equals(discriminatorProperty.baseName))) { + // model.vars.add(discriminatorProperty); + // } + // } + // } + allModels.put(model.getClassname(), model); + } + } + + // all ancestors + Set allAncestorsForAllModelsFlat = new HashSet<>(); + // maps a model to its ancestors + Map> allAncestorsForAllModels = new HashMap<>(); + for (java.util.Map.Entry cm : allModels.entrySet()) { + Set allAncestors = new HashSet<>(); + // get all ancestors + // TODO: optimize this logic ? + getAncestors(cm.getValue(), allModels, allAncestors); + // just in case, a model can't be its own ancestor + allAncestors.remove(cm.getKey()); + + allAncestorsForAllModels.put(cm.getKey(), allAncestors); + allAncestorsForAllModelsFlat.addAll(allAncestors); + } + + Set allPureClasses = new HashSet<>(); + // set isChild,isParent,isPure + for (java.util.Map.Entry cmEntry : allModels.entrySet()) { + String key = cmEntry.getKey(); + CodegenModel cm = cmEntry.getValue(); + // get all ancestors + Set allAncestors = allAncestorsForAllModels.get(key); + + // a class is a parent when it's an ancestor to another class + boolean isParent = allAncestorsForAllModelsFlat.contains(key); + // a class is a child when it has any ancestor + boolean isChild = !allAncestors.isEmpty(); + // a class is pure when it's not a child, and has no oneOf nor anyOf + boolean isPure = !isChild && (cm.oneOf == null || cm.oneOf.isEmpty()) + && (cm.anyOf == null || cm.anyOf.isEmpty()); + + Map varLocation = getInheritanceVariablesLocation(cm); + varLocation.put(kIsChild, isChild); + varLocation.put(kIsParent, isParent); + varLocation.put(kIsPure, isPure); + // if (!isParent && (cm.oneOf == null || cm.oneOf.isEmpty())) { + // // discriminator has no meaning here + // if (cm.discriminator != null) { + // varLocation.put(kParentDiscriminator, cm.discriminator); + // cm.discriminator = null; + // } + // } + // when pure: + // vars = allVars = selfOnlyProperties = kSelfAndAncestorOnlyProps + // ancestorOnlyProps = empty + if (isPure) { + varLocation.put(kHasAnyVars, cm.getAllVars() != null && cm.getAllVars().size() > 0); + varLocation.put(kSelfOnlyProps, new ArrayList<>(cm.getVars())); + varLocation.put(kHasSelfOnlyProps, !cm.getVars().isEmpty()); + varLocation.put(kAncestorOnlyProps, cm.parentVars = new ArrayList()); + varLocation.put(kHasAncestorOnlyProps, false); + varLocation.put(kSelfAndAncestorOnlyProps, cm.allVars = new ArrayList<>(cm.getVars())); + varLocation.put(kHasSelfAndAncestorOnlyProps, !cm.getVars().isEmpty()); + + allPureClasses.add(key); + } + } + + // handle impure models + for (java.util.Map.Entry cmEntry : allModels.entrySet()) { + String key = cmEntry.getKey(); + CodegenModel cm = cmEntry.getValue(); + if (allPureClasses.contains(key)) { + continue; + } + // get all ancestors + Set allAncestors = allAncestorsForAllModels.get(key); + + // get direct parents + // Set directParentNames = cm.allOf == null ? new HashSet<>() : + // cm.allOf; + Set compositeProperties = new HashSet<>(); + + Set compositeModelNames = new HashSet(); + compositeModelNames.addAll(ObjectUtils.firstNonNull(cm.oneOf, new HashSet<>())); + compositeModelNames.addAll(ObjectUtils.firstNonNull(cm.anyOf, new HashSet<>())); + compositeModelNames.addAll(allAncestors); + + for (String compositeModelName : compositeModelNames) { + CodegenModel model = allModels.get(compositeModelName); + if (model == null) + continue; + List allVars = ObjectUtils.firstNonNull(model.getAllVars(), new ArrayList<>()); + for (CodegenProperty prop : allVars) { + compositeProperties.add(prop.getName()); + } + } + // dart classes declare selfOnlyProperties as direct members (they exist in + // "vars") + // for pure models, this will equal vars + Map selfOnlyProperties = new HashMap<>(); + + // ancestorOnlyProperties are properties defined by all ancestors + // NOTE: oneOf,anyOf are NOT considered ancestors + // since a child in dart must implement ALL OF the parent (using implements) + Map ancestorOnlyProperties = new HashMap<>(); + + // combines both selfOnlyProperties and ancestorOnlyProperties + // this will be used by the custom serializer as "x-handled-vars" and + // "x-has-handled-vars" + Map selfAndAncestorOnlyProperties = new HashMap<>(); + + // STEP 1: calculating selfOnlyProperties + // get all vars of all ancestors and add them to ancestorPropNames + // Set _ancestorPropNames = new HashSet<>(); + for (String ancestorKey : allAncestors) { + CodegenModel ancestorCM = allModels.get(ancestorKey); + if (ancestorCM != null) { + for (CodegenProperty prop : ancestorCM.getVars()) { + ancestorOnlyProperties.put(prop.getName(), prop); + } + } + } + for (CodegenProperty p : cm.getVars()) { + p.isInherited = ancestorOnlyProperties.containsKey(p.getName()); + if (!p.isInherited && (!compositeProperties.contains(p.getName()) || p.isDiscriminator)) { + selfOnlyProperties.put(p.getName(), p); + } + } + selfAndAncestorOnlyProperties.putAll(selfOnlyProperties); + selfAndAncestorOnlyProperties.putAll(ancestorOnlyProperties); + + Map varLocation = getInheritanceVariablesLocation(cm); + varLocation.put(kHasAnyVars, cm.getAllVars() != null && cm.getAllVars().size() > 0); + varLocation.put(kSelfOnlyProps, cm.vars = new ArrayList<>(selfOnlyProperties.values())); + varLocation.put(kHasSelfOnlyProps, !selfOnlyProperties.isEmpty()); + varLocation.put(kAncestorOnlyProps, cm.parentVars = new ArrayList<>(ancestorOnlyProperties.values())); + varLocation.put(kHasAncestorOnlyProps, !ancestorOnlyProperties.isEmpty()); + varLocation.put(kSelfAndAncestorOnlyProps, + cm.allVars = new ArrayList<>(selfAndAncestorOnlyProperties.values())); + varLocation.put(kHasSelfAndAncestorOnlyProps, !selfAndAncestorOnlyProperties.isEmpty()); + } + + return objs; + } + + /// Gets all ancestors of a given model, and puts it in accumulator + private void getAncestors(CodegenModel cm, Map allModels, Set accumulator) { + + // get direct parents + Set directParentNames = cm.allOf; + if (directParentNames != null && !directParentNames.isEmpty()) { + for (String directParentName : directParentNames) { + if (accumulator.add(directParentName)) { + CodegenModel parent = allModels.get(directParentName); + if (parent != null) { + getAncestors(parent, allModels, accumulator); + } + } + } + } + } + + @Override + public Map postProcessAllModels(Map objs) { + objs = super.postProcessAllModels(objs); + objs = super.updateAllModels(objs); + objs = adaptToDartInheritance(objs); + + return objs; + } + + // private void addSharedInfrastructureFiles() { + + // String sharedInfrastructureFolder = "shared_infrastructure" + File.separator; + + // String libFolder = sharedInfrastructureFolder + "lib" + File.separator; + // String srcFolder = libFolder + "src" + File.separator; + // String networkingFolder = srcFolder + "networking" + File.separator; + // String serializationFolder = srcFolder + "serialization" + File.separator; + // supportingFiles.add(new SupportingFile(sharedInfrastructureFolder + + // "pubspec.mustache", sharedInfrastructureFolder, + // "pubspec.yaml")); + // supportingFiles.add( + // new SupportingFile(libFolder + "shared_infrastructure.dart", libFolder, + // "shared_infrastructure.dart")); + // // Networking + // supportingFiles.add( + // new SupportingFile(networkingFolder + "_exports.mustache", networkingFolder, + // "_exports.dart")); + // supportingFiles.add( + // new SupportingFile(networkingFolder + "client.mustache", networkingFolder, + // "client.dart")); + // supportingFiles.add( + // new SupportingFile(networkingFolder + "helpers.mustache", networkingFolder, + // "helpers.dart")); + // supportingFiles.add( + // new SupportingFile(networkingFolder + "http_packets.mustache", + // networkingFolder, "http_packets.dart")); + // supportingFiles.add( + // new SupportingFile(networkingFolder + "request.mustache", networkingFolder, + // "request.dart")); + // supportingFiles.add( + // new SupportingFile(networkingFolder + "request.multipart.mustache", + // networkingFolder, "request.multipart.dart")); + // supportingFiles.add( + // new SupportingFile(networkingFolder + "response.mustache", networkingFolder, + // "response.dart")); + + // // Serialization + // supportingFiles.add( + // new SupportingFile(serializationFolder + "_exports.mustache", + // serializationFolder, "_exports.dart")); + // supportingFiles.add( + // new SupportingFile(serializationFolder + "helpers.mustache", + // serializationFolder, "helpers.dart")); + // supportingFiles.add( + // new SupportingFile(serializationFolder + "undefined_wrapper.mustache", + // serializationFolder, + // "undefined_wrapper.dart")); + + // } + + @Override + public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List allModels) { + var result = super.postProcessOperationsWithModels(objs, allModels); + var operations = result.getOperations(); + for (var operation : operations.getOperation()) { + var bodyParam = operation.bodyParam; + if (bodyParam == null) { + continue; + } + var resultContentMap = bodyParam.getContent(); + if (resultContentMap == null) { + continue; + } + var betterConsumes = new ArrayList>(); + for (var consumeEntry : resultContentMap.entrySet()) { + var key = consumeEntry.getKey(); + var resultContent = consumeEntry.getValue(); + var betterConsume = new HashMap(); + Map originalConsume = null; + if (operation.consumes != null) { + for (var x : operation.consumes) { + var mediaType = x.get("mediaType"); + if (key.equals(mediaType)) { + originalConsume = x; + break; + } + } + } + if (originalConsume != null) { + betterConsume.putAll(originalConsume); + } + betterConsume.put("key", key); + var mimePatternList = key.toLowerCase(Locale.ROOT).split(";")[0].split("/"); + betterConsume.put("is_mime_" + mimePatternList[0], true); + betterConsume.put("is_mime_" + mimePatternList[0] + "_" + mimePatternList[1], true); + betterConsume.put("content", resultContent); + var extraParameters = new ArrayList(); + if (resultContent != null && resultContent.getEncoding() != null) { + for (var propEncoding : resultContent.getEncoding().entrySet()) { + if (propEncoding.getValue() == null || propEncoding.getValue().getHeaders() == null) { + continue; + } + var propBaseName = propEncoding.getKey(); + var headers = propEncoding.getValue().getHeaders(); + for (var header : headers) { + if (header.paramName != null) { + header.paramName = toParamName(propBaseName + "_" + header.paramName + "_header"); + } + extraParameters.add(header); + } + } + } + + betterConsume.put("extraParameters", extraParameters); + betterConsumes.add(betterConsume); + } + operation.vendorExtensions.put("better-consumes", betterConsumes); + } + for (var operation : operations.getOperation()) { + if (operation.responses == null) { + continue; + } + for (var response : operation.responses) { + if (response.getContent() == null) { + continue; + } + for (var content : response.getContent().entrySet()) { + var key = content.getKey(); + var value = content.getValue(); + if (value == null) { + continue; + } + + var mimePatternList = key.toLowerCase(Locale.ROOT).split(";")[0].split("/"); + value.vendorExtensions.put("is_mime_" + mimePatternList[0], true); + value.vendorExtensions.put("is_mime_" + mimePatternList[0] + "_" + mimePatternList[1], true); + if (value.getSchema() != null) { + value.getSchema().vendorExtensions.putAll(value.vendorExtensions); + } + } + } + } + return result; + } + + @Override + protected boolean needToImport(String type) { + // Import everything, unless it is from dart:core. + return StringUtils.isNotBlank(type) && (!imports.containsKey(type) || !imports.get(type).equals("dart:core")); + } + + @Override + protected boolean isReservedWord(String word) { + // consider everything as reserved that is + // * a keyword + // * a word that has been mapped in the reservedWordsMappings + // * a default included type or a type include through some library + return super.isReservedWord(word) || reservedWordsMappings().containsKey(word) + || defaultIncludes().contains(word); + } + + @Override + public String escapeReservedWord(String name) { + if (reservedWordsMappings().containsKey(name)) { + return reservedWordsMappings().get(name); + } + return "$" + name; + } + + @Override + public String apiFileFolder() { + return (outputFolder + File.separator + libPath + sourceFolder + File.separator + apiPackage()).replace('/', + File.separatorChar); + } + + @Override + public String modelFileFolder() { + return (outputFolder + File.separator + libPath + sourceFolder + File.separator + modelPackage()).replace('/', + File.separatorChar); + } + + @Override + public String apiTestFileFolder() { + return outputFolder + File.separator + apiTestFolder; + } + + @Override + public String modelTestFileFolder() { + return outputFolder + File.separator + modelTestFolder; + } + + @Override + public String apiDocFileFolder() { + return outputFolder + File.separator + apiDocFolder; + } + + @Override + public String modelDocFileFolder() { + return outputFolder + File.separator + modelDocFolder; + } + + @Override + public String toVarName(String name) { + // obtain the name from nameMapping directly if provided + if (nameMapping.containsKey(name)) { + return nameMapping.get(name); + } + + // sanitize name + name = sanitizeName(name, "\\W-[\\$]"); // FIXME: a parameter should not be assigned. Also declare the methods + // parameters as 'final'. + + if (name.toLowerCase(Locale.ROOT).matches("^_*class$")) { + return "propertyClass"; + } + + if ("_".equals(name)) { + name = "_u"; + } + + // numbers are not allowed at the beginning + if (name.matches("^\\d.*")) { + name = "_" + name; + } + + // if it's all upper case, do nothing + if (name.matches("^[A-Z0-9_]*$")) { + return name; + } + + if (startsWithTwoUppercaseLetters(name)) { + name = name.substring(0, 2).toLowerCase(Locale.ROOT) + name.substring(2); + } + + // If name contains special chars -> replace them. + if ((((CharSequence) name).chars() + .anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character))))) { + List allowedCharacters = new ArrayList<>(); + allowedCharacters.add("_"); + allowedCharacters.add("$"); + name = escape(name, specialCharReplacements, allowedCharacters, "_"); + } + + // camelize (lower first character) the variable name + // pet_id => petId + if (camelCaseDollarSign) { + name = camelize(name, LOWERCASE_FIRST_CHAR); + } else { + name = camelize(name, LOWERCASE_FIRST_LETTER); + } + + // for reserved word or word starting with number, append _ + if (isReservedWord(name) || name.matches("^\\d.*")) { + name = escapeReservedWord(name); + } + + return name; + } + + private boolean startsWithTwoUppercaseLetters(String name) { + boolean startsWithTwoUppercaseLetters = false; + if (name.length() > 1) { + startsWithTwoUppercaseLetters = name.substring(0, 2).equals(name.substring(0, 2).toUpperCase(Locale.ROOT)); + } + return startsWithTwoUppercaseLetters; + } + + @Override + public String toParamName(String name) { + if (parameterNameMapping.containsKey(name)) { + return parameterNameMapping.get(name); + } + + // should be the same as variable name + return toVarName(name); + } + + @Override + public String toModelName(final String name) { + // obtain the name from modelNameMapping directly if provided + if (modelNameMapping.containsKey(name)) { + return modelNameMapping.get(name); + } + + String sanitizedName = sanitizeName(name); + + if (!StringUtils.isEmpty(modelNamePrefix)) { + // add '_' so that model name can be camelized correctly + sanitizedName = modelNamePrefix + "_" + sanitizedName; + } + + if (!StringUtils.isEmpty(modelNameSuffix)) { + // add '_' so that model name can be camelized correctly + sanitizedName = sanitizedName + "_" + modelNameSuffix; + } + + // camelize the model name + // phone_number => PhoneNumber + final String camelizedName = camelize(sanitizedName); + + // Check if there is a mapping that can be used + if (typeMapping().containsKey(camelizedName)) { + String typeName = typeMapping().get(camelizedName); + if (imports.containsKey(typeName)) { + // Anything with an import mapping is likely + // generator specific and can not be used as model name. + final String modelName = "$" + camelizedName; + LOGGER.warn("{} (existing type) cannot be used as model name. Renamed to {}", camelizedName, modelName); + return modelName; + } + return typeName; + } + + // model name cannot use reserved keyword, e.g. return + if (isReservedWord(camelizedName)) { + final String modelName = "$" + camelizedName; + LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", camelizedName, modelName); + return modelName; + } + + // model name starts with number + if (camelizedName.matches("^\\d.*")) { + final String modelName = "$" + camelizedName; // e.g. 200Response => $200Response (after camelize) + LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name, + modelName); + return modelName; + } + + return camelizedName; + } + + @Override + public String toModelFilename(String name) { + return underscore(toModelName(name)); + } + + @Override + public String toModelDocFilename(String name) { + return toModelName(name); + } + + @Override + public String toApiFilename(String name) { + return underscore(toApiName(name)); + } + + @Override + public String toApiTestFilename(String name) { + return toApiFilename(name) + "_test"; + } + + @Override + public String toModelTestFilename(String name) { + return toModelFilename(name) + "_test"; + } + + @Override + public String toDefaultValue(Schema schema) { + if (schema.getDefault() != null) { + // if (ModelUtils.isMapSchema(schema) || ModelUtils.isSet(schema)) { + // return "const {}"; + // } + // if (ModelUtils.isArraySchema(schema)) { + // return "const []"; + // } + if (ModelUtils.isDateSchema(schema) || ModelUtils.isDateTimeSchema(schema)) { + // this is currently not supported and would create compile errors + return null; + } + if (ModelUtils.isStringSchema(schema)) { + return "'" + schema.getDefault().toString().replace("'", "\\'") + "'"; + } + return schema.getDefault().toString(); + } + return null; + + } + + @Override + public CodegenProperty fromProperty(String name, Schema p, boolean required, + boolean schemaIsFromAdditionalProperties) { + var result = super.fromProperty(name, p, required, + schemaIsFromAdditionalProperties); + // Fix for DefaultGenerator setting isModel to false when it has both + // properties + additionalProperties. + Schema referencedSchema = ModelUtils.getReferencedSchema(this.openAPI, p); + if (referencedSchema != null && !result.isModel && + ModelUtils.isModel(referencedSchema) && + referencedSchema.getProperties() != null && + !referencedSchema.getProperties().isEmpty()) { + result.isModel = true; + } + return result; + } + + @Override + public String getTypeDeclaration(Schema p) { + Schema schema = unaliasSchema(p); + Schema target = ModelUtils.isGenerateAliasAsModel() ? p : schema; + return super.getTypeDeclaration(target); + } + // @Override + // public String getTypeDeclaration(Schema p) { + // Schema schema = unaliasSchema(p); + // Schema target = ModelUtils.isGenerateAliasAsModel() ? p : schema; + // if (ModelUtils.isArraySchema(target)) { + // Schema items = ModelUtils.getSchemaItems(schema); + // return getSchemaType(target) + "<" + getTypeDeclaration(items) + ">"; + // } + // if (ModelUtils.isMapSchema(target)) { + // // Note: ModelUtils.isMapSchema(p) returns true when p is a composed schema + // that also defines + // // additionalproperties: true + // Schema inner = ModelUtils.getAdditionalProperties(target); + // if (inner == null) { + // LOGGER.error("`{}` (map property) does not have a proper inner type defined. + // Default to type:string", p.getName()); + // inner = new StringSchema().description("TODO default missing map inner type + // to string"); + // p.setAdditionalProperties(inner); + // } + // return getSchemaType(target) + ""; + // } + // return super.getTypeDeclaration(p); + // } + + @Override + public String getSchemaType(Schema p) { + String openAPIType = super.getSchemaType(p); + + // don't apply renaming on types from the typeMapping + if (typeMapping.containsKey(openAPIType)) { + return typeMapping.get(openAPIType); + } + + if (null == openAPIType) { + LOGGER.error("No Type defined for Schema {}", p); + } + return toModelName(openAPIType); + } + + @Override + public ModelsMap postProcessModels(ModelsMap objs) { + objs = postProcessModelsEnum(objs); + + return objs; + } + + @Override + public void updateCodegenPropertyEnum(CodegenProperty var, CodegenModel cm) { + super.updateCodegenPropertyEnum(var); + if (var.enumName != null) { + propagateCorrectEnumName(var, cm.classname + var.enumName); + } + } + + protected void propagateCorrectEnumName(CodegenProperty var, String enumName) { + if (var == null) { + return; + } + if (var.enumName != null && !var.enumName.equals(enumName)) { + var oldEnumName = var.enumName; + LOGGER.info("enumName is not correct for property {}, renaming from {} to {}", var.name, var.enumName, + enumName); + + var.enumName = enumName; + if (oldEnumName.equals(var.datatypeWithEnum)) { + var.datatypeWithEnum = enumName; + } + } + propagateCorrectEnumName(var.items, enumName); + propagateCorrectEnumName(var.additionalProperties, enumName); + } + + @Override + public String toEnumName(CodegenProperty property) { + return sanitizeName(camelize(property.name)) + "Enum"; + } + + @Override + public String toEnumVarName(String value, String datatype) { + if (enumNameMapping.containsKey(value)) { + return enumNameMapping.get(value); + } + + if (value.length() == 0) { + return "empty"; + } + if (("number".equalsIgnoreCase(datatype) || + "double".equalsIgnoreCase(datatype) || + "int".equalsIgnoreCase(datatype)) && + value.matches("^-?\\d.*")) { + // Only rename numeric values when the datatype is numeric + // AND the name is not changed by enum extensions (matches a numeric value). + boolean isNegative = value.startsWith("-"); + return toVarName("number" + (isNegative ? "_negative" : "") + value); + } + return toVarName(value); + } + + @Override + public String toEnumValue(String value, String datatype) { + if ("String".equalsIgnoreCase(datatype) || + "string".equalsIgnoreCase(datatype)) { + return "'" + escapeText(value) + "'"; + } else { + return value; + } + } + + @Override + public String toOperationId(String operationId) { + operationId = super.toOperationId(operationId); + + operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER); + + // method name cannot use reserved keyword, e.g. return + if (isReservedWord(operationId)) { + String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER); + LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId); + return newOperationId; + } + + // operationId starts with a number + if (operationId.matches("^\\d.*")) { + String newOperationId = "$" + operationId; + LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, + newOperationId); + operationId = newOperationId; + } + + return operationId; + } + + @Override + public String escapeQuotationMark(String input) { + // remove " to avoid code injection + return input.replace("\"", ""); + } + + @Override + public String escapeUnsafeCharacters(String input) { + return input.replace("*/", "*_/").replace("/*", "/_*"); + } + + @Override + public void postProcessFile(File file, String fileType) { + super.postProcessFile(file, fileType); + if (file == null) { + return; + } + + String dartPostProcessFile = System.getenv("DART_POST_PROCESS_FILE"); + if (StringUtils.isEmpty(dartPostProcessFile)) { + return; // skip if DART_POST_PROCESS_FILE env variable is not defined + } + + // process all files with dart extension + if ("dart".equals(FilenameUtils.getExtension(file.toString()))) { + // currently supported is "dartfmt -w" and "dart format" + String command = dartPostProcessFile + " " + file; + try { + Process p = Runtime.getRuntime().exec(command); + int exitValue = p.waitFor(); + if (exitValue != 0) { + LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue); + } else { + LOGGER.info("Successfully executed: {}", command); + } + } catch (InterruptedException | IOException e) { + LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage()); + // Restore interrupted state + Thread.currentThread().interrupt(); + } + } + } +} diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig index e5f7b479fb43..d13a478ebd4d 100644 --- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig +++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -156,3 +156,5 @@ org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen org.openapitools.codegen.languages.WsdlSchemaCodegen org.openapitools.codegen.languages.XojoClientCodegen org.openapitools.codegen.languages.ZapierClientCodegen +org.openapitools.codegen.languages.RustAxumServerCodegen +org.openapitools.codegen.languages.DartNextClientCodegen diff --git a/modules/openapi-generator/src/main/resources/dart-next/.gitignore b/modules/openapi-generator/src/main/resources/dart-next/.gitignore new file mode 100644 index 000000000000..3cceda557896 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/.gitignore @@ -0,0 +1,7 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock diff --git a/modules/openapi-generator/src/main/resources/dart-next/CHANGELOG.md b/modules/openapi-generator/src/main/resources/dart-next/CHANGELOG.md new file mode 100644 index 000000000000..effe43c82c8a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/modules/openapi-generator/src/main/resources/dart-next/README.md b/modules/openapi-generator/src/main/resources/dart-next/README.md new file mode 100644 index 000000000000..81b01f698e09 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/README.md @@ -0,0 +1,70 @@ +# Dart-next Generator + +This generator solves all the problems that other dart generators are facing, but rethinking the approaches we use to generate and represent APIs to closely match what the openapi spec expects. + +Thus having 100% spec compliance and 0 surprises for the API consumer. + +## Schema representation + +The generator maps the following [schema types](https://spec.openapis.org/oas/v3.0.3#data-types) to their dart counterparts: + +type| format | Comments | Dart type +------ | -------- | -------- | -------- +`integer` | `int32` | signed 32 bits | `int` +`integer` | `int64` | signed 64 bits (a.k.a long) | `int` +`number` | `float` | | `double` +`number` | `double` | | `double` +`string` | | | `String` +`string` | `byte` | base64 encoded characters | `Uint8List` +`string` | `binary` | any sequence of octets | `XFile` +`boolean` | | | `bool` +`string` | `date` | As defined by `full-date` - [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) | `DateTime` +`string` | `date-time` | As defined by `date-time` - [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) | `DateTime` +`string` | `password` | A hint to UIs to obscure input. | `String` +`array` | | | `List` +`map` | | | `Map` +`object` | | | `$OpenApiObjectMixin` (more on that in [models](#models)) + +## Models + +A model in this generator represents either: +1. an `object` type. +2. a `oneOf`/`anyOf` construct (even if it's between 2 pure primitives). +3. or both. + +A model does NOT represent pure primitives (e.g. `type: string`), since they are represented with their own types (e.g. `String`). + +All models are represented by classes that mix `$OpenApiObjectMixin`, and they MUST provide an override of `ModelReflection get $classReflection`. + +## Reflections + +The way this generator works, is by including the metadata described in the OAS document as part of the generated code as compile-time constants (`const`) that we call `Reflection`, and then using the generated reflections to handle serialization related functions. + +Each reflection must provide the following functions: + +1. `serializeFunction`: Takes in an instance of the associated type, and converts it to the appropriate serialization type based on the provided `SerializationContext`. +2. `canDeserializeFunction`: Takes in a serialization type, and checks if it can be converted to the associated type based on the provided `SerializationContext`. +3. `deserializeFunction`: Takes in a serialization type, and converts it to the associated type based on the provided `SerializationContext`. +4. `empty` generates an empty instance of the associated type. This is mainly used in deserialization if a property is required, we use the reflection to get an empty instance of it that MUST be changed later. +5. `example`: generates a random example value, used both in tests and in example folder. + +There are 2 types of reflections and they both inherit `SerializationReflection`, where `T` represents the dart type being reflected. + +### Primitive Reflections + +Used to reflect the primitive types described [above](#schema-representation). + +### Class Reflections + +Used to reflect [Models](#models) only. + +Contains parts of the OAS document that are relevant to the class. + +These are split into the 4 main types: + +1. **PropertyPart**s: Used to describe property definitions, including their name, type, required, nullable, etc... +2. **additionalPropertiesPart**: Used to declare that this model accepts additional properties, and also contains information about their type. +3. **oneOfs**,**anyOfs**,**allOfs**: Used to describe composite relations in this model. + +#### Property Parts + diff --git a/modules/openapi-generator/src/main/resources/dart-next/README.mustache b/modules/openapi-generator/src/main/resources/dart-next/README.mustache new file mode 100644 index 000000000000..59c8f28a0f8b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/README.mustache @@ -0,0 +1,19 @@ +# {{pubName}} (EXPERIMENTAL) +{{#appDescriptionWithNewLines}} +{{{.}}} +{{/appDescriptionWithNewLines}} + +This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +{{#artifactVersion}} +- Package version: {{.}} +{{/artifactVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Generator version: {{generatorVersion}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/analysis_options.yaml b/modules/openapi-generator/src/main/resources/dart-next/analysis_options.yaml new file mode 100644 index 000000000000..dee8927aafeb --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/internal_exports.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/internal_exports.mustache new file mode 100644 index 000000000000..ee69d75ffda6 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/internal_exports.mustache @@ -0,0 +1,11 @@ +export 'src/serialization/_internal.dart'; +export 'src/networking/_internal.dart'; +export 'dart:core'; +export '{{pubName}}.dart'; +export 'package:cross_file/cross_file.dart'; +export 'dart:convert'; +export 'dart:typed_data'; +export 'package:xml/xml.dart'; +export 'package:http_parser/http_parser.dart'; +export 'package:meta/meta.dart'; +export 'dart:math'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/public_exports.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/public_exports.mustache new file mode 100644 index 000000000000..a489e94158ae --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/public_exports.mustache @@ -0,0 +1,10 @@ +/// Auto generated openapi bindings +library; + +export 'src/api_facade.dart'; +export 'src/apis/_exports.dart'; +export 'src/models/_exports.dart'; +export 'src/networking/_exports.dart'; +export 'src/serialization/_exports.dart'; + +export 'package:openapi_infrastructure/openapi_infrastructure.dart'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/_exports.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/_exports.mustache new file mode 100644 index 000000000000..59ba81a3b42b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/_exports.mustache @@ -0,0 +1,2 @@ +{{#apiInfo}}{{#apis}}export '{{classFilename}}.dart'; +{{/apis}}{{/apiInfo}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/api.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/api.mustache new file mode 100644 index 000000000000..d7f4722ed830 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/api.mustache @@ -0,0 +1,42 @@ +import 'package:{{pubName}}/_internal.dart'; + +{{#operations}} +part '{{classFilename}}.requests.dart'; +part '{{classFilename}}.responses.dart'; +{{/operations}} + +{{#operations}} +class {{classname}} { + final NetworkingClientBase networkingClient; + final Uri baseUrl; + final Map userContext; + + const {{classname}}({ + required this.networkingClient, + required this.baseUrl, + this.userContext = const {}, + }); + + {{#operation}} + {{#isDeprecated}} + @Deprecated('This operation has been deprecated') + {{/isDeprecated}} + Future<{{classname}}{{operationIdCamelCase}}Response> {{operationId}}( + {{classname}}{{operationIdCamelCase}}Request request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return {{classname}}{{operationIdCamelCase}}Response.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + {{/operation}} +} +{{/operations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/api_requests.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/api_requests.mustache new file mode 100644 index 000000000000..c72df6d67973 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/api_requests.mustache @@ -0,0 +1,305 @@ +// ignore_for_file: unnecessary_type_check + +{{#operations}} +part of '{{classFilename}}.dart'; +{{/operations}} + +{{#operations}}{{#operation}} + +{{#allParams}} +{{! you may think that this logic is redundant here, but these 2 lines are required +since we don't have a #hasSchema variable. + +The first line will change the scope to the schema variable, and we can't go back to +the parent once inside 'recursive_inline_enum' + +The second line will always target the current parameter scope. +}} +{{#schema}}{{>lib/src/models/enum_inline_recursive}}{{/schema}} +{{^schema}}{{>lib/src/models/enum_inline_recursive}}{{/schema}} +{{/allParams}} + +{{#isDeprecated}} +@Deprecated('This operation has been deprecated') +{{/isDeprecated}} +{{#bodyAllowed}}abstract{{/bodyAllowed}} class {{classname}}{{operationIdCamelCase}}Request { + static const pathTemplate = r'{{{path}}}'; + static String method = r'{{{httpMethod}}}'; + + {{#bodyAllowed}} + String get contentType; + {{/bodyAllowed}} + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + {{! add path / header / query / cookie params }} + {{#allParams}} + {{^isFormParam}}{{^isBodyParam}} + /// {{{description}}} + /// spec name: {{baseName}} + final {{>types/param}} {{paramName}}; + {{/isBodyParam}}{{/isFormParam}} + {{/allParams}} + + {{#bodyAllowed}} + const factory {{classname}}{{operationIdCamelCase}}Request.unsafe({ + {{#allParams}}{{^isFormParam}}{{^isBodyParam}} + {{>types/required_ctor}} {{>types/param}} {{paramName}}, + {{/isBodyParam}}{{/isFormParam}}{{/allParams}} + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = {{classname}}{{operationIdCamelCase}}RequestUnsafe; + + {{#vendorExtensions}}{{#better-consumes}}{{#content}}{{#schema}} + const factory {{classname}}{{operationIdCamelCase}}Request.{{nameInCamelCase}}({ + required {{>types/variable_recursive}} data, + {{#extraParameters}} + {{>types/param}} {{paramName}}, + {{/extraParameters}} + {{#allParams}} + {{^isFormParam}}{{^isBodyParam}} + {{>types/required_ctor}} {{>types/param}} {{paramName}}, + {{/isBodyParam}}{{/isFormParam}} + {{/allParams}} + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = {{classname}}{{operationIdCamelCase}}Request{{nameInPascalCase}}; + {{/schema}}{{/content}}{{/better-consumes}}{{/vendorExtensions}} + {{/bodyAllowed}} + + const {{classname}}{{operationIdCamelCase}}Request({ + {{#allParams}} + {{^isFormParam}}{{^isBodyParam}} + {{>types/required_ctor}} this.{{paramName}}{{>types/default}}, + {{/isBodyParam}}{{/isFormParam}} + {{/allParams}} + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + {{! first we resolve path parameters }} + {{#pathParams}} + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'{{style}}', explode: {{isExplode}}, parameterName: r'{{baseName}}',).expand(resolvedPath, {{paramName}}); + {{/pathParams}} + {{! then query parameters }} + var methodUri = Uri(path: resolvedPath); + {{#queryParams}} + {{^required}} + if ({{paramName}}.isDefined) { + {{/required}} + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'{{style}}', explode: {{isExplode}}, parameterName: r'{{baseName}}', allowEmptyValue: {{isAllowEmptyValue}},).expandUri(methodUri, {{paramName}}{{^required}}.valueRequired{{/required}}); + {{^required}} + } + {{/required}} + {{/queryParams}} + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + {{#cookieParams}} + {{^required}}if ({{paramName}}.isDefined){{/required}} + r'{{baseName}}': OpenApiParameterSerializationCookie(parameterName: r'{{baseName}}',explode: {{isExplode}}).serialize({{paramName}}{{^required}}.valueRequired{{/required}}), + {{/cookieParams}} + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + {{#bodyAllowed}} + 'Content-Type': this.contentType, + {{/bodyAllowed}} + {{! first add cookie header }} + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + {{! then headers to override the cookie if necessary }} + {{#headerParams}} + {{>lib/src/apis/request/header_param}} + {{/headerParams}} + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + {{#bodyAllowed}} + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + {{/bodyAllowed}} + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: {{#bodyAllowed}}getResolvedBody(userContext: userContext, headers: headers){{/bodyAllowed}}{{^bodyAllowed}}Stream.empty(){{/bodyAllowed}}, + context: userContext, + ); + } +} + +{{#bodyAllowed}} +/// A version of [{{classname}}{{operationIdCamelCase}}Request], where you can send arbitrary bytes in the body. +class {{classname}}{{operationIdCamelCase}}RequestUnsafe extends {{classname}}{{operationIdCamelCase}}Request { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const {{classname}}{{operationIdCamelCase}}RequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + {{#allParams}} + {{^isFormParam}}{{^isBodyParam}} + {{>types/required_ctor}} super.{{paramName}}, + {{/isBodyParam}}{{/isFormParam}} + {{/allParams}} + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + +{{#vendorExtensions}}{{#better-consumes}}{{#content}}{{#schema}} + +{{#content}}{{#encoding}}{{#entrySet}}{{#value}}{{#headers}} +{{#schema}}{{>lib/src/models/enum_inline_recursive}}{{/schema}} +{{^schema}}{{>lib/src/models/enum_inline_recursive}}{{/schema}} +{{/headers}}{{/value}}{{/entrySet}}{{/encoding}}{{/content}} +class {{classname}}{{operationIdCamelCase}}Request{{nameInPascalCase}} extends {{classname}}{{operationIdCamelCase}}Request { + static const specMediaType = r'{{{key}}}'; + + @override + String get contentType => specMediaType; + + final {{>types/variable_recursive}} data; + static const dataReflection = {{>types/reflection_recursive}}; + + {{#extraParameters}} + final {{>types/param}} {{paramName}}; + {{/extraParameters}} + + const {{classname}}{{operationIdCamelCase}}Request{{nameInPascalCase}}({ + required this.data, + {{#extraParameters}} + {{>types/required_ctor}} this.{{paramName}}{{>types/default}}, + {{/extraParameters}} + {{#allParams}} + {{^isFormParam}}{{^isBodyParam}} + {{>types/required_ctor}} super.{{paramName}}, + {{/isBodyParam}}{{/isFormParam}} + {{/allParams}} + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + {{#content}}{{#encoding}} + {{#entrySet}} + r'{{{key}}}': {{#value}}PropertyEncodingRule( + {{#style}}style: r'{{{style}}}',{{/style}} + {{#explode}}explode: {{explode}},{{/explode}} + {{#allowReserved}}allowReserved: {{allowReserved}},{{/allowReserved}} + {{#contentType}}contentType: MediaType.parse(r'{{{contentType}}}'),{{/contentType}} + {{#headers}}{{#-first}} + headers: { + {{/-first}} + {{>lib/src/apis/request/header_param}} + {{#-last}} + }, + {{/-last}}{{/headers}} + ),{{/value}} + {{/entrySet}} + {{/encoding}}{{/content}} + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +}{{/schema}}{{/content}}{{/better-consumes}}{{/vendorExtensions}}{{/bodyAllowed}} + +{{/operation}}{{/operations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/api_responses.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/api_responses.mustache new file mode 100644 index 000000000000..1f780e1a8f08 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/api_responses.mustache @@ -0,0 +1,327 @@ +// ignore_for_file: unnecessary_type_check, unnecessary_null_comparison, unnecessary_cast + +{{#operations}} +part of '{{classFilename}}.dart'; +{{/operations}} + +{{#operations}}{{#operation}} +{{#isDeprecated}} +@Deprecated('This operation has been deprecated') +{{/isDeprecated}} +class {{>lib/src/apis/response/response_class}} { + {{>lib/src/apis/response/response_class}}({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + {{#responses}} + required T Function({{>lib/src/apis/response/response_class_code}} response) on{{>lib/src/apis/response/code}}, + {{/responses}} + required T Function({{>lib/src/apis/response/response_class}} response) other, + }) { + return switch (this) { + {{#responses}} + {{>lib/src/apis/response/response_class_code}} response => on{{>lib/src/apis/response/code}}(response), + {{/responses}} + _ => other(this), + }; + } + + static Future<{{>lib/src/apis/response/response_class}}> fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future<{{>lib/src/apis/response/response_class}}> Function())> [ + {{#responses}} + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, {{#wildcard}}r'default'{{/wildcard}}{{^wildcard}}r'{{code}}'{{/wildcard}}), + () => {{>lib/src/apis/response/response_class_code}}.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + {{/responses}} + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return {{>lib/src/apis/response/response_class}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + +{{#responses}} + +{{#headers}} +{{#schema}}{{>lib/src/models/enum_inline_recursive}}{{/schema}} +{{^schema}}{{>lib/src/models/enum_inline_recursive}}{{/schema}} +{{/headers}} + +{{! generate a class per response code }} +{{#isDeprecated}} +@Deprecated('This operation has been deprecated') +{{/isDeprecated}} +class {{>lib/src/apis/response/response_class_code}} extends {{>lib/src/apis/response/response_class}} { + {{>lib/src/apis/response/response_class_code}}({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + {{#headers}} + {{>types/required_ctor}} this.{{name}}{{>types/default}}, + {{/headers}} + }); + + {{#headers}} + final {{>types/variable}} {{name}}; + {{/headers}} + + {{#content}} + T split{{>lib/src/apis/response/code}}({ + {{#entrySet}}{{#value}}{{#schema}} + required T Function({{>lib/src/apis/response/response_class_code_mime}} response) on{{nameInPascalCase}}, + {{/schema}}{{/value}}{{/entrySet}} + required T Function({{>lib/src/apis/response/response_class_code}} response) other, + }) { + return switch (this) { + {{#entrySet}}{{#value}}{{#schema}} + {{>lib/src/apis/response/response_class_code_mime}} response => on{{nameInPascalCase}}(response), + {{/schema}}{{/value}}{{/entrySet}} + _ => other(this), + }; + }{{/content}} + + static Future<{{>lib/src/apis/response/response_class_code}}> fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + {{#content}} + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future<{{>lib/src/apis/response/response_class_code}}> Function())>[ + {{#entrySet}} + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'{{key}}')), + () => {{#value}}{{#schema}}{{>lib/src/apis/response/response_class_code_mime}}{{/schema}}{{/value}}.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + {{/entrySet}} + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + {{/content}} + return {{>lib/src/apis/response/response_class_code}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + +{{#content}}{{#entrySet}}{{#value}} +{{#schema}}{{>lib/src/models/enum_inline_recursive}}{{/schema}} +{{^schema}}{{>lib/src/models/enum_inline_recursive}}{{/schema}} + +{{#schema}} +{{! generate a class per content per response code }} +/// Represent the response when content-type is {{key}}. +{{#isDeprecated}} +@Deprecated('This operation has been deprecated') +{{/isDeprecated}} +class {{>lib/src/apis/response/response_class_code_mime}} extends {{>lib/src/apis/response/response_class_code}} { + final UndefinedWrapper<{{>types/variable_recursive}}> body; + + static const bodyReflection = {{>types/reflection_recursive}}; + + {{#vendorExtensions}} + {{#is_mime_application_json}} + /// The raw result of calling jsonDecode + final Object? rawJson; + {{/is_mime_application_json}} + {{#is_mime_application_xml}} + /// The raw result of calling XmlDocumentFragment.parse + final XmlDocumentFragment? rawXml; + {{/is_mime_application_xml}} + {{#is_mime_text}} + /// The raw result of decoding bytes to text. + final String? rawText; + {{/is_mime_text}} + {{#is_mime_application_x-www-form-urlencoded}} + final Map? rawQueryParameters; + {{/is_mime_application_x-www-form-urlencoded}} + {{/vendorExtensions}} + + {{>lib/src/apis/response/response_class_code_mime}}({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + {{#headers}} + {{>types/required_ctor}} super.{{name}}, + {{/headers}} + {{#vendorExtensions}} + {{#is_mime_application_json}} + this.rawJson, + {{/is_mime_application_json}} + {{#is_mime_application_xml}} + this.rawXml, + {{/is_mime_application_xml}} + {{#is_mime_text}} + this.rawText, + {{/is_mime_text}} + {{#is_mime_application_x-www-form-urlencoded}} + this.rawQueryParameters, + {{/is_mime_application_x-www-form-urlencoded}} + {{/vendorExtensions}} + }); + + static Future<{{>lib/src/apis/response/response_class_code_mime}}> fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + {{#content}}{{#encoding}} + {{#entrySet}} + r'{{{key}}}': {{#value}}PropertyEncodingRule( + {{#style}}style: r'{{{style}}}',{{/style}} + {{#explode}}explode: {{explode}},{{/explode}} + {{#allowReserved}}allowReserved: {{allowReserved}},{{/allowReserved}} + {{#contentType}}contentType: MediaType.parse(r'{{{contentType}}}'),{{/contentType}} + ),{{/value}} + {{/entrySet}} + {{/encoding}}{{/content}} + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + {{#vendorExtensions}} + switch (contentType) { + {{#is_mime_application_json}} + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return {{>lib/src/apis/response/response_class_code_mime}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + {{>lib/src/apis/response/read_headers}} + ); + } else { + // since we consumed the stream, we need to publish our read result. + return {{>lib/src/apis/response/response_class_code_mime}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + {{>lib/src/apis/response/read_headers}} + ); + } + {{/is_mime_application_json}} + {{#is_mime_text}} + case MediaType(type: 'text'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = serialized; + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return {{>lib/src/apis/response/response_class_code_mime}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + {{>lib/src/apis/response/read_headers}} + ); + } else { + // since we consumed the stream, we need to publish our read result. + return {{>lib/src/apis/response/response_class_code_mime}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawText: v, + {{>lib/src/apis/response/read_headers}} + ); + } + {{/is_mime_text}} + {{#is_mime_application_xml}} + case MediaType(type: 'application', subtype: 'xml'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = XmlDocumentFragment.parse(serialized); + // check if v can be deserialized to xml + return {{>lib/src/apis/response/response_class_code_mime}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawXml: v, + {{>lib/src/apis/response/read_headers}} + ); + {{/is_mime_application_xml}} + {{#is_mime_application_x-www-form-urlencoded}} + case MediaType(type: 'application', subtype: 'x-www-form-urlencoded'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final queryParametersAll = Uri(query: serialized).queryParametersAll; + final v = queryParametersAll.map((k,v) => MapEntry(k, v.isEmpty ? null : v.length == 1 ? v.first.isEmpty ? null : v.first : v)); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return {{>lib/src/apis/response/response_class_code_mime}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + {{>lib/src/apis/response/read_headers}} + ); + } else { + // since we consumed the stream, we need to publish our read result. + return {{>lib/src/apis/response/response_class_code_mime}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawQueryParameters: v, + {{>lib/src/apis/response/read_headers}} + ); + } + {{/is_mime_application_x-www-form-urlencoded}} + default: + } + {{/vendorExtensions}} + return {{>lib/src/apis/response/response_class_code_mime}}( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + {{>lib/src/apis/response/read_headers}} + ); + } +} +{{/schema}}{{/value}}{{/entrySet}}{{/content}} +{{/responses}} +{{/operation}}{{/operations}} + + diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/request/header_param.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/request/header_param.mustache new file mode 100644 index 000000000000..3324da10bdc1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/request/header_param.mustache @@ -0,0 +1,2 @@ +{{^required}}if ({{paramName}}.isDefined){{/required}} + r'{{baseName}}': OpenApiParameterSerializationHeader(parameterName: r'{{baseName}}',explode: {{isExplode}}).serialize({{paramName}}{{^required}}.valueRequired{{/required}}), \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/code.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/code.mustache new file mode 100644 index 000000000000..56611ae5aed4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/code.mustache @@ -0,0 +1 @@ +{{#wildcard}}Default{{/wildcard}}{{^wildcard}}{{code}}{{/wildcard}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/code_example.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/code_example.mustache new file mode 100644 index 000000000000..db855a5edcef --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/code_example.mustache @@ -0,0 +1,11 @@ +{{#wildcard}}exampleContext.exampleCode(1, 599){{/wildcard}} +{{^wildcard}} + {{#range}} + {{#is1xx}}exampleContext.exampleCode(100, 200){{/is1xx}} + {{#is2xx}}exampleContext.exampleCode(200, 300){{/is2xx}} + {{#is3xx}}exampleContext.exampleCode(300, 400){{/is3xx}} + {{#is4xx}}exampleContext.exampleCode(400, 500){{/is4xx}} + {{#is5xx}}exampleContext.exampleCode(500, 600){{/is5xx}} + {{/range}} + {{^range}}{{code}}{{/range}} +{{/wildcard}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/read_headers.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/read_headers.mustache new file mode 100644 index 000000000000..c3058bdf9ba6 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/read_headers.mustache @@ -0,0 +1,3 @@ +{{#headers}} +{{name}}: {{>types/reflection}}.deserializeFunction(response.headers.getOrUndefined(r'{{baseName}}')), +{{/headers}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/response_class.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/response_class.mustache new file mode 100644 index 000000000000..9f6122301a68 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/response_class.mustache @@ -0,0 +1 @@ +{{classname}}{{operationIdCamelCase}}Response \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/response_class_code.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/response_class_code.mustache new file mode 100644 index 000000000000..070b11650c9d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/response_class_code.mustache @@ -0,0 +1 @@ +{{>lib/src/apis/response/response_class}}{{>lib/src/apis/response/code}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/response_class_code_mime.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/response_class_code_mime.mustache new file mode 100644 index 000000000000..4a6c432d8899 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/apis/response/response_class_code_mime.mustache @@ -0,0 +1 @@ +{{>lib/src/apis/response/response_class_code}}{{nameInPascalCase}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/facade.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/facade.mustache new file mode 100644 index 000000000000..4d11485aa354 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/facade.mustache @@ -0,0 +1,24 @@ +import 'package:openapi_infrastructure/openapi_infrastructure.dart'; + +import 'apis/_exports.dart'; + +/// A facade class as an entry point to the generated APIs +class {{clientName}} { + static final defaultBaseUrl = Uri.parse(r'{{{basePath}}}'); + + final NetworkingClientBase networkingClient; + final Uri baseUrl; + + {{clientName}}({ + required this.networkingClient, + Uri? baseUrl, + }) : baseUrl = defaultBaseUrl; + + + {{#apiInfo}}{{#apis}} + late final {{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}} = {{classname}}( + networkingClient: networkingClient, + baseUrl: baseUrl, + ); + {{/apis}}{{/apiInfo}} +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/_exports.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/_exports.mustache new file mode 100644 index 000000000000..37e7594b5520 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/_exports.mustache @@ -0,0 +1,2 @@ +{{#models}}{{#model}}export '{{classFilename}}.dart'; +{{/model}}{{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/class.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/class.mustache new file mode 100644 index 000000000000..22875f2c4ee1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/class.mustache @@ -0,0 +1,106 @@ +/// {{{description}}}{{^description}}{{classname}}Mixin{{/description}} +{{#hasVars}} +/// +/// Properties: +{{#vars}} +/// * [{{{name}}}] {{#description}}- {{{.}}}{{/description}} +{{/vars}} +{{/hasVars}} +{{#isDeprecated}} +@Deprecated('{{{classname}}}Mixin has been deprecated') +{{/isDeprecated}} +mixin {{classname}}Mixin on + {{#allOf}}{{.}}Mixin, {{/allOf}}$OpenApiObjectMixin { + {{#vars}}{{>types/variable}} get {{name}}; + {{/vars}} + {{#composedSchemas}}{{#oneOf}} + UndefinedWrapper<{{>types/variable_recursive_nonnullable}}> get {{name}};{{/oneOf}}{{#anyOf}} + UndefinedWrapper<{{>types/variable_recursive_nonnullable}}> get {{name}};{{/anyOf}}{{/composedSchemas}} +} + +/// {{{description}}}{{^description}}{{classname}}{{/description}} +{{#hasVars}} +/// +/// Properties: +{{#allVars}} +/// * [{{{name}}}] {{#description}}- {{{.}}}{{/description}} +{{/allVars}} +{{/hasVars}} +{{#isDeprecated}} +@Deprecated('{{{classname}}}Mixin has been deprecated') +{{/isDeprecated}} +class {{classname}} with +$OpenApiObjectMixin, +{{#allOf}}{{.}}Mixin,{{/allOf}} +{{classname}}Mixin { + {{#allVars}} + @override + {{>types/variable}} {{name}}; + {{/allVars}} + + {{#additionalProperties}} + AdditionalProperties<{{>types/variable_recursive}}> additionalProperties;{{/additionalProperties}} + + {{#composedSchemas}}{{#oneOf}} + @override + UndefinedWrapper<{{>types/variable_recursive_nonnullable}}> {{name}}; + {{/oneOf}}{{#anyOf}} + @override + UndefinedWrapper<{{>types/variable_recursive_nonnullable}}> {{name}}; + {{/anyOf}}{{/composedSchemas}} + + {{classname}}.$all({ + {{#allVars}} required this.{{name}}, + {{/allVars}} + {{#additionalProperties}}required this.additionalProperties,{{/additionalProperties}} + {{#composedSchemas}}{{#oneOf}} + required this.{{name}},{{/oneOf}}{{#anyOf}} + required this.{{name}},{{/anyOf}}{{/composedSchemas}} + }); + + {{classname}}({ + {{#allVars}}{{>types/required_ctor}} this.{{name}} {{>types/default}}, + {{/allVars}} + {{#additionalProperties}}AdditionalProperties<{{>types/variable_recursive}}>? additionalProperties,{{/additionalProperties}} + {{#composedSchemas}}{{#oneOf}} + this.{{name}} = const UndefinedWrapper.undefined(),{{/oneOf}}{{#anyOf}} + this.{{name}} = const UndefinedWrapper.undefined(), + {{/anyOf}}{{/composedSchemas}} + }){{#additionalProperties}} : additionalProperties = additionalProperties ?? {}{{/additionalProperties}}; + + static const $reflection = {{classname}}Reflection.instance; + {{classname}}Reflection get $classReflection => $reflection; + + @override + bool validate() { + {{#composedSchemas}} + {{#oneOf}}{{#-first}}final oneOfs = [{{/-first}}{{name}},{{#-last}}].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + {{/-last}}{{/oneOf}} + {{/composedSchemas}} + return super.validate(); + } + + factory {{classname}}.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + {{classname}} clone() { + return $reflection.clone(this); + } +} + +{{#vars}} +{{>lib/src/models/enum_inline_recursive}} +{{/vars}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/class.reflection.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/class.reflection.mustache new file mode 100644 index 000000000000..20c4d8973b29 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/class.reflection.mustache @@ -0,0 +1,232 @@ +//class reflection + +class {{classname}}Reflection extends ModelReflection<{{classname}}> { + static {{classname}}Reflection instanceGetter() => instance; + static const instance = {{classname}}Reflection._( + modelName: r'{{schemaName}}', + className: r'{{classname}}', + xml: {{>types/xml}}, + {{#allVars}} + {{name}}Part: PropertyReflection<{{classname}}, {{>types/variable}}>( + dartName: r'{{name}}', + nullable: {{isNullable}}, + required: {{required}}, + oasName: r'{{baseName}}', + oasType: r'{{openApiType}}', + pattern: {{#pattern}}r'{{{pattern}}}'{{/pattern}}{{^pattern}}null{{/pattern}}, + parentReflectionGetter: instanceGetter, + isDiscriminator: {{isDiscriminator}}, + xml: {{>types/xml}}, + getter: FunctionWrapper1(_{{name}}Getter), + setter: FunctionWrapper2(_{{name}}Setter), + reflection: {{>types/reflection}}, + ), + {{/allVars}} + {{#discriminator}} + discriminatorKey: r'{{{propertyBaseName}}}', + discriminatorImplicitMappings: const { + {{#allOf}} + r'{{.}}': {{.}}Reflection.instance, + {{/allOf}} + {{#oneOf}} + r'{{.}}': {{.}}Reflection.instance, + {{/oneOf}} + {{#anyOf}} + r'{{.}}': {{.}}Reflection.instance, + {{/anyOf}} + }, + discriminatorMappings: const { + {{#mappedModels}} + r'{{mappingName}}': {{modelName}}Reflection.instance, + {{/mappedModels}} + }, + {{/discriminator}} + {{#allOf}}allOf{{.}}Part: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: {{.}}Reflection.instance, + ), + {{/allOf}} + + {{#composedSchemas}}{{#oneOf}} + {{name}}Part: {{classname}}{{nameInPascalCase}}Part( + parentReflectionGetter: instanceGetter, + ), + {{/oneOf}}{{#anyOf}} + {{name}}Part: {{classname}}{{nameInPascalCase}}Part( + parentReflectionGetter: instanceGetter, + ), + {{/anyOf}}{{/composedSchemas}} + {{#additionalProperties}} + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: {{>types/reflection_recursive}}, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + {{/additionalProperties}} + ); + const {{classname}}Reflection._({ + required this.modelName, + required this.className, + required this.xml, + {{#allVars}} + required this.{{name}}Part, + {{/allVars}} + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + {{#allOf}}required this.allOf{{.}}Part, + {{/allOf}} + {{#composedSchemas}}{{#oneOf}} + required this.{{name}}Part, + {{/oneOf}}{{#anyOf}} + required this.{{name}}Part, + {{/anyOf}}{{/composedSchemas}} + {{#additionalProperties}} + required this.additionalPropertiesPart, + {{/additionalProperties}} + }); + + {{#allVars}} + final PropertyReflection<{{classname}}, {{>types/variable}}> {{name}}Part; + static {{>types/variable}} _{{name}}Getter({{classname}} parent) { + return parent.{{name}}; + } + static void _{{name}}Setter({{classname}} parent, {{>types/variable}} value) { + parent.{{name}} = value; + } + + {{/allVars}} + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + {{#allVars}}{{name}}Part, + {{/allVars}} + ]; + + {{#additionalProperties}} + @override + final AdditionalPropertiesPart<{{classname}}, {{>types/variable_recursive}}>? additionalPropertiesPart; + + static AdditionalProperties<{{>types/variable_recursive}}> _AdditionalPropertiesGetter({{classname}} instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter({{classname}} instance, AdditionalProperties<{{>types/variable_recursive}}> additionalProperties) { + instance.additionalProperties = additionalProperties; + } + {{/additionalProperties}} + + {{#allOf}}final AllOfReflection<{{classname}}, {{.}}Mixin> allOf{{.}}Part; + {{/allOf}} + + {{#composedSchemas}}{{#oneOf}} + final {{classname}}{{nameInPascalCase}}Part {{name}}Part; + {{/oneOf}}{{#anyOf}} + final {{classname}}{{nameInPascalCase}}Part {{name}}Part; + {{/anyOf}}{{/composedSchemas}} + + @override + List> get allOfs => [ + {{#allOf}}allOf{{.}}Part,{{/allOf}} + ]; + + {{#composedSchemas}} + @override + List> get oneOfs => [ + {{#oneOf}}{{name}}Part,{{/oneOf}} + ]; + @override + List> get anyOfs => [ + {{#anyOf}}{{name}}Part,{{/anyOf}} + ]; + {{/composedSchemas}} + + + /// Creates an empty instance used as a starting point for deserialization. + @override + {{classname}} empty() { + return {{classname}}( + {{#allVars}} + {{#required}} + {{name}}: {{name}}Part.reflection.emptyFunction(), + {{/required}} + {{/allVars}} + ); + } + + @override + bool operator ==(Object other) { + return other is {{classname}}Reflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + +{{#composedSchemas}}{{#oneOf}} +class {{classname}}{{nameInPascalCase}}Part extends OneOfReflection<{{classname}}, {{>types/variable_recursive_nonnullable}}> { + + {{>lib/src/models/reflection/oneof_anyof_common}} + + UndefinedWrapper<{{>types/variable_recursive_nonnullable}}> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + {{#-first}} + // An example SHOULD be generated + {{/-first}} + {{^-first}} + return UndefinedWrapper.undefined(); + {{/-first}} + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} +{{/oneOf}} +{{#anyOf}} +class {{classname}}{{nameInPascalCase}}Part extends AnyOfReflection<{{classname}}, {{>types/variable_recursive_nonnullable}}> { + + {{>lib/src/models/reflection/oneof_anyof_common}} + + UndefinedWrapper<{{>types/variable_recursive_nonnullable}}> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} +{{/anyOf}} +{{/composedSchemas}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/enum.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/enum.mustache new file mode 100644 index 000000000000..a2753b3989ac --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/enum.mustache @@ -0,0 +1,51 @@ +//enum def + +extension type const {{{classname}}}._({{dataType}} value) implements {{dataType}} { + {{#allowableValues}} + {{#enumVars}} + {{#description}} + /// {{{.}}} + {{/description}} + const {{{classname}}}.{{name}}() : this._({{#isString}}r{{/isString}}{{{value}}}); + {{/enumVars}} + {{/allowableValues}} + + /// Creates a [{{{classname}}}] enum from a value and safely checking if it exists. + factory {{{classname}}}.$safe({{dataType}} value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.for{{dataType}}, + members: [ + {{#allowableValues}}{{#enumVars}} + EnumMemberReflection(dartName: r'{{name}}', oasValue: {{#isString}}r{{/isString}}{{{value}}}, value: {{{classname}}}.{{name}}()), + {{/enumVars}}{{/allowableValues}} + ], + ); + + factory {{{classname}}}.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [{{{classname}}}] enum from a value without checking if it exists. + const {{{classname}}}.$unsafe({{dataType}} value) : this._(value); + + /// All possible values of the enum. + static const List<{{{classname}}}> values = [ + {{#allowableValues}}{{#enumVars}}{{{classname}}}.{{name}}(), + {{/enumVars}}{{/allowableValues}} + ]; +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/enum_inline.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/enum_inline.mustache new file mode 100644 index 000000000000..e6f67e95c86c --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/enum_inline.mustache @@ -0,0 +1,49 @@ +extension type const {{{enumName}}}._({{dataType}} value) implements {{dataType}} { + {{#allowableValues}} + {{#enumVars}} + {{#description}} + /// {{{.}}} + {{/description}} + const {{{enumName}}}.{{name}}() : this._({{#isString}}r{{/isString}}{{{value}}}); + {{/enumVars}} + {{/allowableValues}} + + /// Creates a [{{{enumName}}}] enum from a value and safely checking if it exists. + factory {{{enumName}}}.$safe({{dataType}} value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection<{{{enumName}}}, {{dataType}}>( + PrimitiveReflection.for{{dataType}}, + members: [ + {{#allowableValues}}{{#enumVars}} + EnumMemberReflection(dartName: r'{{name}}', oasValue: {{#isString}}r{{/isString}}{{{value}}}, value: {{{enumName}}}.{{name}}()), + {{/enumVars}}{{/allowableValues}} + ], + ); + + factory {{{enumName}}}.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [{{enumName}}] enum from a value without checking if it exists. + const {{enumName}}.$unsafe({{dataType}} value) : this._(value); + + /// All possible values of the enum. + static const List<{{enumName}}> values = [ + {{#allowableValues}}{{#enumVars}}{{enumName}}.{{name}}(), + {{/enumVars}}{{/allowableValues}} + ]; +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/enum_inline_recursive.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/enum_inline_recursive.mustache new file mode 100644 index 000000000000..48a89117f861 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/enum_inline_recursive.mustache @@ -0,0 +1,2 @@ +{{#items}}{{>lib/src/models/enum_inline_recursive}}{{/items}} +{{^items}}{{#enumName}}{{^isModel}}{{>lib/src/models/enum_inline}}{{/isModel}}{{/enumName}}{{/items}} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/model.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/model.mustache new file mode 100644 index 000000000000..3c24e6bb2912 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/model.mustache @@ -0,0 +1,10 @@ +// Model def + +import 'package:{{pubName}}/_internal.dart'; + + +{{#models}}{{#model}}part '{{classFilename}}.reflection.dart'; +{{/model}}{{/models}} + +{{#models}}{{#model}}{{#isEnum}}{{>lib/src/models/enum}}{{/isEnum}}{{^isEnum}}{{>lib/src/models/class}} +{{/isEnum}}{{/model}}{{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/model.reflection.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/model.reflection.mustache new file mode 100644 index 000000000000..9b988389e4ed --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/model.reflection.mustache @@ -0,0 +1,6 @@ +// Model reflection + +{{#models}}{{#model}}part of '{{classFilename}}.dart'; +{{/model}}{{/models}} + +{{#models}}{{#model}}{{^isEnum}}{{>lib/src/models/class.reflection}}{{/isEnum}}{{/model}}{{/models}} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/reflection/oneof_anyof_common.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/reflection/oneof_anyof_common.mustache new file mode 100644 index 000000000000..2fe2ff407d88 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/models/reflection/oneof_anyof_common.mustache @@ -0,0 +1,22 @@ +const {{classname}}{{nameInPascalCase}}Part({ + required {{classname}}Reflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1types/variable_recursive_nonnullable}}>, {{classname}}> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2types/variable_recursive_nonnullable}}>> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper<{{>types/variable_recursive_nonnullable}}> _getter({{classname}} src) { + return src.{{name}}; +} +static void _setter({{classname}} src, UndefinedWrapper<{{>types/variable_recursive_nonnullable}}> value) { + src.{{name}} = value; +} + +@override +UndefinedWrapperReflection<{{>types/variable_recursive_nonnullable}}> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: {{>types/xml}}, + {{>types/reflection_recursive_nonnullable}} + ), +); \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/_exports.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/_exports.mustache new file mode 100644 index 000000000000..e84060708f8d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/_exports.mustache @@ -0,0 +1,4 @@ +export 'package_http_client.dart'; +export 'property_encoding_rule.dart'; +export 'multipart.dart'; +export 'wire_serialization_options.dart'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/_internal.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/_internal.mustache new file mode 100644 index 000000000000..48a03674a96b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/_internal.mustache @@ -0,0 +1,3 @@ +export '_exports.dart'; + +export 'helpers.dart'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/helpers.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/helpers.mustache new file mode 100644 index 000000000000..ccf709a54f5e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/helpers.mustache @@ -0,0 +1,211 @@ +import 'package:collection/collection.dart'; +import 'package:{{pubName}}/_internal.dart'; + +enum PatternMatchResult { + exact, + partial, + fail, +} + +extension PatternMatchResultHelper on Iterable<(PatternMatchResult, T)> { + T? pickPrioritized() { + return this + .where((a) => a.$1 != PatternMatchResult.fail) + .sortedByCompare((x) => x.$1, Enum.compareByIndex) + .firstOrNull + ?.$2; + } +} + + +class OASNetworkingUtils { + /// Serializes dart primitives into a byte stream based on mime type. + /// + /// This is an opinionated best-effort function that will try to serialize + /// common objects into common mime type formats. + /// + /// If the target mime type is a text-based mime type (e.g. application/json + /// or application/xml), then the [src] object will be serialized to string + /// and then encoded based on [targetMediaType]'s `charset` parameter. + /// + /// If the target mime type is NOT a text-based mime type, then the [src] object + /// MUST be either a Stream> or [Uint8List] or [XFile] and it will be + /// sent as-is. + static Stream> serializeToWire( + Object? src, + MediaType targetMediaType, { + WireSerializationOptions? options, + }) async* { + options ??= WireSerializationOptions(); + if (options.isTextBased(targetMediaType, options)) { + final string = + await serializeToString(src, targetMediaType, options: options); + final encoding = getEncodingOrDefault(targetMediaType); + yield encoding.encode(string); + } else { + if (src is Stream>) { + yield* src; + } else if (src is Uint8List) { + yield src; + } else if (src is XFile) { + yield* src.openRead(); + } else { + throw UnsupportedError( + 'Object of type $src can not be serialized to mime type ($targetMediaType)', + ); + } + } + } + + static Future serializeToString( + Object? src, + MediaType targetMediaType, { + WireSerializationOptions? options, + }) async { + options ??= WireSerializationOptions(); + if (options.isXml(targetMediaType)) { + if (src is! XmlHasWriter) { + throw ArgumentError.value( + src, + 'src', + 'only XmlNode can be serialized to xml.', + ); + } + return src.toXmlString(); + } else if (options.isJson(targetMediaType)) { + return jsonEncode(src, toEncodable: options.toEncodable); + } else if (options.isFormUrlEncoded(targetMediaType)) { + if (src is! Map) { + throw ArgumentError.value( + src, + 'src', + 'Only Map can be serializd ' + 'to application/x-www-form-urlencoded', + ); + } + return formUrlEncoded(src, options.encodingRules ?? {}); + } else { + // by default, call toString. + return src?.toString() ?? ''; + } + } + + /// Deserializes a byte stream to dart primitives based on mime type. + /// + /// if the deserialization is not possible, returns a Stream. + static Future deserializeFromWire( + Stream src, + MediaType targetMediaType, { + WireSerializationOptions? options, + }) async { + options ??= WireSerializationOptions(); + if (options.isTextBased(targetMediaType, options)) { + final encoding = getEncodingOrDefault(targetMediaType); + final decoded = await encoding.decodeStream(src); + return await deserializeFromString(decoded, targetMediaType); + } else { + return src; + } + } + + static Future deserializeFromString( + String src, + MediaType targetMediaType, { + WireSerializationOptions? options, + }) async { + // + options ??= WireSerializationOptions(); + if (options.isXml(targetMediaType)) { + return XmlDocumentFragment.parse(src); + } else if (options.isJson(targetMediaType)) { + return jsonDecode(src); + } else if (options.isFormUrlEncoded(targetMediaType)) { + return Uri(query: src).queryParametersAll; + } else { + // by default, return src as is. + return src; + } + } + + static bool isMediaTypeSerializable(MediaType mediaType) { + if (mediaType + case MediaType(type: 'application', subtype: 'json') || + MediaType(type: 'application', subtype: 'xml') || + MediaType(type: 'text') || + MediaType(type: 'application', subtype: 'x-www-form-urlencoded')) { + return true; + } + return false; + } + + static String formUrlEncoded(Map serialized, + Map encodingRules) { + var result = Uri(); + + for (var e in serialized.entries) { + final rule = encodingRules[e.key]; + final style = rule?.style ?? 'form'; + final explode = rule?.explode ?? (style == 'form'); + result = OpenApiParameterSerializationQuery.fromStyle( + style, + explode: explode, + parameterName: e.key, + allowEmptyValue: false, + ).expandUri(result, e.value); + } + var resultString = result.query.toString(); + if (resultString.startsWith('?')) { + resultString = resultString.substring(1); + } + return resultString; + } + + static Encoding getEncodingOrDefault(MediaType contentType) { + final charset = contentType.parameters['charset'] ?? 'utf-8'; + return Encoding.getByName(charset) ?? utf8; + } + + static PatternMatchResult matchesStatusCodePattern( + int statusCode, + String pattern, + ) { + // Normalize the pattern + pattern = pattern.toUpperCase(); + if (pattern == 'DEFAULT') { + return PatternMatchResult.partial; + } + final parsedPattern = int.tryParse(pattern); + if (parsedPattern != null) { + return parsedPattern == statusCode + ? PatternMatchResult.exact + : PatternMatchResult.fail; + } + final removePlaceHolders = pattern.replaceAll('X', ''); + return statusCode.toString().startsWith(removePlaceHolders) + ? PatternMatchResult.partial + : PatternMatchResult.fail; + } + + static PatternMatchResult matchesContentTypePattern( + MediaType contentType, + MediaType pattern, + ) { + switch (pattern) { + case MediaType(type: '*', subtype: '*'): + return PatternMatchResult.partial; + case MediaType(type: final type, subtype: '*'): + if (type == contentType.type) { + return PatternMatchResult.partial; + } + case MediaType(type: '*', subtype: final subtype): + if (subtype == contentType.subtype) { + return PatternMatchResult.partial; + } + case MediaType(type: final type, subtype: final subtype): + if (contentType.type == type && contentType.subtype == subtype) { + return PatternMatchResult.exact; + } + } + return PatternMatchResult.fail; + } +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/multipart.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/multipart.mustache new file mode 100644 index 000000000000..c7e991accc75 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/multipart.mustache @@ -0,0 +1,171 @@ +import 'package:{{pubName}}/_internal.dart'; + +typedef UnknownMediaTypeHandler = Stream> Function(MediaType mediaType, Object? serialized, Encoding encoding, Map encodingRules); + +typedef AppendFormDataPartHandler = Stream Function( + String fieldName, + Object? value, + MediaType? contentType, + Map? headers, +); +typedef AppendPartHandler = Stream Function( + Object? value, + MediaType? contentType, + Map? headers, +); + +Stream defaultAppendFormDataPart( + String fieldName, + Object? value, + MediaType? contentType, + Map? headers, +) async* { + yield MultiPartFormDataFieldHttpPacket( + field: fieldName, + value: value.toString(), + extraHeaders: headers, + ); +} +Stream defaultAppendPart( + Object? value, + MediaType? contentType, + Map? headers, +) async* { + yield HttpPacketMixin.memory( + bodyBytes: utf8.encode(jsonEncode(value)), + headers: { + 'Content-Type': 'application/json', + ...?headers, + }, + ); +} + +Stream appendFormDataValue( + String fieldName, + Object? value, + MediaType? contentType, + Map? headers, { + AppendFormDataPartHandler unkownHandler = defaultAppendFormDataPart, +}) async* { + switch (value) { + case Uint8List(): + yield MultiPartFormDataFileHttpPacket( + field: fieldName, + bodyBytesStream: Stream.value(value), + mimeType: contentType?.toString(), + fileSize: value.lengthInBytes, + extraHeaders: headers, + ); + case XFile(): + yield MultiPartFormDataFileHttpPacket( + field: fieldName, + bodyBytesStream: value.openRead(), + mimeType: contentType?.toString() ?? value.mimeType, + fileSize: await value.length(), + fileName: value.name, + extraHeaders: headers, + ); + + case String(): + case num(): + yield MultiPartFormDataFieldHttpPacket( + field: fieldName, + value: value.toString(), + extraHeaders: headers, + ); + case Iterable(): + for (var child in value) { + yield* appendFormDataValue( + fieldName + '[]', + child, + contentType, + headers, + unkownHandler: unkownHandler, + ); + } + case Map(): + for (var entry in value.entries) { + // We can either serialize the value as json, or flatten it as a form data. + yield* appendFormDataValue( + fieldName + '[' + entry.key + ']', + entry.value, + contentType, + headers, + unkownHandler: unkownHandler, + ); + } + // DateTime implementation is left to the user in the unkownHandler. + case DateTime(): + default: + yield* unkownHandler( + fieldName, + value, + contentType, + headers, + ); + } +} + +Stream appendPartValue( + Object? value, + MediaType? contentType, + Map? headers, { + AppendPartHandler unkownHandler = defaultAppendPart, +}) async* { + switch (value) { + case Uint8List(): + yield HttpPacketMixin.memory( + bodyBytes: value, + headers: { + 'Content-Type': contentType?.toString() ?? 'application/octet-stream', + ...?headers + }, + ); + case XFile(): + yield HttpPacketMixin.stream( + bodyBytesStream: value.openRead(), + headers: { + 'Content-Disposition': 'attachment; filename="${value.name}"', + 'Content-Type': contentType?.toString() ?? value.mimeType ?? 'application/octet-stream', + ...?headers, + }, + contentLength: await value.length(), + ); + case String(): + case num(): + yield HttpPacketMixin.memory( + bodyBytes: utf8.encode(value.toString()), + headers: { + 'Content-Type': contentType?.toString() ?? 'text/plain', + ...?headers + }, + ); + case Iterable(): + for (var child in value) { + yield* appendPartValue( + child, + contentType, + headers, + unkownHandler: unkownHandler, + ); + } + case Map(): + for (var entry in value.entries) { + // We can either serialize the value as json, or flatten it as a form data. + yield* appendPartValue( + entry.value, + contentType, + headers, + unkownHandler: unkownHandler, + ); + } + // DateTime implementation is left to the user in the unkownHandler. + case DateTime(): + default: + yield* unkownHandler( + value, + contentType, + headers, + ); + } +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/package_http_client.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/package_http_client.mustache new file mode 100644 index 000000000000..f3d9edb7d9d7 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/package_http_client.mustache @@ -0,0 +1,45 @@ +import 'package:openapi_infrastructure/openapi_infrastructure.dart'; +import 'package:http/http.dart' as http; + + +class PackageHttpNetworkingClient extends NetworkingClientBase { + final http.Client client; + + PackageHttpNetworkingClient({ + http.Client? client, + }) : client = client ?? http.Client(); + + @override + Future sendRequest(HttpRequestBase request) async { + final mappedRequest = _BaseRequestWrapper(request); + final response = await client.send(mappedRequest); + + return HttpResponseBase.stream( + originalRequest: request, + context: request.context, + headers: request.headers, + bodyBytesStream: response.stream, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + ); + } +} + +class _BaseRequestWrapper extends http.BaseRequest { + _BaseRequestWrapper(this.request) : super(request.method, request.url) { + for (var element in request.headers.entries) { + headers[element.key] = element.value; + } + if (request is MemoryHttpRequest) { + contentLength = (request as MemoryHttpRequest).bodyBytes.length; + } + } + + final HttpRequestBase request; + + @override + http.ByteStream finalize() { + super.finalize(); + return http.ByteStream(request.bodyBytesStream); + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/property_encoding_rule.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/property_encoding_rule.mustache new file mode 100644 index 000000000000..5814ee0a1041 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/property_encoding_rule.mustache @@ -0,0 +1,17 @@ +import 'package:{{pubName}}/_internal.dart'; + +class PropertyEncodingRule { + final String? style; + final bool? explode; + final bool? allowReserved; + final MediaType? contentType; + final Map headers; + + const PropertyEncodingRule({ + this.style, + this.explode, + this.allowReserved, + this.contentType, + this.headers = const {} + }); +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/wire_serialization_options.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/wire_serialization_options.mustache new file mode 100644 index 000000000000..b8a9f393aeee --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/networking/wire_serialization_options.mustache @@ -0,0 +1,226 @@ +import 'package:{{pubName}}/_internal.dart'; + +/// Options to control serialization of dart objects to wire formats. +/// The main target of this class is figuring out what wire format and serialization context to use +/// for a given mime type. +class WireSerializationOptions { + const WireSerializationOptions({ + this.isJson = defaultIsJson, + this.isXml = defaultIsXml, + this.isFormUrlEncoded = defaultIsFormUrlEncoded, + this.isMultiPart = defaultIsMultiPart, + this.isMultiPartFormData = defaultIsMultiPartFormData, + this.isTextBased = defaultIsTextBased, + this.toEncodable, + this.encodingRules = const {}, + this.handleUnkownMediaType, + this.appendUnkownPart = defaultAppendPart, + this.appendUnkownFormDataPart = defaultAppendFormDataPart, + }); + + final Object? Function(Object? src)? toEncodable; + final Map encodingRules; + final bool Function(MediaType mediaType) isJson; + final bool Function(MediaType mediaType) isXml; + final bool Function(MediaType mediaType) isFormUrlEncoded; + final bool Function(MediaType mediaType) isMultiPart; + final bool Function(MediaType mediaType) isMultiPartFormData; + final bool Function(MediaType mediaType, WireSerializationOptions options) + isTextBased; + + /// Pass this to handle serialization and encoding of unkown media types yourself. + final UnknownMediaTypeHandler? handleUnkownMediaType; + + /// Only useful in multipart requests. + /// + /// Pass this to handle serialization of unkown parts yourself. + /// A value can result in one or more parts. + /// returning an empty iterable will skip the part entirely. + /// + /// The default behavior is to call [defaultAppendPart] which will call `jsonEncode` + /// to stringify the value. + final AppendPartHandler appendUnkownPart; + + /// Only useful in multipart formdata requests. + /// + /// Pass this to handle serialization of unkown form data values yourself. + /// A value can result in one or more parts. + /// returning an empty iterable will skip the field entirely. + /// + /// The default behavior is to call [defaultAppendFormDataPart] which will call `.toString` + /// to stringify the value. + final AppendFormDataPartHandler appendUnkownFormDataPart; + + WireSerializationOptions withEncodingRules( + Map rules) { + return copyWith(encodingRules: rules); + } + + WireSerializationOptions copyWith({ + Object? Function(Object? src)? toEncodable, + Map? encodingRules, + bool Function(MediaType mediaType)? isJson, + bool Function(MediaType mediaType)? isXml, + bool Function(MediaType mediaType)? isFormUrlEncoded, + bool Function(MediaType mediaType)? isMultiPart, + bool Function(MediaType mediaType)? isMultiPartFormData, + bool Function(MediaType mediaType, WireSerializationOptions options)? + isTextBased, + AppendPartHandler? appendUnkownPart = defaultAppendPart, + AppendFormDataPartHandler? appendUnkownFormDataPart, + }) { + return WireSerializationOptions( + toEncodable: toEncodable ?? this.toEncodable, + encodingRules: encodingRules ?? this.encodingRules, + isJson: isJson ?? this.isJson, + isXml: isXml ?? this.isXml, + isFormUrlEncoded: isFormUrlEncoded ?? this.isFormUrlEncoded, + isMultiPart: isMultiPart ?? this.isMultiPart, + isMultiPartFormData: isMultiPartFormData ?? this.isMultiPartFormData, + isTextBased: isTextBased ?? this.isTextBased, + appendUnkownPart: appendUnkownPart ?? this.appendUnkownPart, + appendUnkownFormDataPart: + appendUnkownFormDataPart ?? this.appendUnkownFormDataPart, + ); + } + + SerializationContext createSerializationContext(MediaType mediaType) { + if (isXml(mediaType)) { + return SerializationContext.xml(); + } + return SerializationContext.json(); + } + + /// True if the entire message can be represented textually. + static bool defaultIsTextBased( + MediaType mediaType, WireSerializationOptions options) { + return mediaType.type == 'text' || + options.isJson(mediaType) || + options.isXml(mediaType) || + options.isFormUrlEncoded(mediaType); + } + + static bool defaultIsJson(MediaType mediaType) { + if (mediaType case MediaType(subtype: 'json')) { + return true; + } + + if (mediaType.subtype.endsWith('+json')) { + return true; + } + return false; + } + + static bool defaultIsXml(MediaType mediaType) { + // covers text/xml and application/xml + if (mediaType case MediaType(subtype: 'xml')) { + return true; + } + if (mediaType.subtype.endsWith('+xml')) { + return true; + } + return false; + } + + static bool defaultIsFormUrlEncoded(MediaType mediaType) { + if (mediaType + case MediaType(type: 'application', subtype: 'x-www-form-urlencoded')) { + return true; + } + return false; + } + + static bool defaultIsMultiPart(MediaType mediaType) { + return mediaType.type == 'multipart'; + } + + static bool defaultIsMultiPartFormData(MediaType mediaType) { + return mediaType.type == 'multipart' && mediaType.subtype == 'form-data'; + } + + Stream> getBodyFromSerialized({ + required Map headers, + required Object? serialized, + required MediaType resolvedMediaType, + }) async* { + final encoding = OASNetworkingUtils.getEncodingOrDefault(resolvedMediaType); + Stream> _stringResult(String? src) { + if (src == null) { + return Stream.empty(); + } + return Stream.value(encoding.encode(src)); + } + + if (isJson(resolvedMediaType)) { + yield* _stringResult(json.encode(serialized, toEncodable: toEncodable)); + } else if (isXml(resolvedMediaType)) { + if (serialized is XmlHasWriter) { + yield* _stringResult(serialized.toXmlString()); + } + } else if (isFormUrlEncoded(resolvedMediaType)) { + if (serialized is! Map) { + yield* _stringResult(serialized.toString()); + return; + } + yield* _stringResult( + OASNetworkingUtils.formUrlEncoded(serialized, encodingRules)); + } else if (isMultiPart(resolvedMediaType)) { + if (serialized is! Map) { + throw ArgumentError( + 'The serialized data must be a map in a multipart request.'); + } + + Stream getParts() async* { + if (isMultiPartFormData(resolvedMediaType)) { + for (final e in serialized.entries) { + final fieldName = e.key; + final rule = encodingRules[e.key]; + final value = e.value; + final contentType = rule?.contentType; + final headers = rule?.headers; + yield* appendFormDataValue(fieldName, value, contentType, headers, + unkownHandler: appendUnkownFormDataPart); + } + } else { + for (final e in serialized.entries) { + final key = e.key; + final value = e.value; + final rule = encodingRules[key]; + final contentType = rule?.contentType; + final headers = rule?.headers; + //key is meaningless here + yield* appendPartValue(value, contentType, headers, + unkownHandler: appendUnkownPart); + } + } + } + + final bodySerializer = MultiPartBodySerializer( + boundary: resolvedMediaType.parameters['boundary'], + parts: getParts(), + ); + final result = await bodySerializer.serialize(); + yield* result.bodyBytesStream; + } else { + if (serialized is Stream>) { + yield* serialized; + return; + } + if (serialized is Uint8List) { + yield* Stream.value(serialized); + return; + } + if (serialized is XFile) { + yield* serialized.openRead(); + return; + } + final handleUnkownMediaType = this.handleUnkownMediaType; + if (handleUnkownMediaType != null) { + yield* handleUnkownMediaType( + resolvedMediaType, serialized, encoding, encodingRules); + return; + } + yield* _stringResult(serialized.toString()); + } + } +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/_exports.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/_exports.mustache new file mode 100644 index 000000000000..6ed187f69f7a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/_exports.mustache @@ -0,0 +1,3 @@ +export 'additional_properties.dart'; +export 'open_api_object.dart'; +export 'parameter_serialization.dart'; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/_internal.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/_internal.mustache new file mode 100644 index 000000000000..d2c030169004 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/_internal.mustache @@ -0,0 +1,28 @@ +export '_exports.dart'; + +export 'reflection.dart'; +export 'xml_reflection.dart'; +export 'context.dart'; +export 'json_extensions.dart'; +export 'xml_extensions.dart'; +export 'examples.dart'; +export 'primitive_reflection.dart'; +export 'model_reflection.dart'; +export 'container_reflection.dart'; +export 'generated_reflections.dart'; + +Never throwArgumentMismatch(Type type, Object? value) { + throw ArgumentError.value(value, 'value', + 'Value was expected to be of type ($type), but instead was of type (${value.runtimeType})'); +} + +Never throwArgumentRequired(String name) { + throw ArgumentError.value(name, 'name', 'Value was required, but its value was undefined'); +} + +TOther? ifNotNull(T? src, TOther? Function(T) fn) { + if (src == null) { + return null; + } + return fn(src); +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/additional_properties.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/additional_properties.mustache new file mode 100644 index 000000000000..b34391eb3a90 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/additional_properties.mustache @@ -0,0 +1,122 @@ +import 'package:{{pubName}}/_internal.dart'; +typedef $FreeFormObject = Map; +typedef AdditionalProperties = Map; + +extension OASMapExtensions on Map { + Map except(Set toRemove) => + Map.fromEntries(entries.where((e) => !toRemove.contains(e.key))); +} + +/// Mixin to mark objects as having additional properties. +mixin AdditionalPropertiesMixin on $OpenApiObjectMixin { + /// A special field containing properties that are not explicitly defined by the schema, + /// but are included in the serialization process. + /// + /// These are NOT considered a separate field, but rather an extension of the schema. + AdditionalProperties get additionalProperties; +} + +/// An openapi object that has no known properties. +class UnknownOpenApiObject + with $OpenApiObjectMixin, AdditionalPropertiesMixin { + UnknownOpenApiObject({ + AdditionalProperties? additionalProperties, + }) : additionalProperties = additionalProperties ?? {}; + + AdditionalProperties additionalProperties; + + Object? serialize([ + SerializationContext context = const SerializationContext.json(), + ]) { + return $classReflection.serialize(this); + } + + @override + UnknownOpenApiObjectReflection get $classReflection => + const UnknownOpenApiObjectReflection(); + + static Object? serializeInstance( + UnknownOpenApiObject src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src.serialize(context); + } + + static bool canDeserialize( + Object? src, [ + SerializationContext = const SerializationContext.json(), + ]) { + return true; + } + + static UnknownOpenApiObject deserialize( + Object? src, [ + SerializationContext = const SerializationContext.json(), + ]) { + return UnknownOpenApiObject( + additionalProperties: src is Map ? src : {}, + ); + } +} + +class UnknownOpenApiObjectReflection + extends ModelReflection { + const UnknownOpenApiObjectReflection(); + + @override + String get className => 'UnkownOpenApiObject'; + + @override + AdditionalPropertiesPart? + get additionalPropertiesPart => AdditionalPropertiesPart( + getter: FunctionWrapper1(additionalPropertiesGetter), + setter: FunctionWrapper2(additionalPropertiesSetter), + itemReflection: NullableReflection(ObjectReflection()), + parentReflectionGetter: () => this, + ); + + Map additionalPropertiesGetter(UnknownOpenApiObject src) { + return src.additionalProperties; + } + + void additionalPropertiesSetter( + UnknownOpenApiObject src, + Map value, + ) { + src.additionalProperties = value; + } + + @override + Map get discriminatorImplicitMappings => {}; + + @override + String? get discriminatorKey => null; + + @override + Map get discriminatorMappings => {}; + + @override + UnknownOpenApiObject empty() { + return UnknownOpenApiObject( + additionalProperties: {}, + ); + } + + @override + UnknownOpenApiObject example([ExampleContext? context]) { + return UnknownOpenApiObject( + additionalProperties: + const MapReflection(NullableReflection(ObjectReflection())).example(context), + ); + } + + @override + String get modelName => ''; + + @override + List> get properties => + const []; + + @override + XmlReflection get xml => XmlReflection(); +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/container_reflection.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/container_reflection.mustache new file mode 100644 index 000000000000..349546c2b4eb --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/container_reflection.mustache @@ -0,0 +1,658 @@ +import 'package:{{pubName}}/_internal.dart'hide e; + +import 'package:collection/collection.dart'; + +const $FreeFormObjectReflection = + MapReflection(NullableReflection(ObjectReflection())); + +extension SerializationReflectionExtensions on SerializationReflection { + ModelReflection? getNearestModelReflection({ + bool Function(ContainerReflection reflection) shouldVisitChildOf = + defaultShouldVisitChildOf, + }) { + return getNearestReflectionOfType(shouldVisitChildOf: shouldVisitChildOf); + } + /// searches serialization reflection tree to find a reflection that matches a given type. + TReflection? getNearestReflectionOfType< + TReflection extends SerializationReflection>({ + bool Function(ContainerReflection reflection) shouldVisitChildOf = + defaultShouldVisitChildOf, + }) { + return getNearestReflectionWhere( + (reflection) => reflection is TReflection, + shouldVisitChildOf: shouldVisitChildOf, + ) as TReflection?; + } + + static bool defaultShouldVisitChildOf( + ContainerReflection containerReflection) { + return containerReflection is! ListReflection && + containerReflection is! SetReflection && + containerReflection is! MapReflection; + } + + SerializationReflection? getNearestReflectionWhere( + bool Function(SerializationReflection reflection) predicate, { + bool Function(ContainerReflection reflection) shouldVisitChildOf = + defaultShouldVisitChildOf, + }) { + SerializationReflection current = this; + while (true) { + if (predicate(current)) { + return current; + } + if (current is ContainerReflection && shouldVisitChildOf(current)) { + current = current.subReflection; + continue; + } + return null; + } + } +} + +abstract class ContainerReflection extends PrimitiveReflection { + const ContainerReflection(this.subReflection); + + final SerializationReflection subReflection; +} + +class MapReflection extends ContainerReflection, T> { + const MapReflection(super.subReflection); + + @override + Equality> get equality => MapEquality( + keys: PrimitiveReflection.forString.equality, + values: subReflection.equality, + ); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is Map && + src.values + .every((v) => subReflection.canDeserializeFunction(v, context)), + onXml: (context) { + if (src is! XmlNode) { + return false; + } + final srcNormalized = src.readNormalized(); + return srcNormalized.entries + .where( + (element) => element.key != null, + ) + .every( + (element) => subReflection.canDeserializeFunction( + element.value, + context.withOasNameContainer( + OasNameWrapper(oasName: element.key!), + ), + ), + ); + }, + ); + } + + @override + Map deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => (src as Map).map((key, value) => + MapEntry(key, subReflection.deserializeFunction(value, context))), + onXml: (context) { + final srcNormalized = (src as XmlNode).readNormalized(); + return Map.fromEntries( + srcNormalized.entries + .where( + (element) => element.key != null, + ) + .map( + (e) => MapEntry( + e.key!, + subReflection.deserializeFunction( + e.value, + context + .withOasNameContainer(OasNameWrapper(oasName: e.key!)), + ), + ), + ) + .where((e) => e.value != UndefinedWrapper.$undefinedToken), + ); + }, + ); + } + + @override + Object? serialize( + Map src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) { + return Map.fromEntries( + src.entries + .where((e) => e.value != UndefinedWrapper.$undefinedToken) + .map( + (e) => MapEntry( + e.key, + subReflection.serializeFunction(e.value, context), + ), + ), + ); + }, + onXml: (context) { + final wrapped = src.entries + .where((e) => e.value != UndefinedWrapper.$undefinedToken) + .map( + (e) => MapEntry( + e.key, + subReflection.serializeFunction( + e.value, + context.withOasNameContainer(OasNameWrapper(oasName: e.key)), + ), + ), + ) + .map( + (e) => context.wrapSerializedValue( + keyReflection: null, + XmlName( + e.key, + ), + e.value, + ), + ); + + return XmlDocumentFragment(wrapped); + }, + ); + } + + @override + Map empty() => {}; + + @override + Map example([ExampleContext? context]) { + context ??= ExampleContext(); + return Map.fromEntries( + (ListReflection(subReflection).exampleFunction(context)) + .map((e) => MapEntry(const StringReflection().example(context), e)), + ); + } + + @override + Map clone(Map src) { + return Map.of(src); + } +} + +class ListReflection extends ContainerReflection, T> { + const ListReflection(super.subReflection); + @override + Equality> get equality => ListEquality(subReflection.equality); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is Iterable && + src.every((v) => subReflection.canDeserializeFunction(v, context)), + onXml: (context) => (src is XmlNode && + src.childElements.every( + (v) => subReflection.canDeserializeFunction(v, context), + )), + ); + } + + @override + List deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => (src as Iterable) + .map((value) => subReflection.deserializeFunction(value, context)) + .where((x) => x != UndefinedWrapper.$undefinedToken) + .toList(), + onXml: (context) { + final node = src as XmlNode; + final children = node.children; + return children + .map((v) => subReflection.deserializeFunction(v, context)) + .where((x) => x != UndefinedWrapper.$undefinedToken) + .toList(); + }, + ); + } + + @override + Object? serialize( + List src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final mapped = src + .where((x) => x != UndefinedWrapper.$undefinedToken) + .map((value) => subReflection.serializeFunction(value, context)); + return context.split( + onJson: (context) { + return mapped.toList(); + }, + onXml: (context) { + final xml = context.xmlContainer?.xml ?? XmlReflection(); + final listName = + xml.getQualifiedName(context.oasNameContainer?.oasName ?? 'list'); + final wrapped = mapped.map( + (e) => context.wrapSerializedValue( + keyReflection: xml, + listName, + e, + ), + ); + return XmlDocumentFragment(wrapped); + }, + ); + } + + @override + List empty() => []; + + @override + List example([ExampleContext? context]) { + context ??= ExampleContext(); + return List.generate( + context.random.nextInt(10), + (_) => subReflection.exampleFunction(context), + ); + } + + @override + List clone(Iterable src) { + return List.of(src); + } +} + +class SetReflection extends ContainerReflection, T> { + const SetReflection(super.subReflection); + + @override + Equality> get equality => SetEquality(subReflection.equality); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return ListReflection(subReflection).canDeserialize(src, context); + } + + @override + Set deserialize(Object? src, + [SerializationContext context = const SerializationContext.json()]) { + return ListReflection(subReflection).deserialize(src, context).toSet(); + } + + @override + Object? serialize( + Set src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return ListReflection(subReflection).serialize(src.toList(), context); + } + + @override + Set empty() => {}; + + @override + Set example([ExampleContext? context]) => + ListReflection(subReflection).example(context).toSet(); + + @override + Set clone(Iterable src) { + return Set.of(src); + } +} + +class NullableReflection extends ContainerReflection + implements Equality { + const NullableReflection(super.subReflection); + + @override + Equality get equality => this; + + bool isNull(Object? src, SerializationContext context) { + return context.split( + onJson: (context) => src == null, + onXml: (context) => + src == null || + // if src is a node called xsi:nil + (src is XmlHasName && + xmlNameEquals(src.name, XmlSerializationContext.nilXmlName)) || + (src is XmlNode && + ( + // if src is a node that contains xsi:nil attribute + (src + .getAttributeOrUndefinedMapped( + XmlSerializationContext.nilXmlName.local, + (value) => bool.tryParse(value.value) ?? false, + namespace: XmlSerializationContext + .nilXmlName.namespaceUri, + ) + .valueOrNull ?? + false) || + // if src is a node that contains xsi:nil element + src.childElements.any( + (element) => xmlNameEquals( + element.name, + XmlSerializationContext.nilXmlName, + ), + ))), + ); + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return isNull(src, context) || + subReflection.canDeserializeFunction(src, context); + } + + @override + T? deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return isNull(src, context) + ? null + : subReflection.deserializeFunction(src, context); + } + + @override + Object? serialize( + T? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src == null ? null : subReflection.serializeFunction(src, context); + } + + @override + T? empty() => null; + + @override + T? example([ExampleContext? context]) { + context ??= ExampleContext(); + return context.random.nextBool() + ? subReflection.exampleFunction(context) + : null; + } + + @override + bool equals(T? e1, T? e2) { + if (e1 == null || e2 == null) { + return e1 == e2; + } + return subReflection.equality.equals(e1, e2); + } + + @override + int hash(T? e) { + if (e == null) { + return null.hashCode; + } + return subReflection.equality.hash(e); + } + + @override + bool isValidKey(Object? o) { + return o == null || subReflection.equality.isValidKey(o); + } + + @override + T? clone(T? src) { + return src == null ? null : subReflection.cloneFunction(src); + } +} + +class UndefinedWrapperReflection + extends ContainerReflection, T> + implements Equality> { + const UndefinedWrapperReflection(super.subReflection); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src == UndefinedWrapper.$undefinedToken || + subReflection.canDeserializeFunction(src, context); + } + + @override + UndefinedWrapper deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src == UndefinedWrapper.$undefinedToken + ? UndefinedWrapper.undefined() + : UndefinedWrapper(subReflection.deserializeFunction(src, context)); + } + + @override + Object? serialize( + UndefinedWrapper src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src.map( + (src) => subReflection.serializeFunction(src, context), + ); + } + + @override + UndefinedWrapper empty() => const UndefinedWrapper.undefined(); + + @override + UndefinedWrapper example([ExampleContext? context]) { + context ??= ExampleContext(); + return context.random.nextBool() + ? UndefinedWrapper(subReflection.exampleFunction(context)) + : const UndefinedWrapper.undefined(); + } + + @override + Equality> get equality => this; + + @override + bool equals(UndefinedWrapper e1, UndefinedWrapper e2) { + if (e1.isDefined && e2.isDefined) { + return subReflection.equality.equals(e1.source as T, e2.source as T); + } + return e1.isDefined == e2.isDefined; + } + + @override + int hash(UndefinedWrapper e) { + return e.split( + defined: (src) => subReflection.equality.hash(src), + unDefined: () => UndefinedWrapper.$undefinedToken.hashCode, + ); + } + + @override + bool isValidKey(Object? o) => true; + + @override + UndefinedWrapper clone(UndefinedWrapper src) { + return src.map( + (src) => subReflection.cloneFunction(src), + ); + } +} + +class XmlReflectionWrapper extends ContainerReflection + with HasXmlReflection { + const XmlReflectionWrapper( + super.subReflection, { + required this.xml, + }); + + final XmlReflection xml; + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => subReflection.canDeserializeFunction(src, context), + onXml: (context) { + if (src is MapEntry) { + return subReflection.canDeserializeFunction( + src.value, + context.withXmlContainer(this), + ); + } + return subReflection.canDeserializeFunction( + src, + context.withXmlContainer(this), + ); + }, + ); + } + + @override + T deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) { + return subReflection.deserializeFunction(src, context); + }, + onXml: (context) { + if (src is MapEntry) { + return subReflection.deserializeFunction( + src.value, + context.withXmlContainer(this), + ); + } + return subReflection.deserializeFunction( + src, + context.withXmlContainer(this), + ); + }, + ); + } + + @override + Object? serialize( + T src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => subReflection.serializeFunction(src, context), + onXml: (context) { + return MapEntry( + xml, + subReflection.serializeFunction( + src, + context.withXmlContainer(this), + ), + ); + }, + ); + } + + @override + T empty() { + return subReflection.emptyFunction(); + } + + @override + T example([ExampleContext? context]) { + return subReflection.exampleFunction(context); + } + + @override + T clone(T src) { + return subReflection.cloneFunction(src); + } + + @override + Equality get equality => subReflection.equality; +} + +class EnumReflection + extends ContainerReflection { + const EnumReflection( + super.subReflection, { + required this.members, + }); + + final List> members; + + @override + T deserialize(Object? value, + [SerializationContext context = const SerializationContext.json()]) { + final deserialized = subReflection.deserializeFunction(value); + final res = members + .where((element) => element.oasValue == deserialized) + .firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res.value; + } + + @override + bool canDeserialize(Object? value, + [SerializationContext context = const SerializationContext.json()]) { + if (!subReflection.canDeserializeFunction(value, context)) { + return false; + } + final deserialized = subReflection.deserializeFunction(value, context); + return members.any((element) => element.oasValue == deserialized); + } + + @override + Object? serialize(T value, + [SerializationContext context = const SerializationContext.json()]) { + return subReflection.serializeFunction(value as TDataType, context); + } + + @override + T empty() { + return subReflection.emptyFunction() as T; + } + + @override + T example([ExampleContext? context]) { + context ??= ExampleContext(); + final member = members.elementAt(context.random.nextInt(members.length)); + return member.value; + } + + @override + T clone(T src) { + return subReflection.cloneFunction(src as TDataType) as T; + } +} + +class EnumMemberReflection { + const EnumMemberReflection({ + required this.dartName, + required this.oasValue, + required this.value, + }); + + final String dartName; + final TDataType oasValue; + final T value; +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/context.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/context.mustache new file mode 100644 index 000000000000..3da3c8d249be --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/context.mustache @@ -0,0 +1,283 @@ +import 'package:{{pubName}}/_internal.dart'; + +enum SupportedWireTypes { + other, + json, + xml, +} + +int xmlNameHashcode(XmlName a) { + return Object.hash(a.local, a.namespaceUri, a.prefix); +} + +bool xmlNameEquals(XmlName a, XmlName b) { + return a.local == b.local && + a.namespaceUri == b.namespaceUri && + a.prefix == b.prefix; +} + +typedef SerializeReflectionResolver = SerializationReflection? Function( + Object src, +); +typedef DeserializeReflectionResolver = SerializationReflection? + Function( + Object? src, +); +typedef ValueConverterFunction = Object? Function(Object? value); +typedef ValueConverterCheckerFunction = bool Function(Object? value); +typedef FileBytesSyncResolver = Uint8List? Function(XFile file); + +/// This function is used to check if a generic type T1 can be assigned to a generic type T2. +/// +/// e.g. a value of type int can be assigned to a value of type num +/// isOfType() == true +/// but not the opposite +/// isOfType() == true +/// +/// This also works for deeply nested objects +/// isOfType>, List>>() == true +bool isOfType() { + return (_fakeFunction) is T2 Function(); +} + +TItem Function() extractIterableType, TItem>() { + return _fakeFunction; +} + +/// This function is used to check if a generic type T can accept a null value. +bool isNullableType() { + return null is T; +} + +/// This function will NEVER be called. +T _fakeFunction() { + return null as T; +} + +abstract class SerializationContext { + const SerializationContext({ + this.serializeReflectionResolver, + this.deserializeReflectionResolver, + this.fileBytesResolver, + }); + + SerializationContext copyWith({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + }); + + /// Creates a json serialization context, where the target is to output + /// types that can be passed to jsonEncode and jsonDecode. + /// + /// You can completely control the serialization and deserialization process + /// for unknown objects by passing [serializeReflectionResolver] and [deserializeReflectionResolver]. + const factory SerializationContext.json({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + }) = JsonSerializationContext; + + /// Creates an XML serialization context, where the target is to output + /// an XmlNode. + /// + /// You can completely control the serialization and deserialization process + /// for unknown objects by passing [serializeReflectionResolver] and [deserializeReflectionResolver]. + /// + /// [xmlContainer] and [oasNameContainer] are required here due to the nature + /// of XML, since serializing a value requires information about the property + /// name, namespace, prefix, wrapped, etc... + const factory SerializationContext.xml({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + HasXmlReflection? xmlContainer, + HasOasName? oasNameContainer, + }) = XmlSerializationContext; + + // used when serializing an unknown value to discover its reflection. + final SerializeReflectionResolver? serializeReflectionResolver; + // used when deserializing an unknown value to discover its reflection. + final DeserializeReflectionResolver? deserializeReflectionResolver; + + /// Try to resolve the bytes of a file synchronously, if not possible, return null. + final FileBytesSyncResolver? fileBytesResolver; + + SupportedWireTypes get wireType; + bool get isJson => wireType == SupportedWireTypes.json; + bool get isXml => wireType == SupportedWireTypes.xml; + + T split({ + required T Function(JsonSerializationContext context) onJson, + required T Function(XmlSerializationContext context) onXml, + T Function(SerializationContext context)? onOther, + }) { + return switch (this) { + JsonSerializationContext json => onJson(json), + XmlSerializationContext xml => onXml(xml), + _ => onOther == null ? throw UnimplementedError() : onOther(this), + }; + } +} + +class JsonSerializationContext extends SerializationContext { + const JsonSerializationContext({ + super.serializeReflectionResolver, + super.deserializeReflectionResolver, + super.fileBytesResolver, + }); + + @override + SupportedWireTypes get wireType => SupportedWireTypes.json; + + @override + JsonSerializationContext copyWith({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + }) => + JsonSerializationContext( + serializeReflectionResolver: + serializeReflectionResolver ?? this.serializeReflectionResolver, + deserializeReflectionResolver: + deserializeReflectionResolver ?? this.deserializeReflectionResolver, + fileBytesResolver: fileBytesResolver ?? this.fileBytesResolver, + ); +} + +class XmlSerializationContext extends SerializationContext { + const XmlSerializationContext({ + super.serializeReflectionResolver, + super.deserializeReflectionResolver, + super.fileBytesResolver, + this.xmlContainer, + this.oasNameContainer, + }); + + static final xmlnsAttribute = XmlAttribute( + XmlName("xmlns"), + 'http://www.w3.org/2001/XMLSchema', + ); + static final xsiNamespaceAttribute = XmlAttribute( + XmlName("xsi", "xmlns"), + 'http://www.w3.org/2001/XMLSchema-instance', + ); + static final nilXmlName = XmlName("nil", "xsi"); + static final nilXmlAttribute = XmlAttribute(nilXmlName, 'true'); + static final nilXmlElement = XmlElement(nilXmlName, [], [XmlText("true")]); + + @override + SupportedWireTypes get wireType => SupportedWireTypes.xml; + + final HasXmlReflection? xmlContainer; + final HasOasName? oasNameContainer; + + XmlSerializationContext withXmlContainer(HasXmlReflection? xmlContainer) { + return XmlSerializationContext( + serializeReflectionResolver: serializeReflectionResolver, + deserializeReflectionResolver: deserializeReflectionResolver, + fileBytesResolver: fileBytesResolver, + xmlContainer: xmlContainer, + oasNameContainer: oasNameContainer, + ); + } + + XmlSerializationContext withOasNameContainer(HasOasName? oasNameContainer) { + return XmlSerializationContext( + serializeReflectionResolver: serializeReflectionResolver, + deserializeReflectionResolver: deserializeReflectionResolver, + fileBytesResolver: fileBytesResolver, + xmlContainer: xmlContainer, + oasNameContainer: oasNameContainer, + ); + } + + @override + XmlSerializationContext copyWith({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + HasXmlReflection? xmlContainer, + HasOasName? oasNameContainer, + }) => + XmlSerializationContext( + serializeReflectionResolver: + serializeReflectionResolver ?? this.serializeReflectionResolver, + deserializeReflectionResolver: + deserializeReflectionResolver ?? this.deserializeReflectionResolver, + fileBytesResolver: fileBytesResolver ?? this.fileBytesResolver, + xmlContainer: xmlContainer ?? this.xmlContainer, + oasNameContainer: oasNameContainer ?? this.oasNameContainer, + ); + + + XmlNode wrapSerializedValue( + XmlName key, + Object? value, { + XmlReflection? keyReflection, + }) { + key = key.copy(); + final keyXmlns = keyReflection?.getXmlNamespaceAttribute(); + switch (value) { + case null: + return XmlElement(key, [ + XmlSerializationContext.nilXmlAttribute.copy(), + if (keyXmlns != null) keyXmlns, + ]); + case XmlNode node: + return XmlElement(key, [ + if (keyXmlns != null) keyXmlns, + ], [ + node.copy() + ]); + case MapEntry nodeEntry: + final subXml = nodeEntry.key; + var item = nodeEntry.value; + if (item is XmlNode && item.hasParent) { + item = item.copy(); + } + final itemXmlnsAttr = subXml.getXmlNamespaceAttribute() ?? keyXmlns; + final newItemName = + XmlName(subXml.xmlName ?? key.local, subXml.prefix ?? key.prefix); + + // non-wrapped lists and maps do not require returning an XML element, + // and should be returned as is. + if (item is XmlDocumentFragment) { + if (!subXml.wrapped) { + return item; + } + } + return XmlElement( + newItemName, + [ + if (item == null) + XmlSerializationContext.nilXmlAttribute.copy() + else if (item is XmlAttribute) + item, + if (itemXmlnsAttr != null) itemXmlnsAttr, + ], + [if (item is XmlNode && item is! XmlAttribute) item], + ); + default: + return XmlElement(key); + } + } + + XmlNode handleAttributes(XmlReflection xml, XmlNode node) { + if (xml.attribute) { + if (node is XmlAttribute) { + return node; + } + if (node case XmlHasName namedNode) { + return XmlAttribute( + namedNode.name.copy(), + node.value ?? node.innerText, + ); + } else { + return node; + } + } else { + return node; + } + } +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/examples.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/examples.mustache new file mode 100644 index 000000000000..7823c96c905e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/examples.mustache @@ -0,0 +1,44 @@ +import 'package:{{pubName}}/_internal.dart'; + +var $examplesRandom = Random(123); + +class ExampleContext { + ExampleContext({ + Random? random, + AggregatedDiscriminatorsResult? discriminators, + Map? fileCache, + Map>? + discriminatorExampleResults, + }) : discriminators = discriminators ?? {}, + fileCache = fileCache ?? {}, + discriminatorExampleResults = discriminatorExampleResults ?? {}, + random = random ?? $examplesRandom; + + final Random random; + final AggregatedDiscriminatorsResult discriminators; + final Map fileCache; + final Map> + discriminatorExampleResults; + + T exampleEnum(List values) { + return values.elementAt(random.nextInt(values.length)); + } + + int exampleCode(int min, int max) { + return random.nextInt(max - min) + min; + } + + String exampleMimeType(String pattern) { + return MediaType.parse(pattern).fillDefaults().toString(); + } + + MapEntry? exampleDiscriminator( + Map discriminatorMappings, + ) { + if (discriminatorMappings.isEmpty) { + return null; + } + final pickResult = random.nextInt(discriminatorMappings.length); + return discriminatorMappings.entries.elementAt(pickResult); + } +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/generated_reflections.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/generated_reflections.mustache new file mode 100644 index 000000000000..e47998dfef89 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/generated_reflections.mustache @@ -0,0 +1,26 @@ +import 'package:{{pubName}}/_internal.dart'; +// All the model reflections that were generated. + +const generatedClassReflectionsList = >[ +{{#models}}{{#model}}{{^isEnum}} + {{classname}}Reflection.instance, +{{/isEnum}}{{/model}}{{/models}} +]; +/// This does NOT include inline enums. +const generatedEnumReflectionsList = >[ + {{#models}}{{#model}}{{#isEnum}} + {{classname}}.$reflection, + {{/isEnum}}{{/model}}{{/models}} +]; + + +const generatedClassReflectionsMap = >{ + {{#models}}{{#model}}{{^isEnum}} + r'{{{name}}}': {{classname}}Reflection.instance, + {{/isEnum}}{{/model}}{{/models}} +}; +const generatedEnumReflectionsMap = >{ + {{#models}}{{#model}}{{#isEnum}} + r'{{{name}}}': {{classname}}.$reflection, + {{/isEnum}}{{/model}}{{/models}} +}; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/json_extensions.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/json_extensions.mustache new file mode 100644 index 000000000000..4de6afd8dcb3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/json_extensions.mustache @@ -0,0 +1,34 @@ +import 'package:openapi_infrastructure/openapi_infrastructure.dart'; + +extension UndefinedWrapperMapExtensions on Map { + UndefinedWrapper getOrUndefined( + TKey key, + ) { + if (!containsKey(key)) { + return UndefinedWrapper.undefined(); + } else { + return UndefinedWrapper(this[key] as TValue); + } + } + + UndefinedWrapper getOrUndefinedMapped( + TKey key, + T Function(TValue src) mapper, + ) { + return getOrUndefined(key).map(mapper); + } + + T getRequiredMapped( + TKey key, + T Function(TValue src) mapper, + ) { + if (!containsKey(key)) { + throw ArgumentError( + 'key ($key) is not present in the source Map, but it is required.', + 'key', + ); + } else { + return mapper(this[key] as TValue); + } + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/model_reflection.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/model_reflection.mustache new file mode 100644 index 000000000000..eb0dc55e88ba --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/model_reflection.mustache @@ -0,0 +1,1032 @@ +import 'package:{{pubName}}/_internal.dart'; + +import 'package:collection/collection.dart'; + +extension type DiscriminatorKey(String key) {} +extension type DiscriminatorValue(String key) {} + +typedef AggregatedDiscriminatorsResult + = Map>; + +abstract class ModelReflection + with + HasXmlReflection, + HasOasName, + SerializationReflection, + InheritanceBasedSerializationReflection + implements Equality { + const ModelReflection(); + + String get modelName; + + @override + String get oasName => modelName; + String get className; + XmlReflection get xml; + String? get discriminatorKey; + Map get discriminatorMappings; + Map get discriminatorImplicitMappings; + + AdditionalPropertiesPart? get additionalPropertiesPart => null; + List> get oneOfs => []; + List> get anyOfs => []; + List> get allOfs => []; + + ModelReflection? tryGetDiscriminatorModel(String? discriminatorValue) { + if (discriminatorValue == null) { + return null; + } + return discriminatorMappings[discriminatorValue] ?? + discriminatorImplicitMappings[discriminatorValue]; + } + + static final _cachedAggregatedDiscriminators = + Expando(); + + AggregatedDiscriminatorsResult get aggregatedDiscriminators { + final cached = _cachedAggregatedDiscriminators[this]; + if (cached != null) { + return cached; + } + final result = + >{}; + _aggregatedDiscriminators(this, result); + return _cachedAggregatedDiscriminators[this] = result; + } + + static void _aggregatedDiscriminators( + ModelReflection reflection, + AggregatedDiscriminatorsResult result, + ) { + if (reflection.discriminatorKey case String discriminatorKey) { + final discriminatorMapping = + result[DiscriminatorKey(discriminatorKey)] ??= {}; + discriminatorMapping.addAll( + reflection.discriminatorImplicitMappings + .map((key, value) => MapEntry(DiscriminatorValue(key), value)), + ); + discriminatorMapping.addAll( + reflection.discriminatorMappings + .map((key, value) => MapEntry(DiscriminatorValue(key), value)), + ); + } + for (final OneOfReflection( + reflection: UndefinedWrapperReflection(subReflection: classReflection) + ) in reflection.oneOfs) { + final modelReflection = classReflection.getNearestModelReflection(); + if (modelReflection == null) { + continue; + } + _aggregatedDiscriminators(modelReflection, result); + } + for (final AnyOfReflection( + reflection: UndefinedWrapperReflection(subReflection: classReflection) + ) in reflection.anyOfs) { + final modelReflection = classReflection.getNearestModelReflection(); + if (modelReflection == null) { + continue; + } + _aggregatedDiscriminators(modelReflection, result); + } + } + + /// Aggregates properties from anyof and oneof as well. + static final _cachedAggregatedProperties = + Expando>(); + + Map get aggregatedProperties { + final cached = _cachedAggregatedProperties[this]; + if (cached != null) { + return cached; + } + + final result = {}; + _aggregateProperties(this, result); + return _cachedAggregatedProperties[this] = result; + } + + static void _aggregateProperties( + ModelReflection reflection, + Map result, + ) { + // + for (var element in reflection.properties) { + result[element.oasName] = element; + } + for (var oneOf in reflection.oneOfs) { + final modelReflection = oneOf.reflection.getNearestModelReflection(); + if (modelReflection == null) { + continue; + } + _aggregateProperties(modelReflection, result); + } + for (var anyOf in reflection.anyOfs) { + final modelReflection = anyOf.reflection.getNearestModelReflection(); + if (modelReflection == null) { + continue; + } + _aggregateProperties(modelReflection, result); + } + } + + List> get parts => [ + ...oneOfs, + ...anyOfs, + ...allOfs, + ...properties, + if (additionalPropertiesPart != null) additionalPropertiesPart!, + ]; + List> get properties; + Set get knownKeys => aggregatedProperties.keys.toSet(); + + T example([ExampleContext? context]) { + context ??= ExampleContext(discriminators: aggregatedDiscriminators); + for (final MapEntry(key: propName, value: mappings) + in context.discriminators.entries) { + if (context.discriminatorExampleResults.containsKey(propName)) { + continue; + } + final r = context.exampleDiscriminator(mappings); + if (r != null) { + context.discriminatorExampleResults[propName] = r; + } + } + + final exampleResult = empty(); + for (var propPart in properties) { + var propExample = propPart.reflection.exampleFunction(context); + final preSelectedResult = + context.discriminatorExampleResults[propPart.oasName]?.key.key; + if (preSelectedResult != null) { + propExample = preSelectedResult; + } + propPart.setter(exampleResult, propExample); + } + if (additionalPropertiesPart + case AdditionalPropertiesPart( + setter: final additionalPropertiesPartSetter, + reflection: final additionalPropertiesPartReflection, + )) { + additionalPropertiesPartSetter( + exampleResult, + additionalPropertiesPartReflection.exampleFunction(context), + ); + } + for (var element in [...oneOfs, ...anyOfs]) { + element.setter( + exampleResult, element.reflection.exampleFunction(context)); + } + return exampleResult; + } + + @override + Object? serialize( + T instance, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final reflection = this; + return context.split( + onJson: (context) { + // Logic is: + // 1. Start with oneof and anyof serialization + // 2. The output of the serialization is either a Map, null or a scalar. + // 3. If it is a Map or null, then we need to add the vars from allVars + // 4. If it is a non-null value, return it. + Object? result; + // 1. Handle oneof serialization + final oneOfResult = reflection.oneOfs + .where((oneof) => oneof.getter(instance).isDefined) + .firstOrNull; + if (oneOfResult != null) { + result = oneOfResult.reflection.serializeFunction( + oneOfResult.getter(instance), + context, + ); + } + // 2. Handle anyof serialization + final anyOfResults = reflection.anyOfs + .where((anyOf) => anyOf.getter(instance).isDefined) + .toList(); + if (anyOfResults.isNotEmpty) { + final serializedAnyOfs = anyOfResults + .map( + (anyOf) => anyOf.reflection.serializeFunction!( + anyOf.getter(instance), + context, + ), + ) + .toList(); + for (var anyOf in serializedAnyOfs) { + if (anyOf is Map) { + result ??= {}; + if (result is Map) { + result.addAll(anyOf); + } else { + // Model is trying to mix scalar and non-scalar properties via anyof + } + } else { + if (result == null) { + result = anyOf; + } else { + // If the anyOfs are scalars, then we only pick the first one, since it's not possible to mix them. + } + } + } + } + result ??= {}; + // 3. Handle properties + if (result is Map) { + result = { + ...result, + // we give priority to self properties over oneOf/anyOf. + ...Map.fromEntries( + reflection.properties + .where((x) => + x.getter(instance) != UndefinedWrapper.$undefinedToken) + .map( + (x) => MapEntry( + x.oasName, + x.reflection + .serializeFunction(x.getter(instance), context), + ), + ), + ), + }; + // Put additional properties last so that users can override any existing property value. + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final additionalProperties = + additionalPropertiesPart.getter(instance); + final serializedAdditionalPropertiesEntries = additionalProperties + .entries + //ignore undefined + .where( + (e) => e.value != UndefinedWrapper.$undefinedToken, + ) + .map( + (e) => MapEntry( + e.key, + additionalPropertiesPart.itemReflection.serializeFunction!( + e.value, + context, + ), + ), + ); + result.addEntries(serializedAdditionalPropertiesEntries); + } + } + return result; + }, + onXml: (context) { + final xmlReflection = context.xmlContainer?.xml ?? reflection.xml; + // if the result of serialization outputs an XmlElement (or multiple elements), this will be its name. + final elementName = + xmlReflection.getQualifiedName(reflection.modelName); + // Logic is: + // 1. Start with oneof and anyof serialization + // 2. The output of the serialization is either a Map, null or a scalar. + // 3. If it is a Map or null, then we need to add the vars from allVars + // 4. If it is a non-null value, return it. + XmlNode? result; + // 1. Handle oneof serialization + final oneOfResult = reflection.oneOfs + .where((oneof) => oneof.getter(instance).isDefined) + .firstOrNull; + if (oneOfResult != null) { + result = oneOfResult.reflection.serializeFunction!( + oneOfResult.getter(instance), + context, + ) as XmlNode?; + } + // 2. Handle anyof serialization + final anyOfResults = reflection.anyOfs + .where((anyOf) => anyOf.getter(instance).isDefined) + .toList(); + if (anyOfResults.isNotEmpty) { + final serializedAnyOfs = anyOfResults + .map( + (anyOf) => anyOf.reflection.serializeFunction!( + anyOf.getter(instance), + context, + ), + ) + .whereType() + .toList(); + // XmlElement(elementName, [XmlAttribute(name, value)]); + for (var anyOf in serializedAnyOfs) { + if (anyOf is XmlDocumentFragment) { + result ??= XmlDocumentFragment([]); + if (result is XmlDocumentFragment) { + result.children.addAll(anyOf.children); + } else { + // Model is trying to mix scalar and non-scalar properties via anyof + } + } else { + if (result == null) { + result = anyOf; + } else { + // If the anyOfs are scalars, then we only pick the first one, since it's not possible to mix them. + } + } + } + } + result ??= XmlElement( + elementName, + [ + XmlSerializationContext.xsiNamespaceAttribute.copy(), + XmlSerializationContext.xmlnsAttribute.copy() + ], + [], + ); + // 3. Handle properties + if (result is XmlElement) { + final namespaceAttribute = xmlReflection.getXmlNamespaceAttribute(); + if (namespaceAttribute != null) { + result.attributes.add(namespaceAttribute); + } + final definedProps = reflection.properties.where( + (x) => x.getter(instance) != UndefinedWrapper.$undefinedToken, + ); + final serializedProps = Map.fromEntries(definedProps.map( + (propPart) => MapEntry( + propPart.oasName, + context.handleAttributes( + propPart.xml, + context.wrapSerializedValue( + propPart.xml.getQualifiedName(propPart.oasName), + propPart.reflection.serializeFunction( + propPart.getter(instance), + context.withOasNameContainer(propPart), + ), + ), + ), + ), + )); + + final attributesToAdd = Map.fromEntries( + serializedProps.entries + .where( + (element) => element.value is XmlAttribute, + ) + .map( + (e) => MapEntry(e.key, e.value as XmlAttribute), + ), + ); + final childrenToAdd = Map.fromEntries( + serializedProps.entries.where( + (element) => element.value is! XmlAttribute, + ), + ); + + // Put additional properties last so that users can override any existing property value. + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final additionalProperties = + additionalPropertiesPart.getter(instance); + final serializedAdditionalPropertiesEntries = Map.fromEntries( + additionalProperties.entries + .where( + (e) => e.value != UndefinedWrapper.$undefinedToken, + ) + .map( + (e) => MapEntry( + e.key, + context.handleAttributes( + additionalPropertiesPart.xml, + context.wrapSerializedValue( + additionalPropertiesPart.xml.getQualifiedName(e.key), + additionalPropertiesPart + .itemReflection.serializeFunction!( + e.value, + context.withOasNameContainer( + OasNameWrapper(oasName: e.key), + ), + ), + ), + ), + ), + ), + ); + attributesToAdd.addEntries( + serializedAdditionalPropertiesEntries.entries + .where((e) => e.value is XmlAttribute) + .cast>(), + ); + childrenToAdd.addEntries( + serializedAdditionalPropertiesEntries.entries + .where((e) => e.value is! XmlAttribute), + ); + } + result.children.addAll(childrenToAdd.values.map((e) => e.copy())); + result.attributes.addAll(attributesToAdd.values.map((e) => e.copy())); + } + return result; + }, + ); + } + + @override + T deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final reflection = this; + return context.split( + onJson: (context) { + final result = reflection.empty(); + final discriminatorKey = reflection.discriminatorKey; + ModelReflection? discriminatedReflection; + if (src is Map) { + final discriminatorValue = discriminatorKey == null + ? null + : src[discriminatorKey]?.toString(); + discriminatedReflection = discriminatorValue == null + ? null + : reflection.tryGetDiscriminatorModel(discriminatorValue); + for (final prop in reflection.properties) { + final value = src.getOrUndefined(prop.oasName); + + prop.setter( + result, + prop.reflection.deserializeFunction( + value, + context, + ), + ); + } + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + additionalPropertiesPart.setter( + result, + src.except(reflection.knownKeys).map( + (key, v) => MapEntry( + key, + additionalPropertiesPart + .itemReflection.deserializeFunction!(v, context), + ), + ), + ); + } + } + final selectedOneOf = reflection.oneOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + if (selectedOneOf != null) { + selectedOneOf.setter( + result, + selectedOneOf.reflection.deserializeFunction!(src, context), + ); + } else { + for (var element in reflection.oneOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + element.setter( + result, + element.reflection.deserializeFunction!(src, context), + ); + } + } + } + + final selectedAnyOf = reflection.anyOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + + if (selectedAnyOf != null) { + selectedAnyOf.setter( + result, + selectedAnyOf.reflection.deserializeFunction!(src, context), + ); + } else { + for (var element in reflection.anyOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + element.setter( + result, + element.reflection.deserializeFunction!(src, context), + ); + } + } + } + return result; + }, + onXml: (context) { + if (src is! XmlNode) { + throw UnimplementedError('Can only deserialize xml nodes'); + } + final result = reflection.empty(); + final discriminatorKey = reflection.discriminatorKey; + final discriminatorName = discriminatorKey == null + ? null + : XmlName.fromString(discriminatorKey); + XmlNode? discriminatorValue; + + final srcNormalized = src.readNormalized(); + + discriminatorValue = + discriminatorName == null ? null : srcNormalized[discriminatorName]; + final discriminatedReflection = + reflection.tryGetDiscriminatorModel(discriminatorValue?.value); + + for (final property in reflection.properties) { + final propertyName = property.xml.getQualifiedName(property.oasName); + final rawNode = srcNormalized.getOrUndefined(propertyName.qualified); + if (property.required && !rawNode.isDefined) { + throwArgumentRequired(propertyName.qualified); + } + if (rawNode.isUndefined) { + //skip non-required undefined properties + continue; + } + + final node = rawNode.valueRequired; + if (property.xml.attribute) { + if (node is! XmlAttribute) { + throw ArgumentError( + 'Trying to deserialize an XML attribute, but instead found a (${node.nodeType}).', + ); + } + } + final propContext = context.withOasNameContainer(property); + if (property.reflection.canDeserializeFunction(node, propContext)) { + final propertyValue = property.reflection.deserializeFunction( + node, + propContext, + ); + property.setter(result, propertyValue); + } else { + throw UnsupportedError( + 'Not possible to deserialize the property ${property.oasName}', + ); + } + } + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final additionalProperties = + additionalPropertiesPart.reflection.emptyFunction(); + final knownKeys = reflection.properties + .map((e) => e.xml.getQualifiedName(e.oasName)) + .toSet(); + for (final MapEntry(key: keyRaw, value: node) + in srcNormalized.entries) { + if (keyRaw == null) { + continue; + } + if (knownKeys.contains(keyRaw)) { + continue; + } + final key = XmlName.fromString(keyRaw); + + if (key.prefix != additionalPropertiesPart.xml.prefix) { + continue; + } + if (additionalPropertiesPart.xml.prefix != null && + additionalPropertiesPart.xml.namespace != null) { + if (key.namespaceUri != additionalPropertiesPart.xml.namespace) { + // skip if the namespace is not correct + continue; + } + } + + additionalProperties[key.local] = + additionalPropertiesPart.itemReflection.deserializeFunction!( + node, + context.withOasNameContainer( + OasNameWrapper(oasName: key.local), + ), + ); + } + additionalPropertiesPart.setter(result, additionalProperties); + } + + final selectedOneOf = reflection.oneOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + if (selectedOneOf != null) { + selectedOneOf.setter( + result, + selectedOneOf.reflection.deserializeFunction!(src, context), + ); + } else { + for (var element in reflection.oneOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + element.setter(result, + element.reflection.deserializeFunction!(src, context)); + } + } + } + + final selectedAnyOf = reflection.anyOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + + if (selectedAnyOf != null) { + selectedAnyOf.setter( + result, + selectedAnyOf.reflection.deserializeFunction!(src, context), + ); + } else { + for (var element in reflection.anyOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + element.setter(result, + element.reflection.deserializeFunction!(src, context)); + } + } + } + return result; + }, + ); + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final reflection = this; + return context.split( + onJson: (context) { + final discriminatorKey = reflection.discriminatorKey; + Object? discriminatorValue; + ModelReflection? discriminatedReflection; + + if (src is Map) { + discriminatorValue = + discriminatorKey == null ? null : src[discriminatorKey]; + discriminatedReflection = reflection + .tryGetDiscriminatorModel(discriminatorValue?.toString()); + + for (final propPart in reflection.properties) { + final value = src.getOrUndefined(propPart.oasName); + if (value.isUndefined && propPart.required) { + return false; + } + if (!propPart.reflection.canDeserializeFunction!( + value, + context, + )) { + return false; + } + } + if (reflection.additionalPropertiesPart != null) { + final additionalProps = src.except(reflection.knownKeys); + final badEntries = additionalProps.entries.where( + (e) => !reflection.additionalPropertiesPart!.itemReflection + .canDeserializeFunction!(e.value, context), + ); + if (badEntries.isNotEmpty) { + return false; + } + } + } else { + if (reflection.properties.any((e) => e.required)) { + return false; + } + } + + final selectedOneOf = discriminatedReflection == null + ? null + : reflection.oneOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + if (selectedOneOf != null) { + if (!selectedOneOf.reflection.canDeserializeFunction!(src, context)) { + return false; + } + } else { + int counter = 0; + for (var element in reflection.oneOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + counter++; + } + } + if (counter > 1) { + return false; + } + } + + return true; + }, + onXml: (context) { + if (src is! XmlNode) { + return false; + } + + final discriminatorKey = reflection.discriminatorKey; + final discriminatorName = discriminatorKey == null + ? null + : XmlName.fromString(discriminatorKey); + XmlNode? discriminatorValue; + // step 1: prepare the src object by grouping it into a srcMap where the key + // is the fully qualified name of the node and the value is a list of nodes + // or attributes with the same name. + final srcNormalized = src.readNormalized(); + discriminatorValue = discriminatorName == null + ? null + : srcNormalized[discriminatorName.qualified]; + final discriminatedReflection = + reflection.tryGetDiscriminatorModel(discriminatorValue?.value); + for (final property in reflection.properties) { + final propertyName = property.xml.getQualifiedName(property.oasName); + final rawNode = srcNormalized.getOrUndefined(propertyName.qualified); + if (property.required && !rawNode.isDefined) { + return false; + } + if (rawNode.isUndefined) { + //skip non-required undefined properties + continue; + } + + final node = rawNode.valueRequired; + if (property.xml.attribute) { + if (node is! XmlAttribute) { + return false; + } + } + if (!property.reflection.canDeserializeFunction( + node, + context.withOasNameContainer(property), + )) { + return false; + } + } + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final knownKeys = reflection.properties + .map((e) => e.xml.getQualifiedName(e.oasName).qualified) + .toSet(); + for (final MapEntry(key: keyRaw, value: node) + in srcNormalized.entries) { + if (keyRaw == null) { + continue; + } + if (knownKeys.contains(keyRaw)) { + continue; + } + final key = XmlName.fromString(keyRaw); + + if (key.prefix != additionalPropertiesPart.xml.prefix) { + continue; + } + if (additionalPropertiesPart.xml.prefix != null && + additionalPropertiesPart.xml.namespace != null) { + if (key.namespaceUri != additionalPropertiesPart.xml.namespace) { + // skip if the namespace is not correct + continue; + } + } + + if (!additionalPropertiesPart + .itemReflection.canDeserializeFunction!( + node, + context.withOasNameContainer( + OasNameWrapper(oasName: key.local), + ), + )) { + return false; + } + } + } + + final selectedOneOf = reflection.oneOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + if (selectedOneOf != null) { + if (!selectedOneOf.reflection.canDeserializeFunction!(src, context)) { + return false; + } + } else { + int counter = 0; + for (var element in reflection.oneOfs) { + if (element.reflection.canDeserializeFunction(src, context)) { + counter++; + } + } + if (counter > 1) { + return false; + } + } + + return true; + }, + ); + } + + @override + int hash(T e) { + const propEq = MapEquality( + keys: const StrictEquality(), + values: const StrictEquality(), + ); + + final toHash = {}; + + toHash.addEntries(properties.map( + (prop) => + MapEntry(prop.oasName, prop.reflection.equality.hash(prop.getter(e))), + )); + + int additionalPropsHash = 0; + final additionalPropertiesPart = this.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final additionalProps = additionalPropertiesPart.getter(e); + additionalPropsHash = + additionalPropertiesPart.reflection.equality.hash(additionalProps); + } + + final oneOfsHash = Object.hashAll( + this.oneOfs.map((o) => o.reflection.equality.hash(o.getter(e))), + ); + final anyOfsHash = Object.hashAll( + this.anyOfs.map((o) => o.reflection.equality.hash(o.getter(e))), + ); + return Object.hash( + // include model name in the hash + this.oasName, + propEq.hash(toHash), + additionalPropsHash, + oneOfsHash, + anyOfsHash, + ); + } + + @override + bool equals(T e1, T e2) { + for (final prop in properties) { + final e1Value = prop.getter(e1); + final e2Value = prop.getter(e2); + final eq = prop.reflection.equality; + if (!eq.equals(e1Value, e2Value)) { + return false; + } + } + final additionalPropertiesPart = this.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final e1Additional = additionalPropertiesPart.getter(e1); + final e2Additional = additionalPropertiesPart.getter(e2); + if (!additionalPropertiesPart.reflection.equality + .equals(e1Additional, e2Additional)) { + return false; + } + } + for (var oneof in oneOfs) { + final e1Value = oneof.getter(e1); + final e2Value = oneof.getter(e2); + if (!oneof.reflection.equality.equals(e1Value, e2Value)) { + return false; + } + } + for (var anyof in anyOfs) { + final e1Value = anyof.getter(e1); + final e2Value = anyof.getter(e2); + if (!anyof.reflection.equality.equals(e1Value, e2Value)) { + return false; + } + } + return true; + } + + @override + bool isValidKey(Object? o) { + return o is T; + } + + @override + T clone(T src) { + final res = empty(); + for (var props in properties) { + props.setter(res, props.reflection.cloneFunction(props.getter(src))); + } + for (var oneOf in oneOfs) { + oneOf.setter(res, oneOf.reflection.cloneFunction(oneOf.getter(src))); + } + for (var anyOf in anyOfs) { + anyOf.setter(res, anyOf.reflection.cloneFunction(anyOf.getter(src))); + } + final additionalPropertiesPart = this.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + additionalPropertiesPart.setter( + res, + additionalPropertiesPart.reflection + .cloneFunction(additionalPropertiesPart.getter(src)), + ); + } + return res; + } +} + +mixin PartReflectionMixin { + SerializationReflection get reflection; + ModelReflection Function() get parentReflectionGetter; + + FunctionWrapper1 get getter; + FunctionWrapper2 get setter; +} + +abstract class PartReflection + with PartReflectionMixin { + const PartReflection({ + required this.parentReflectionGetter, + }); + + final ModelReflection Function() parentReflectionGetter; +} + +class PropertyReflection + extends PartReflection with HasXmlReflection, HasOasName { + const PropertyReflection({ + required this.dartName, + required this.oasName, + required this.oasType, + required this.required, + required this.nullable, + required this.reflection, + required super.parentReflectionGetter, + this.$default, + this.pattern, + this.xml = const XmlReflection(), + required this.getter, + required this.setter, + required this.isDiscriminator, + }); + + @override + final SerializationReflection reflection; + + @override + final XmlReflection xml; + final String dartName; + @override + final String oasName; + final String oasType; + final bool required; + final bool nullable; + final Object? $default; + final String? pattern; + + @override + final FunctionWrapper1 getter; + @override + final FunctionWrapper2 setter; + final bool isDiscriminator; +} + +class AdditionalPropertiesPart + extends PartReflection> with HasXmlReflection { + const AdditionalPropertiesPart({ + required this.getter, + required this.setter, + required super.parentReflectionGetter, + required this.itemReflection, + this.xml = const XmlReflection(), + }); + + final SerializationReflection itemReflection; + + @override + SerializationReflection> get reflection => + MapReflection(itemReflection); + + final XmlReflection xml; + @override + final FunctionWrapper1, TParent> getter; + @override + final FunctionWrapper2> setter; +} + +abstract class OneOfReflection + extends PartReflection> { + const OneOfReflection({ + required super.parentReflectionGetter, + }); + + @override + UndefinedWrapperReflection get reflection; +} + +abstract class AnyOfReflection + extends PartReflection> { + const AnyOfReflection({ + required super.parentReflectionGetter, + }); + + @override + UndefinedWrapperReflection get reflection; +} + +class AllOfReflection + with PartReflectionMixin { + const AllOfReflection({ + required this.parentReflectionGetter, + required ModelReflection this.reflection, + }); + @override + final ModelReflection reflection; + final ModelReflection Function() parentReflectionGetter; + + @override + FunctionWrapper1 get getter => + FunctionWrapper1((TParent src) => src); + + @override + FunctionWrapper2 get setter => + FunctionWrapper2((a, b) => null); +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/open_api_object.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/open_api_object.mustache new file mode 100644 index 000000000000..9c313da5a243 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/open_api_object.mustache @@ -0,0 +1,23 @@ +import 'package:{{pubName}}/_internal.dart'; + +/// A marker mixin to be the base class for all openapi schemas of type `object` or schemas containing `oneof`, `anyof`. +/// +/// Where an `object` is a value that can be serialized/deserialized from a json map. +/// +/// Every openapi object MUST implement `$classReflection`, and optionally implement validate. +mixin $OpenApiObjectMixin { + @mustCallSuper + bool validate() => true; + + ModelReflection get $classReflection; + + @override + bool operator ==(Object other) { + return identical(this, other) || + ($classReflection.isValidKey(other) && + $classReflection.equals(this, other)); + } + + @override + int get hashCode => $classReflection.hash(this); +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/parameter_serialization.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/parameter_serialization.mustache new file mode 100644 index 000000000000..6e93a9080a9f --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/parameter_serialization.mustache @@ -0,0 +1,257 @@ +import 'package:std_uritemplate/std_uritemplate.dart'; + +abstract class OpenApiParameterSerialization { + final bool explode; + final String parameterName; + + const OpenApiParameterSerialization({ + required this.parameterName, + required this.explode, + }); + + String get appendExplode => explode ? '*' : ''; + + String get oldParameterPlaceHolder => '{$parameterName}'; +} + +// in: path ------------------ + +abstract class OpenApiParameterSerializationPath + extends OpenApiParameterSerialization { + const OpenApiParameterSerializationPath({ + required super.explode, + required super.parameterName, + }); + + String modifyTemplateToRFC6570(String template); + + String expand(String template, Object? value) { + final modified = modifyTemplateToRFC6570(template); + return StdUriTemplate.expand(modified, { + parameterName: value, + }); + } + + factory OpenApiParameterSerializationPath.fromStyle(String style, { + required bool explode, + required String parameterName, + }) { + return switch (style) { + 'simple' => OpenApiParameterSerializationPathSimple(parameterName: parameterName, explode: explode), + 'label' => OpenApiParameterSerializationPathLabel(parameterName: parameterName, explode: explode), + 'matrix' => OpenApiParameterSerializationPathMatrix(parameterName: parameterName, explode: explode), + _ => throw UnimplementedError('Invalid style value for path.') + }; + } +} + +class OpenApiParameterSerializationPathSimple + extends OpenApiParameterSerializationPath { + const OpenApiParameterSerializationPathSimple({ + required super.explode, + required super.parameterName, + }); + + @override + String modifyTemplateToRFC6570(String template) { + return template.replaceAll( + oldParameterPlaceHolder, + '{$parameterName$appendExplode}', + ); + } +} + +class OpenApiParameterSerializationPathLabel + extends OpenApiParameterSerializationPath { + const OpenApiParameterSerializationPathLabel({ + required super.explode, + required super.parameterName, + }); + + @override + String modifyTemplateToRFC6570(String template) { + return template.replaceAll( + oldParameterPlaceHolder, + '{.$parameterName$appendExplode}', + ); + } +} + +class OpenApiParameterSerializationPathMatrix + extends OpenApiParameterSerializationPath { + const OpenApiParameterSerializationPathMatrix({ + required super.explode, + required super.parameterName, + }); + + @override + String modifyTemplateToRFC6570(String template) { + return template.replaceAll( + oldParameterPlaceHolder, + '{;$parameterName$appendExplode}', + ); + } +} + +// in: query ------------------ + +abstract class OpenApiParameterSerializationQuery + extends OpenApiParameterSerialization { + const OpenApiParameterSerializationQuery({ + required super.explode, + required super.parameterName, + required this.allowEmptyValue, + }); + + factory OpenApiParameterSerializationQuery.fromStyle(String style, { + required bool explode, + required String parameterName, + required bool allowEmptyValue, + }) { + return switch (style) { + 'form' => OpenApiParameterSerializationQueryForm(parameterName: parameterName, explode: explode, allowEmptyValue: allowEmptyValue), + 'spaceDelimited' => OpenApiParameterSerializationQuerySpaceDelimited(parameterName: parameterName, explode: explode, allowEmptyValue: allowEmptyValue), + 'pipeDelimited' => OpenApiParameterSerializationQueryPipeDelimited(parameterName: parameterName, explode: explode, allowEmptyValue: allowEmptyValue), + 'deepObject' => OpenApiParameterSerializationQueryDeepObject(parameterName: parameterName, explode: explode, allowEmptyValue: allowEmptyValue), + _ => throw UnimplementedError('Invalid style value for path.') + }; + } + + final bool allowEmptyValue; + + /// The templates passed here are valid [Uri]s missing query parameters + Uri expandUri(Uri template, Object? value) { + if ((value == null || + (value is String && value.isEmpty) || + (value is Iterable && value.isEmpty)) && + !allowEmptyValue) { + return template; + } + + final key = Uri.encodeComponent(parameterName); + var expanded = StdUriTemplate.expand('{?$key$appendExplode}', { + key: value, + }); + if (expanded.startsWith('?')) { + expanded = expanded.substring(1); + } + final uriWithExpanded = Uri(query: expanded); + + return template.replace(queryParameters: { + ...template.queryParameters, + ...uriWithExpanded.queryParameters, + }); + } +} + +// Default behavior is the same as [OpenApiParameterSerializationQuery]. +class OpenApiParameterSerializationQueryForm + extends OpenApiParameterSerializationQuery { + const OpenApiParameterSerializationQueryForm({ + required super.explode, + required super.parameterName, + required super.allowEmptyValue, + }); +} + +class OpenApiParameterSerializationQuerySpaceDelimited + extends OpenApiParameterSerializationQuery { + const OpenApiParameterSerializationQuerySpaceDelimited({ + required super.explode, + required super.parameterName, + required super.allowEmptyValue, + }); + + @override + Uri expandUri( + Uri template, + Object? value, + ) { + if (value is Iterable) { + value = value.join(' '); + } + + return super.expandUri(template, value); + } +} + +class OpenApiParameterSerializationQueryPipeDelimited + extends OpenApiParameterSerializationQuery { + const OpenApiParameterSerializationQueryPipeDelimited({ + required super.explode, + required super.parameterName, + required super.allowEmptyValue, + }); + + @override + Uri expandUri( + Uri template, + Object? value, + ) { + if (value is Iterable) { + value = value.join('|'); + } + + return super.expandUri(template, value); + } +} + +class OpenApiParameterSerializationQueryDeepObject + extends OpenApiParameterSerializationQuery { + const OpenApiParameterSerializationQueryDeepObject({ + required super.explode, + required super.parameterName, + required super.allowEmptyValue, + }); + + @override + Uri expandUri( + Uri template, + Object? value, + ) { + if (value is Map) { + return template.replace(queryParameters: { + ...template.queryParameters, + ...value.map( + (key, v) => MapEntry('$parameterName[$key]', v), + ), + }); + } + return super.expandUri(template, value); + } +} + +// in: header ------------------ + +class OpenApiParameterSerializationHeader + extends OpenApiParameterSerialization { + const OpenApiParameterSerializationHeader({ + required super.explode, + required super.parameterName, + }); + + //Style is always "simple" + String serialize(Object? value) { + return StdUriTemplate.expand('{v$appendExplode}', { + 'v': value, + }); + } +} + +// in: cookie ------------------ + +/// WARNING: this is not properly implemented. +/// see https://github.com/OAI/OpenAPI-Specification/issues/2940 +class OpenApiParameterSerializationCookie + extends OpenApiParameterSerialization { + const OpenApiParameterSerializationCookie({ + required super.explode, + required super.parameterName, + }); + + String serialize(Object? value) { + return StdUriTemplate.expand('{$parameterName$appendExplode}', { + parameterName: value, + }); + } +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/primitive_reflection.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/primitive_reflection.mustache new file mode 100644 index 000000000000..6e0acadbb705 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/primitive_reflection.mustache @@ -0,0 +1,744 @@ +import 'package:{{pubName}}/_internal.dart'; + +import 'package:collection/collection.dart'; + +abstract class PrimitiveReflection + with + SerializationReflection, + InheritanceBasedSerializationReflection { + const PrimitiveReflection(); + + static const fornum = NumReflection(); + static const forint = IntReflection(); + static const fordouble = DoubleReflection(); + static const forbool = BoolReflection(); + static const forString = StringReflection(); + static const forUint8List = Uint8ListReflection(); + static const forDateTime = DateTimeReflection(); + static const forXFile = XFileReflection(); + static const forObject = ObjectReflection(); + static const for$FreeFormObject = $FreeFormObjectReflection; +} + +class ObjectReflection extends PrimitiveReflection + implements Equality { + const ObjectReflection(); + static const basicReflections = >[ + PrimitiveReflection.fornum, + PrimitiveReflection.forbool, + PrimitiveReflection.forDateTime, + ListReflection(NullableReflection(PrimitiveReflection.forObject)), + MapReflection(NullableReflection(PrimitiveReflection.forObject)), + PrimitiveReflection.forString, + ]; + static const aggregatedReflections = [ + ...basicReflections, + ...generatedClassReflectionsList, + ]; + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src == null) { + // It's impossible to know the reflection of a null object. + return false; + } + final reflection = context.deserializeReflectionResolver?.call(src); + if (reflection != null) { + return reflection.canDeserializeFunction(src, context); + } + // If deserialization fails we just return the object itself + return true; + } + + @override + Object deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src == null) { + throw ArgumentError.notNull('src'); + } + var subReflection = context.deserializeReflectionResolver?.call(src) ?? + basicReflections + .firstWhereOrNull((x) => x.canDeserializeFunction(src, context)); + if (subReflection == null) { + //return it as is. + return src; + } + return subReflection.deserializeFunction(src, context); + } + + /// Attempts to discover the reflection of a given input that was received in + /// either [deserialize] or [canDeserialize]. + /// + /// It first asks the context if it has a result by calling [SerializationContext.deserializeReflectionResolver]. + /// + /// If it fails, it iteratively checks every item in [basicReflections], and + /// calls [canDeserialize] on each of them, until a reflection returns true. + static SerializationReflection? discoverDeserializeReflection( + Object? src, + SerializationContext context, + ) { + final resolvedResult = context.deserializeReflectionResolver?.call(src); + if (resolvedResult != null) { + return resolvedResult; + } + + return basicReflections + .firstWhereOrNull((x) => x.canDeserializeFunction(src)); + } + + /// It checks if the src object is a [ReflectionOverrideWrapper], and returns its + /// reflection. + /// + /// If it fails, it checks if the src object implements [$OpenApiObjectMixin], + /// and returns its reflection via [$OpenApiObjectMixin.$classReflection]. + /// + /// If it fails, it iteratively checks every item in [aggregatedReflections], and + /// calls [isInstanceOfType] on each of them, until a reflection returns true. + static SerializationReflection? discoverDartObjectReflection( + Object src, + ) { + if (src is ReflectionOverrideWrapper) { + return src.reflection; + } + if (src is $OpenApiObjectMixin) { + return src.$classReflection; + } + + return basicReflections.firstWhereOrNull((x) => x.isInstanceOfType(src)); + } + + /// Attempts to discover the reflection of a given input that was received in + /// a [serialize] call. + /// + /// It first asks the context if it has a result by calling [SerializationContext.serializeReflectionResolver]. + /// + /// If it fails, it checks if the src object implements [$OpenApiObjectMixin], + /// and returns its reflection via [$OpenApiObjectMixin.$classReflection]. + /// + /// If it fails, it iteratively checks every item in [aggregatedReflections], and + /// calls [isInstanceOfType] on each of them, until a reflection returns true. + static SerializationReflection? discoverSerializeReflection( + Object src, + SerializationContext context, + ) { + final resolvedResult = context.serializeReflectionResolver?.call(src); + if (resolvedResult != null) { + return resolvedResult; + } + return discoverDartObjectReflection(src); + } + + @override + Object? serialize( + Object src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final subReflection = discoverSerializeReflection(src, context); + if (subReflection == null) { + //return it as is. + return src; + } + return subReflection.serializeFunction(src, context); + } + + // aggregate primitive equalities. + static final _slowEquality = MultiEquality( + basicReflections.map((e) => e.equality).toList(growable: false), + ); + + @override + Equality get equality => this; + + @override + Object empty() => 0; + + @override + Object example([ExampleContext? context]) { + context ??= ExampleContext(); + final selectedReflectionIndex = + context.random.nextInt(basicReflections.length); + return basicReflections[selectedReflectionIndex].exampleFunction(context); + } + + @override + bool equals(Object e1, Object e2) { + // attempt naïve equality by checking == operator. + // + // this will work on generated models and ReflectionOverrideWrapper, + // but won't work on some primitives like XFile, Uint8List. + // + // which is why we need to check other cases as well. + if (e1 == e2) { + return true; + } + // extract the true value if ReflectionOverrideWrapper is used. + final trueE1 = e1 is ReflectionOverrideWrapper ? e1.value : e1; + final trueE2 = e2 is ReflectionOverrideWrapper ? e2.value : e2; + // attempt to extract reflection if provided via ReflectionOverrideWrapper. + final e1Reflection = discoverDartObjectReflection(e1); + final e2Reflection = discoverDartObjectReflection(e2); + // two objects are equal if any of the discovered reflections say that they are equal. + if (e1Reflection != null) { + final e1Eq = e1Reflection.equality; + return e1Eq.isValidKey(trueE1) && + e1Eq.isValidKey(trueE2) && + e1Eq.equals(trueE1, trueE2); + } + if (e2Reflection != null) { + final e2Eq = e2Reflection.equality; + return e2Eq.isValidKey(trueE1) && + e2Eq.isValidKey(trueE2) && + e2Eq.equals(trueE1, trueE2); + } + // if no reflection was discovered, use the iterative equality. + return _slowEquality.equals(e1, e2); + } + + @override + int hash(Object e) { + final discoveredReflection = discoverDartObjectReflection(e); + if (discoveredReflection != null) { + return discoveredReflection.equality.hash(e); + } + return e.hashCode; + } + + @override + bool isValidKey(Object? o) { + // any non-null object works. + return o != null; + } + + @override + Object clone(Object src) { + final discoveredReflection = discoverDartObjectReflection(src); + if (discoveredReflection != null) { + return discoveredReflection.cloneFunction(src) as Object; + } + return src; + } +} + +class NumReflection extends PrimitiveReflection { + const NumReflection(); + + @override + num clone(num src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is num || + (const StringReflection().canDeserialize(src, context) && + num.tryParse( + const StringReflection().deserialize(src, context)) != + null), + onXml: (context) => + const StringReflection().canDeserialize(src, context) && + num.tryParse(const StringReflection().deserialize(src, context)) != + null, + ); + } + + @override + num deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src is num + ? src + : num.parse(const StringReflection().deserialize(src, context)), + onXml: (context) => + num.parse(const StringReflection().deserialize(src, context)), + ); + } + + @override + Object? serialize( + num src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src, + onXml: (context) => + PrimitiveReflection.forString.serialize(src.toString(), context), + ); + } + + @override + num empty() => 0; + + @override + num example([ExampleContext? context]) { + return (context ??= ExampleContext()).random.nextDouble(); + } +} + +class IntReflection extends PrimitiveReflection { + const IntReflection(); + + @override + int clone(int src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is int || + (const StringReflection().canDeserialize(src, context) && + int.tryParse( + const StringReflection().deserialize(src, context)) != + null), + onXml: (context) => + const StringReflection().canDeserialize(src, context) && + int.tryParse(const StringReflection().deserialize(src, context)) != + null, + ); + } + + @override + int deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src is int + ? src + : int.parse(const StringReflection().deserialize(src, context)), + onXml: (context) => + int.parse(const StringReflection().deserialize(src, context)), + ); + } + + @override + Object? serialize( + int src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src, + onXml: (context) => + PrimitiveReflection.forString.serialize(src.toString(), context), + ); + } + + @override + int empty() => 0; + + @override + int example([ExampleContext? context]) => + (context ??= ExampleContext()).random.nextInt(100); +} + +class DoubleReflection extends PrimitiveReflection { + const DoubleReflection(); + @override + double clone(double src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return const NumReflection().canDeserialize(src, context); + } + + @override + double deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return const NumReflection().deserialize(src, context).toDouble(); + } + + @override + Object? serialize( + double src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return PrimitiveReflection.fornum.serialize(src, context); + } + + @override + double empty() => 0; + + @override + double example([ExampleContext? context]) => + (context ??= ExampleContext()).random.nextDouble(); +} + +class StringReflection extends PrimitiveReflection { + const StringReflection(); + @override + String clone(String src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => true, + onXml: (context) => src is XmlNode, + ); + } + + @override + String deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src.toString(), + onXml: (context) => (src as XmlNode).value ?? src.innerText, + ); + } + + @override + Object? serialize( + String src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src, + onXml: (context) => XmlText(src), + ); + } + + @override + String empty() => ""; + + @override + String example([ExampleContext? context]) => + 'random_string_${(context ??= ExampleContext()).random.nextInt(100)}'; +} + +class BoolReflection extends PrimitiveReflection { + const BoolReflection(); + @override + bool clone(bool src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is bool || + (PrimitiveReflection.forString.canDeserialize(src, context) && + bool.tryParse(PrimitiveReflection.forString + .deserialize(src, context)) != + null), + onXml: (context) => + PrimitiveReflection.forString.canDeserialize(src, context) && + bool.tryParse( + PrimitiveReflection.forString.deserialize(src, context)) != + null, + ); + } + + @override + bool deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src is bool + ? src + : bool.parse(PrimitiveReflection.forString.deserialize(src, context)), + onXml: (context) => + bool.parse(PrimitiveReflection.forString.deserialize(src, context)), + ); + } + + @override + Object? serialize( + bool src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src, + onXml: (context) => + PrimitiveReflection.forString.serialize(src.toString(), context), + ); + } + + @override + bool empty() => false; + + @override + bool example([ExampleContext? context]) => + (context ??= ExampleContext()).random.nextBool(); +} + +class Uint8ListEquality extends StrictEquality { + const Uint8ListEquality(); + + static const subEq = ListEquality(StrictEquality()); + + @override + bool equals(Uint8List e1, Uint8List e2) { + return subEq.equals(e1, e2); + } + + @override + int hash(Uint8List e) { + return subEq.hash(e); + } + + @override + bool isValidKey(Object? o) { + return subEq.isValidKey(o); + } +} + +class Uint8ListReflection extends PrimitiveReflection { + const Uint8ListReflection(); + @override + Uint8List clone(Uint8List src) { + return Uint8List.fromList(src); + } + + static bool isBase64String(String src) { + final regex = RegExp( + r'^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$', + ); + return regex.hasMatch(src); + } + + @override + Equality get equality => const Uint8ListEquality(); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + // src MUST be base64 string + return context.split( + onJson: (context) => + src is Uint8List || + (PrimitiveReflection.forString.canDeserialize(src, context) && + isBase64String( + PrimitiveReflection.forString.deserialize(src, context))), + onXml: (context) => + PrimitiveReflection.forString.canDeserialize(src, context) && + isBase64String( + PrimitiveReflection.forString.deserialize(src, context)), + ); + } + + @override + Uint8List deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src is Uint8List + ? src + : base64 + .decode(PrimitiveReflection.forString.deserialize(src, context)), + onXml: (context) => base64 + .decode(PrimitiveReflection.forString.deserialize(src, context)), + ); + } + + @override + Object? serialize( + Uint8List src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final encoded = base64.encode(src); + return context.split( + onJson: (context) => encoded, + onXml: (context) => + PrimitiveReflection.forString.serialize(encoded, context), + ); + } + + @override + Uint8List empty() => Uint8List(0); + + @override + Uint8List example([ExampleContext? context]) { + context ??= ExampleContext(); + final len = context.random.nextInt(50); + return Uint8List(len)..fillRange(0, len, context.random.nextInt(255)); + } +} + +class DateTimeReflection extends PrimitiveReflection { + const DateTimeReflection(); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src is DateTime) { + return true; + } + return PrimitiveReflection.forString.canDeserialize(src) && + DateTime.tryParse( + PrimitiveReflection.forString.deserialize(src, context)) != + null; + } + + @override + DateTime deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src is DateTime) { + return src; + } + return DateTime.parse( + PrimitiveReflection.forString.deserialize(src, context), + ); + } + + @override + Object? serialize( + DateTime src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return PrimitiveReflection.forString.serialize( + src.toIso8601String(), + context, + ); + } + + @override + DateTime empty() => DateTime.fromMillisecondsSinceEpoch(0, isUtc: true); + + @override + DateTime example([ExampleContext? context]) { + context ??= ExampleContext(); + return DateTime.fromMillisecondsSinceEpoch( + context.random.nextInt(4294967296) + + context.random.nextInt(4294967296) + + context.random.nextInt(4294967296), + isUtc: true, + ); + } + + @override + DateTime clone(DateTime src) { + return src; + } +} + +class XFileReflection extends PrimitiveReflection + implements Equality { + const XFileReflection(); + // XFiles are read only anyway, so we return them as is. + @override + XFile clone(XFile src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + // for now, treat files the same as bytes. + if (src is XFile) { + return true; + } + return PrimitiveReflection.forUint8List.canDeserialize(src, context); + } + + @override + XFile deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src is XFile) { + return src; + } + final data = PrimitiveReflection.forUint8List.deserialize(src, context); + final name = "unknown"; + return XFile.fromData( + data, + name: name, + path: '/$name', + length: data.lengthInBytes, + mimeType: "application/octet-stream", + ); + } + + @override + Object? serialize( + XFile src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final bytes = context.fileBytesResolver?.call(src); + if (bytes != null) { + return PrimitiveReflection.forUint8List.serialize(bytes, context); + } + return src; + } + + @override + XFile empty() => XFile.fromData(PrimitiveReflection.forUint8List.empty(), + name: '', length: 0); + + @override + XFile example([ExampleContext? context]) { + context ??= ExampleContext(); + final data = PrimitiveReflection.forUint8List.example(context); + final name = PrimitiveReflection.forString.example(context) + ".txt"; + context.fileCache[name] = data; + return XFile.fromData( + data, + name: name, + path: '/$name', + length: data.lengthInBytes, + mimeType: "text/plain", + ); + } + + @override + Equality get equality => this; + @override + bool equals(XFile e1, XFile e2) { + if (identical(e1, e2)) return true; + return e1.path == e2.path && + e1.mimeType == e2.mimeType && + e1.name == e2.name; + } + + @override + int hash(XFile e) { + return Object.hash(e.path, e.mimeType, e.name); + } + + @override + bool isValidKey(Object? o) { + return o is XFile; + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/reflection.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/reflection.mustache new file mode 100644 index 000000000000..9140f8059855 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/reflection.mustache @@ -0,0 +1,194 @@ +import 'package:{{pubName}}/_internal.dart'; +import 'package:collection/collection.dart'; + +class StrictEquality implements Equality { + const StrictEquality(); + + @override + bool equals(T e1, T e2) => e1 == e2; + + @override + int hash(T e) { + return e.hashCode; + } + + @override + bool isValidKey(Object? o) { + return o is T; + } +} + +mixin SerializationReflection { + SerializationFunction get deserializeFunction; + SerializationFunction get canDeserializeFunction; + SerializationFunction get serializeFunction; + + T Function([ExampleContext?]) get exampleFunction; + T Function() get emptyFunction; + Equality get equality => StrictEquality(); + FunctionWrapper1 get cloneFunction; + + /// check if an instance can be reflected using this reflection. + bool isInstanceOfType( + Object? instance, [ + SerializationContext context = const SerializationContext.json(), + ]) => + instance is T; + + /// check if a `TOther Function()` is assignable to `T Function()`, + /// meaning that [TOther] is assignable to -and thus a subtype of- [T]. + /// + /// A reflection can reflect a type as long as [TOther] is assignable to [T]. + bool canReflectType() => + TOther == T || (() => null as TOther) is T Function(); +} + +mixin InheritanceBasedSerializationReflection on SerializationReflection { + @override + SerializationFunction get canDeserializeFunction => + SerializationFunction(canDeserialize); + bool canDeserialize(Object? src, + [SerializationContext context = const SerializationContext.json()]); + + @override + SerializationFunction get deserializeFunction => + SerializationFunction(deserialize); + T deserialize(Object? src, + [SerializationContext context = const SerializationContext.json()]); + + @override + SerializationFunction get serializeFunction => + SerializationFunction(serialize); + Object? serialize(T src, + [SerializationContext context = const SerializationContext.json()]); + + @override + T Function([ExampleContext?]) get exampleFunction => example; + T example([ExampleContext? context]); + + @override + T Function() get emptyFunction => empty; + T empty(); + + @override + FunctionWrapper1 get cloneFunction => FunctionWrapper1(clone); + T clone(T src); +} + +class DelegatingSerializationReflection with SerializationReflection { + @override + final SerializationFunction serializeFunction; + @override + final SerializationFunction canDeserializeFunction; + @override + final SerializationFunction deserializeFunction; + + @override + final T Function() emptyFunction; + @override + final T Function([ExampleContext? p1]) exampleFunction; + + @override + final Equality equality; + @override + final FunctionWrapper1 cloneFunction; + + const DelegatingSerializationReflection({ + required this.serializeFunction, + required this.canDeserializeFunction, + required this.deserializeFunction, + required this.emptyFunction, + required this.exampleFunction, + required this.equality, + required this.cloneFunction, + }); +} + +/// A special wrapper to be used in Map or Iterable, +/// where the type information of the object is lost. +/// +/// e.g. +/// +/// final serialized = MapReflection(NullableReflection(PrimitiveReflection.forObject)).serialize({ +/// // this will use the default string reflection +/// 'a': 'b' +/// // this uses a special enum reflection +/// 'c': ReflectionOverrideWrapper( +/// value: 'z', +/// reflection: MyEnumReflection.instance, +/// ), +/// // now we know that this null actually represents `num?`. +/// 'd': ReflectionOverrideWrapper( +/// value: null, +/// reflection: NullableReflection(PrimitiveReflection.fornum) +/// ) +/// }, SerializationContext.json()); +class ReflectionOverrideWrapper { + final T value; + final SerializationReflection reflection; + + const ReflectionOverrideWrapper({ + required this.value, + required this.reflection, + }); + + @override + bool operator ==(Object other) { + final otherValue = + other is ReflectionOverrideWrapper ? other.value : other; + return otherValue is T && + reflection.equality.isValidKey(otherValue) && + reflection.equality.equals(value, otherValue); + } + + @override + int get hashCode => reflection.equality.hash(value); +} + +class OasNameWrapper with HasOasName { + @override + final String oasName; + + const OasNameWrapper({ + required this.oasName, + }); +} + +mixin HasOasName { + String get oasName; +} + +// see https://github.com/dart-lang/sdk/issues/56231 for reason why this is needed. +extension type const SerializationFunction.unsafe(Function fn) { + const SerializationFunction( + TOut Function(TIn, [SerializationContext context]) src, + ) : this.unsafe(src); + + TOut call( + TIn value, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return fn(value, context) as TOut; + } +} +extension type const FunctionWrapper1.unsafe(Function fn) { + const FunctionWrapper1(TOut Function(TIn1) src) : this.unsafe(src); + TOut call(TIn1 value1) { + return fn(value1) as TOut; + } +} +extension type const FunctionWrapper2.unsafe(Function fn) { + const FunctionWrapper2(TOut Function(TIn1, TIn2) src) : this.unsafe(src); + TOut call(TIn1 value1, TIn2 value2) { + return fn(value1, value2) as TOut; + } +} +extension type const FunctionWrapper3.unsafe( + Function fn) { + const FunctionWrapper3(TOut Function(TIn1, TIn2, TIn3) src) + : this.unsafe(src); + + TOut call(TIn1 value1, TIn2 value2, TIn3 value3) { + return fn(value1, value2, value3) as TOut; + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/xml_extensions.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/xml_extensions.mustache new file mode 100644 index 000000000000..3deb912896df --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/xml_extensions.mustache @@ -0,0 +1,105 @@ +import 'package:xml/xml.dart'; +import 'package:openapi_infrastructure/openapi_infrastructure.dart'; + +extension UndefinedWrapperXmlNodeExtensions on XmlNode { + Map readNormalized() { + final srcMap = >{}; + for (final child in children.followedBy(attributes)) { + String? srcMapKey; + if (child case XmlHasName namedChild) { + srcMapKey = namedChild.name.qualified; + } + final nodes = srcMap[srcMapKey] ??= []; + nodes.add(child); + } + final srcNormalized = srcMap.map( + (key, value) => MapEntry( + key, + value.normalize(), + ), + ); + return srcNormalized; + } + UndefinedWrapper getElementOrUndefined( + String key, { + String? namespace, + }) { + final element = getElement(key, namespace: namespace); + if (element == null) { + return UndefinedWrapper.undefined(); + } else { + return UndefinedWrapper(element); + } + } + + UndefinedWrapper getElementOrUndefinedMapped( + String key, + T Function(XmlElement src) mapper, { + String? namespace, + }) { + return getElementOrUndefined(key, namespace: namespace).map(mapper); + } + + T getElementRequiredMapped( + String key, + T Function(XmlElement src) mapper, { + String? namespace, + }) { + final element = getElement(key, namespace: namespace); + if (element == null) { + throw ArgumentError( + 'Element ($key) is not present in the Node, but it is required.', + 'key', + ); + } else { + return mapper(element); + } + } + + UndefinedWrapper getAttributeOrUndefined( + String key, { + String? namespace, + }) { + final element = getAttributeNode(key, namespace: namespace); + if (element == null) { + return UndefinedWrapper.undefined(); + } else { + return UndefinedWrapper(element); + } + } + + UndefinedWrapper getAttributeOrUndefinedMapped( + String key, + T Function(XmlAttribute src) mapper, { + String? namespace, + }) { + return getAttributeOrUndefined(key, namespace: namespace).map(mapper); + } + + T getAttributeRequiredMapped( + String key, + T Function(XmlAttribute src) mapper, { + String? namespace, + }) { + final element = getAttributeNode(key, namespace: namespace); + if (element == null) { + throw ArgumentError( + 'Element ($key) is not present in the Node, but it is required.', + 'key', + ); + } else { + return mapper(element); + } + } +} + +extension XmlNodeListExtensions on Iterable { + XmlNode normalize() { + final length = this.length; + return length == 0 + ? XmlDocumentFragment([]) + : length == 1 + ? first + : XmlDocumentFragment(this.map((e) => e.copy())); + } +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/xml_reflection.mustache b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/xml_reflection.mustache new file mode 100644 index 000000000000..2ebc7d73e50a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/lib/src/serialization/xml_reflection.mustache @@ -0,0 +1,40 @@ +import 'package:{{pubName}}/_internal.dart'; + +mixin HasXmlReflection { + XmlReflection get xml; +} + +class XmlReflection { + const XmlReflection({ + this.xmlName, + this.namespace, + this.prefix, + this.attribute = false, + this.wrapped = false, + }); + + final String? xmlName; + final String? namespace; + final String? prefix; + final bool attribute; + final bool wrapped; + + XmlName getQualifiedName(String fallbackName) { + return XmlName(xmlName ?? fallbackName, prefix); + } + + XmlName? getQualifiedNameOrNull(String? fallbackName) { + final actualName = xmlName ?? fallbackName; + if (actualName == null) { + return null; + } + return XmlName(actualName, prefix); + } + + XmlAttribute? getXmlNamespaceAttribute() { + if (prefix == null || namespace == null) { + return null; + } + return XmlAttribute(XmlName(prefix!, 'xmlns'), namespace!); + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/pubspec.mustache b/modules/openapi-generator/src/main/resources/dart-next/pubspec.mustache new file mode 100644 index 000000000000..2f2d85348c55 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/pubspec.mustache @@ -0,0 +1,28 @@ +name: {{pubName}} +version: {{pubVersion}} +description: {{pubDescription}} +homepage: {{pubHomepage}} +{{#pubRepository}} +repository: {{.}} +{{/pubRepository}} +{{#pubPublishTo}} +publish_to: {{.}} +{{/pubPublishTo}} + +environment: + sdk: '>=3.4.3 <4.0.0' + +# Add regular dependencies here. +dependencies: + http: ^1.2.1 + xml: ^6.5.0 + std_uritemplate: ^1.0.1 + collection: ^1.19.0 + http_parser: ^4.1.0 + cross_file: '>=0.3.4+1 <1.0.0' + openapi_infrastructure: ^2.0.1 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 + parameterized_test: ^2.0.0 diff --git a/modules/openapi-generator/src/main/resources/dart-next/test/apis/api_tests.mustache b/modules/openapi-generator/src/main/resources/dart-next/test/apis/api_tests.mustache new file mode 100644 index 000000000000..37f6aa24e9eb --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/test/apis/api_tests.mustache @@ -0,0 +1,29 @@ +import 'package:test/test.dart'; +import 'package:{{pubName}}/_internal.dart'; +import '../utils.dart'; + +{{#operations}} +/// tests for {{{classname}}} +void main() { + final wireOptions = WireSerializationOptions(); + final exampleContext = ExampleContext(); + group({{{classname}}}, () { + final baseUrl = Uri.https("example.com", "/api"); + {{#operation}} + {{#summary}} + // {{{.}}} + // + {{/summary}} + {{#notes}} + // {{{.}}} + // + {{/notes}} + group(r'{{{operationId}}}', () { + {{>test/apis/request_tests}} + + {{>test/apis/response_tests}} + }); + {{/operation}} + }); +} +{{/operations}} diff --git a/modules/openapi-generator/src/main/resources/dart-next/test/apis/param_examples.mustache b/modules/openapi-generator/src/main/resources/dart-next/test/apis/param_examples.mustache new file mode 100644 index 000000000000..82cc246e93e5 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/test/apis/param_examples.mustache @@ -0,0 +1,3 @@ +{{#allParams}}{{^isFormParam}}{{^isBodyParam}} +{{paramName}}: {{>types/reflection}}.exampleFunction(exampleContext), +{{/isBodyParam}}{{/isFormParam}}{{/allParams}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/test/apis/request_tests.mustache b/modules/openapi-generator/src/main/resources/dart-next/test/apis/request_tests.mustache new file mode 100644 index 000000000000..bee16b730f78 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/test/apis/request_tests.mustache @@ -0,0 +1,59 @@ +group({{classname}}{{operationIdCamelCase}}Request, () { + late {{classname}}{{operationIdCamelCase}}Request request; + {{^bodyAllowed}} + test(r'No Body', () async { + request = {{classname}}{{operationIdCamelCase}}Request( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + {{>test/apis/param_examples}} + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + {{/bodyAllowed}} + {{#bodyAllowed}} + test({{classname}}{{operationIdCamelCase}}RequestUnsafe, () async { + request = {{classname}}{{operationIdCamelCase}}Request.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + {{>test/apis/param_examples}} + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + {{#vendorExtensions}}{{#better-consumes}}{{#content}}{{#schema}} + test({{classname}}{{operationIdCamelCase}}Request{{nameInPascalCase}}, () async { + request = {{classname}}{{operationIdCamelCase}}Request.{{nameInCamelCase}}( + data: {{classname}}{{operationIdCamelCase}}Request{{nameInPascalCase}}.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + {{>test/apis/param_examples}} + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + {{/schema}}{{/content}}{{/better-consumes}}{{/vendorExtensions}} + {{/bodyAllowed}} +}); \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/test/apis/response_tests.mustache b/modules/openapi-generator/src/main/resources/dart-next/test/apis/response_tests.mustache new file mode 100644 index 000000000000..ab095e1beb6b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/test/apis/response_tests.mustache @@ -0,0 +1,90 @@ +group({{>lib/src/apis/response/response_class}}, () { + late {{>lib/src/apis/response/response_class}} response; + test('Unkown status code', () async { + response = await {{>lib/src/apis/response/response_class}}.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA<{{>lib/src/apis/response/response_class}}>() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + {{#responses}} + group({{>lib/src/apis/response/response_class_code}}, () { + test('Unknown mime', () async { + final codeExample = {{>lib/src/apis/response/code_example}}; + response = await {{>lib/src/apis/response/response_class}}.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA<{{>lib/src/apis/response/response_class_code}}>() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + {{#content}}{{#entrySet}}{{#value}}{{#schema}} + test({{>lib/src/apis/response/response_class_code_mime}}, () async { + final codeExample = {{>lib/src/apis/response/code_example}}; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'{{key}}')); + final bodyReflection = {{>lib/src/apis/response/response_class_code_mime}}.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + {{#vendorExtensions}} + {{#is_mime_application_json}} + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + {{/is_mime_application_json}} + {{#is_mime_text}} + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + {{/is_mime_text}} + {{#is_mime_application_xml}} + finalValue = serializedBody; + {{/is_mime_application_xml}} + {{#is_mime_application_x-www-form-urlencoded}} + finalValue = serializedBody is Map ? OASNetworkingUtils.formUrlEncoded(serializedBody, {}) : serializedBody.toString(); + {{/is_mime_application_x-www-form-urlencoded}} + {{/vendorExtensions}} + + response = await {{>lib/src/apis/response/response_class}}.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + {{/schema}}{{/value}}{{/entrySet}}{{/content}} + }); + {{/responses}} + +}); \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/test/models/model_tests.mustache b/modules/openapi-generator/src/main/resources/dart-next/test/models/model_tests.mustache new file mode 100644 index 000000000000..e39bc30f3da9 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/test/models/model_tests.mustache @@ -0,0 +1,84 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +{{#models}} +{{#model}} +void main() { + group(r'{{{classname}}}', () { + final reflection = {{{classname}}}.$reflection; + final exampleContext = ExampleContext(); + {{#isEnum}} + test('values not empty', () { + expect({{{classname}}}.values, isNotEmpty); + }); + + test('unsafe', () { + final example = reflection.subReflection.exampleFunction(exampleContext); + expect({{{classname}}}.$unsafe(example), example); + }); + + {{#allowableValues}}{{#enumVars}} + test(r'{{name}}', () { + expect({{{classname}}}.{{name}}().value, {{#isString}}r{{/isString}}{{{value}}}); + }); + {{/enumVars}}{{/allowableValues}} + {{/isEnum}} + {{^isEnum}} + + late {{{classname}}} exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect({{{classname}}}.canDeserialize(roundTripped, context), isTrue); + + final deserialized = {{{classname}}}.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + {{/isEnum}} + }); +} +{{/model}} +{{/models}} diff --git a/modules/openapi-generator/src/main/resources/dart-next/test/networking/helpers_test.mustache b/modules/openapi-generator/src/main/resources/dart-next/test/networking/helpers_test.mustache new file mode 100644 index 000000000000..286346fccac2 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/test/networking/helpers_test.mustache @@ -0,0 +1,8 @@ +import '../utils.dart'; +import 'package:test/test.dart'; + +void main() { + group('OASNetworkingUtils', () { + test('works',(){}); + }); +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/test/serialization/helpers_test.mustache b/modules/openapi-generator/src/main/resources/dart-next/test/serialization/helpers_test.mustache new file mode 100644 index 000000000000..f64643fbcec2 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/test/serialization/helpers_test.mustache @@ -0,0 +1,66 @@ +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; +import 'package:test/test.dart'; +import 'package:{{pubName}}/_internal.dart'; + +void main() { + group('Serialization Helpers', () { + parameterizedTest( + 'Uint8ListReflection.isBase64String', + [ + ['invalid string', false, null], + ['SGVsbG8gd29ybGQgIQ==', true, 'Hello world !'], + ['IA==', true, ' '], + ], + (String input, bool result, String? original) { + expect(Uint8ListReflection.isBase64String(input), result); + if (result) { + expect(utf8.decode(base64.decode(input)), original); + } + }, + ); + }); + + group('XML Reflection', () { + test( + 'test wrapped array', + () { + final rootXml = XmlReflection( + prefix: r'kl', + wrapped: true, + ); + final propReflection = UndefinedWrapperReflection(XmlReflectionWrapper( + xml: rootXml, + ListReflection(XmlReflectionWrapper( + xml: XmlReflection(prefix: r'mn', xmlName: r'my_item'), + PrimitiveReflection.forint, + )), + )); + final context = XmlSerializationContext() + .withOasNameContainer(OasNameWrapper(oasName: 'my_list')); + final serialized1 = context.handleAttributes( + rootXml, + context.wrapSerializedValue( + rootXml.getQualifiedName('my_list'), + propReflection.serialize( + UndefinedWrapper([]), + context, + ), + ), + ); + print(serialized1); + final serialized2 = context.handleAttributes( + rootXml, + context.wrapSerializedValue( + rootXml.getQualifiedName('my_list'), + propReflection.serialize( + UndefinedWrapper([1, 2, 3]), + context, + ), + ), + ); + print(serialized2); + }, + ); + }); +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/test/utils.mustache b/modules/openapi-generator/src/main/resources/dart-next/test/utils.mustache new file mode 100644 index 000000000000..82ba07dad98d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/test/utils.mustache @@ -0,0 +1,325 @@ +import 'package:{{pubName}}/_internal.dart'; +import 'package:test/test.dart'; + +HttpResponseBase createFakeResponse({ + required int statusCode, + required Stream> bodyBytesStream, + Map headers = const {}, + String? contentType, + String? reasonPhrase, +}) { + return HttpResponseBase.stream( + originalRequest: HttpRequestBase.empty( + url: Uri.https("example.com", "/api"), method: 'GET'), + bodyBytesStream: bodyBytesStream, + statusCode: statusCode, + reasonPhrase: reasonPhrase, + headers: CaseInsensitiveMap.from({ + if (contentType != null) 'Content-Type': contentType, + ...headers, + }), + ); +} + +Stream> streamOfText(String value, {Encoding? encoding}) async* { + yield (encoding ?? utf8).encode(value); +} + +HttpResponseBase createFakeTextResponse({ + required int statusCode, + required String value, + Map headers = const {}, + String? contentType, + Encoding? encoding, + String? reasonPhrase, +}) { + var parsedContentType = + contentType == null ? null : MediaType.parse(contentType); + if (encoding != null) { + parsedContentType = parsedContentType?.change(parameters: { + ...parsedContentType.parameters, + 'charset': encoding.name, + }); + } + return createFakeResponse( + statusCode: statusCode, + headers: { + 'Content-Type': 'text/plain; charset=utf-8', + if (parsedContentType != null) + 'Content-Type': parsedContentType.toString(), + ...headers, + }, + reasonPhrase: reasonPhrase, + bodyBytesStream: streamOfText(value, encoding: encoding), + ); +} + +_DeepMatcher modelEquals( + T expected, { + required ModelReflection reflection, +}) { + return _DeepMatcher( + expected, + reflection: reflection, + ignoreAdditionalPropertiesExtraKeys: + reflection.anyOfs.isNotEmpty || reflection.oneOfs.isNotEmpty, + ); +} + +class ModelEqualsMatcher extends Matcher { + const ModelEqualsMatcher( + this.expected, { + required this.reflection, + }); + + final T expected; + final ModelReflection reflection; + @override + Description describe(Description description) { + return description.addDescriptionOf(expected).addDescriptionOf(reflection); + } + + @override + bool matches(Object? item, Map matchState) { + if (item is! T) { + return false; + } + return true; + } + + @override + Description describeMismatch( + Object? item, + Description mismatchDescription, + Map matchState, + bool verbose, + ) { + return super + .describeMismatch(item, mismatchDescription, matchState, verbose); + } +} + +class _DeepMatcher extends Matcher { + final T _expected; + final ModelReflection reflection; + final bool ignoreAdditionalPropertiesExtraKeys; + _DeepMatcher( + this._expected, { + required this.reflection, + required this.ignoreAdditionalPropertiesExtraKeys, + }); + + _Mismatch? _getMismatch({ + required Object? actual, + required TModel expected, + required ModelReflection reflection, + }) { + if (actual == _expected) { + return null; + } + if (actual is! TModel) { + return _Mismatch.simple( + '', + actual, + 'expected $TModel', + reflection: reflection, + ); + } + for (final prop in reflection.properties) { + final actualValue = prop.getter(actual); + final expectedValue = prop.getter(expected); + final eq = prop.reflection.equality; + if (!eq.equals(actualValue, expectedValue)) { + return _Mismatch( + 'property[${prop.dartName}]', + actualValue, + (description, verbose) => description.addDescriptionOf(expectedValue), + instead: true, + reflection: reflection, + ); + } + } + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final actualValue = additionalPropertiesPart.getter(actual); + final expectedValue = additionalPropertiesPart.getter(expected); + var err = (expectedValue.length == actualValue.length) + ? '' + : 'has different length and '; + for (var key in expectedValue.keys) { + if (!actualValue.containsKey(key)) { + return _Mismatch( + 'additionalProperties', + actual, + (description, verbose) => description + .add('${err}is missing map key ') + .addDescriptionOf(key) + .add('where the actual map is ') + .addDescriptionOf(actualValue), + reflection: reflection, + ); + } + } + + if (!ignoreAdditionalPropertiesExtraKeys) { + for (var key in actualValue.keys) { + if (!expectedValue.containsKey(key)) { + return _Mismatch( + 'additionalProperties', + actualValue, + (description, verbose) => description + .add('${err}has extra map key ') + .addDescriptionOf(key) + .add(' where the expected map is ') + .addDescriptionOf(expectedValue), + reflection: reflection, + ); + } + } + } + + for (var key in expectedValue.keys) { + final expectedPropValue = expectedValue[key]; + final actualPropValue = actualValue[key]; + + if (!additionalPropertiesPart.itemReflection.equality + .equals(expectedPropValue, actualPropValue)) { + // + return _Mismatch( + "additionalProperties['$key']", + actualPropValue, + (description, verbose) => + description.addDescriptionOf(expectedPropValue), + reflection: reflection, + ); + } + } + } + for (final (index, oneof) in reflection.oneOfs.indexed) { + final expectedValue = oneof.getter(expected); + final actualValue = oneof.getter(actual); + + if (!oneof.reflection.equality.equals(expectedValue, actualValue)) { + return _Mismatch( + 'oneOf[$index]', + actualValue, + (description, verbose) => description.addDescriptionOf(expectedValue), + reflection: reflection, + ); + } + } + for (final (index, anyof) in reflection.anyOfs.indexed) { + final expectedValue = anyof.getter(expected); + final actualValue = anyof.getter(actual); + if (!anyof.reflection.equality.equals(expectedValue, actualValue)) { + return _Mismatch( + 'anyOf[$index]', + actualValue, + (description, verbose) => description.addDescriptionOf(expectedValue), + reflection: reflection, + ); + } + } + + return _Mismatch( + '', + actual, + (description, verbose) => description + .add( + '== resulted in false, but no reason was found to explain it', + ) + .addDescriptionOf(expected), + reflection: reflection, + ); + } + + @override + bool matches(Object? actual, Map matchState) { + if (actual is! T) { + return false; + } + final mismatch = _getMismatch( + actual: actual, + expected: _expected, + reflection: reflection, + ); + if (mismatch == null) { + return true; + } + addStateInfo(matchState, {'mismatch': mismatch}); + return false; + } + + @override + Description describe(Description description) => + description.addDescriptionOf(_expected); + + @override + Description describeMismatch(Object? item, Description mismatchDescription, + Map matchState, bool verbose) { + var mismatch = matchState['mismatch'] as _Mismatch; + var describeProblem = mismatch.describeProblem; + if (mismatch.location.isNotEmpty) { + mismatchDescription + .add('at location ') + .add(mismatch.location) + .add(' is ') + .addDescriptionOf(mismatch.actual); + if (describeProblem != null) { + mismatchDescription + .add(' ${mismatch.instead ? 'instead of' : 'which'} '); + describeProblem(mismatchDescription, verbose); + } + } else { + // If we didn't get a good reason, that would normally be a + // simple 'is ' message. We only add that if the mismatch + // description is non empty (so we are supplementing the mismatch + // description). + if (describeProblem == null) { + if (mismatchDescription.length > 0) { + mismatchDescription.add('is ').addDescriptionOf(item); + } + } else { + describeProblem(mismatchDescription, verbose); + } + } + return mismatchDescription; + } +} + +class _Mismatch { + /// A human-readable description of the location within the collection where + /// the mismatch occurred. + final String location; + + /// The actual value found at [location]. + final Object? actual; + final SerializationReflection reflection; + + /// Callback that can create a detailed description of the problem. + final void Function(Description, bool verbose)? describeProblem; + + /// If `true`, [describeProblem] describes the expected value, so when the + /// final mismatch description is pieced together, it will be preceded by + /// `instead of` (e.g. `at location [2] is <3> instead of <4>`). If `false`, + /// [describeProblem] is a problem description from a sub-matcher, so when the + /// final mismatch description is pieced together, it will be preceded by + /// `which` (e.g. `at location [2] is which has length of 3`). + final bool instead; + + _Mismatch( + this.location, + this.actual, + this.describeProblem, { + this.instead = false, + required this.reflection, + }); + + _Mismatch.simple( + this.location, + this.actual, + String problem, { + required this.reflection, + }) : describeProblem = ((description, verbose) => description.add(problem)), + instead = false; +} diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/default.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/default.mustache new file mode 100644 index 000000000000..61c1df9f6db1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/default.mustache @@ -0,0 +1,15 @@ +{{^required}}= const UndefinedWrapper + {{#defaultValue}}( + {{#enumName}}{{.}}.$unsafe({{{defaultValue}}}){{/enumName}} + {{^enumName}}{{{.}}}{{/enumName}} + ) + {{/defaultValue}} + {{^defaultValue}}.undefined(){{/defaultValue}} +{{/required}} +{{#required}} + {{#defaultValue}}= + {{#isContainer}}const{{/isContainer}} + {{{.}}} + {{#isArray}}{{#enumName}}.map((v) => {{.}}.$unsafe(v)).toList(){{/enumName}}{{/isArray}} + {{/defaultValue}} +{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/param.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/param.mustache new file mode 100644 index 000000000000..9a6e08fb30b8 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/param.mustache @@ -0,0 +1 @@ +{{^required}}UndefinedWrapper<{{/required}}{{#schema}}{{>types/variable_recursive}}{{/schema}}{{^required}}>{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/reflection.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/reflection.mustache new file mode 100644 index 000000000000..c00b38446334 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/reflection.mustache @@ -0,0 +1 @@ +{{^required}}UndefinedWrapperReflection({{/required}}{{>types/reflection_recursive}}{{^required}}){{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/reflection_recursive.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/reflection_recursive.mustache new file mode 100644 index 000000000000..2d25756970e2 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/reflection_recursive.mustache @@ -0,0 +1,4 @@ +XmlReflectionWrapper( + xml: {{>types/xml}}, + {{#isNullable}}NullableReflection({{/isNullable}}{{>types/reflection_recursive_nonnullable}}{{#isNullable}}){{/isNullable}}, +) diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/reflection_recursive_nonnullable.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/reflection_recursive_nonnullable.mustache new file mode 100644 index 000000000000..e589c67bb1ce --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/reflection_recursive_nonnullable.mustache @@ -0,0 +1,20 @@ +{{#isAnyType}}ObjectReflection(){{/isAnyType}} +{{^isAnyType}} + {{#isContainer}}{{dataType}}Reflection({{#items}}{{>types/reflection_recursive}}{{/items}}) + {{/isContainer}} + {{^isContainer}} + {{#isEnum}}{{{datatypeWithEnum}}}.$reflection{{/isEnum}} + {{^isEnum}}{{#enumName}}{{{enumName}}}.$reflection{{/enumName}}{{/isEnum}} + {{^isEnum}}{{^enumName}} + {{#isEnumRef}}{{{datatypeWithEnum}}}.$reflection{{/isEnumRef}} + {{^isEnumRef}} + {{#isModel}} + {{{dataType}}}.$reflection + {{/isModel}} + {{^isModel}} + PrimitiveReflection.for{{{dataType}}} + {{/isModel}} + {{/isEnumRef}} + {{/enumName}}{{/isEnum}} + {{/isContainer}} +{{/isAnyType}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/required_ctor.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/required_ctor.mustache new file mode 100644 index 000000000000..4effb5980ac2 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/required_ctor.mustache @@ -0,0 +1 @@ +{{#required}}{{^defaultValue}}{{^isNullable}}required{{/isNullable}}{{/defaultValue}}{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/variable.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/variable.mustache new file mode 100644 index 000000000000..a11e286422b5 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/variable.mustache @@ -0,0 +1 @@ +{{^required}}UndefinedWrapper<{{/required}}{{>types/variable_recursive}}{{^required}}>{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/variable_recursive.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/variable_recursive.mustache new file mode 100644 index 000000000000..c346266fb06d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/variable_recursive.mustache @@ -0,0 +1 @@ +{{>types/variable_recursive_nonnullable}}{{#isNullable}}?{{/isNullable}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/variable_recursive_nonnullable.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/variable_recursive_nonnullable.mustache new file mode 100644 index 000000000000..007f3ff249d9 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/variable_recursive_nonnullable.mustache @@ -0,0 +1,9 @@ +{{#isAnyType}}Object{{/isAnyType}} +{{^isAnyType}} + {{#isContainer}}{{dataType}}<{{#isMap}}String, {{/isMap}} + {{#items}}{{>types/variable_recursive}}{{/items}}> + {{/isContainer}} + {{^isContainer}} + {{{datatypeWithEnum}}} + {{/isContainer}} +{{/isAnyType}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart-next/types/xml.mustache b/modules/openapi-generator/src/main/resources/dart-next/types/xml.mustache new file mode 100644 index 000000000000..ed047a896dbd --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart-next/types/xml.mustache @@ -0,0 +1,17 @@ +XmlReflection( + {{#xmlName}} + xmlName: r'{{{xmlName}}}', + {{/xmlName}} + {{#xmlNamespace}} + namespace: r'{{{xmlNamespace}}}', + {{/xmlNamespace}} + {{#xmlPrefix}} + prefix: r'{{{xmlPrefix}}}', + {{/xmlPrefix}} + {{#isXmlAttribute}} + attribute: {{isXmlAttribute}}, + {{/isXmlAttribute}} + {{#isXmlWrapped}} + wrapped: {{isXmlWrapped}}, + {{/isXmlWrapped}} +) \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/next/DartNextClientCodegenModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/next/DartNextClientCodegenModelTest.java new file mode 100644 index 000000000000..5f0e05cdf344 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/next/DartNextClientCodegenModelTest.java @@ -0,0 +1,29 @@ +package org.openapitools.codegen.dart.next; + +import org.openapitools.codegen.*; +import org.openapitools.codegen.languages.DartNextClientCodegen; +import io.swagger.models.*; +import io.swagger.models.properties.*; + +import org.testng.Assert; +import org.testng.annotations.Test; + +@SuppressWarnings("static-method") +public class DartNextClientCodegenModelTest { + + @Test(description = "convert a simple java model") + public void simpleModelTest() { + final Model model = new ModelImpl() + .description("a sample model") + .property("id", new LongProperty()) + .property("name", new StringProperty()) + .required("id") + .required("name"); + final DefaultCodegen codegen = new DartNextClientCodegen(); + + // TODO: Complete this test. + Assert.fail("Not implemented."); + } + +} + diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/next/DartNextClientCodegenOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/next/DartNextClientCodegenOptionsTest.java new file mode 100644 index 000000000000..06c1641d31c6 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/next/DartNextClientCodegenOptionsTest.java @@ -0,0 +1,30 @@ +package org.openapitools.codegen.dart.next; + +import org.openapitools.codegen.AbstractOptionsTest; +import org.openapitools.codegen.CodegenConfig; +import org.openapitools.codegen.languages.DartNextClientCodegen; +import org.openapitools.codegen.options.DartNextClientCodegenOptionsProvider; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +public class DartNextClientCodegenOptionsTest extends AbstractOptionsTest { + private DartNextClientCodegen codegen = mock(DartNextClientCodegen.class, mockSettings); + + public DartNextClientCodegenOptionsTest() { + super(new DartNextClientCodegenOptionsProvider()); + } + + @Override + protected CodegenConfig getCodegenConfig() { + return codegen; + } + + @SuppressWarnings("unused") + @Override + protected void verifyOptions() { + // TODO: Complete options using Mockito + // verify(codegen).someMethod(arguments) + } +} + diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/next/DartNextClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/next/DartNextClientCodegenTest.java new file mode 100644 index 000000000000..39b4fabf9c2a --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/next/DartNextClientCodegenTest.java @@ -0,0 +1,16 @@ +package org.openapitools.codegen.dart.next; + +import org.openapitools.codegen.languages.DartNextClientCodegen; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class DartNextClientCodegenTest { + + DartNextClientCodegen codegen = new DartNextClientCodegen(); + + @Test + public void shouldSucceed() throws Exception { + // TODO: Complete this test. + Assert.fail("Not implemented."); + } +} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartNextClientCodegenOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartNextClientCodegenOptionsProvider.java new file mode 100644 index 000000000000..e8f9f8605cd4 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartNextClientCodegenOptionsProvider.java @@ -0,0 +1,31 @@ +package org.openapitools.codegen.options; + +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.languages.DartNextClientCodegen; + +import com.google.common.collect.ImmutableMap; + +import java.util.Map; + +public class DartNextClientCodegenOptionsProvider implements OptionsProvider { + public static final String PROJECT_NAME_VALUE = "OpenAPI"; + + @Override + public String getLanguage() { + return "dart-next"; + } + + @Override + public Map createOptions() { + ImmutableMap.Builder builder = new ImmutableMap.Builder(); + return builder + .put(DartNextClientCodegen.PROJECT_NAME, PROJECT_NAME_VALUE) + .build(); + } + + @Override + public boolean isServer() { + return false; + } +} + diff --git a/modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml new file mode 100644 index 000000000000..dc276b5977bb --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml @@ -0,0 +1,3116 @@ +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' + +security: [] +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +paths: + /foo: + get: + responses: + default: + description: response + content: + application/json: + schema: + type: object + properties: + string: + $ref: '#/components/schemas/Foo' + /pet: + servers: + - url: 'http://petstore.swagger.io/v2' + - url: 'http://path-server-test.petstore.local/v2' + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + style: form + explode: false + deprecated: true + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid status value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: >- + Multiple tags can be provided with comma separated strings. Use tag1, + tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + style: form + explode: false + schema: + type: array + items: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid tag value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + deprecated: true + '/pet/{petId}': + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '400': + description: Invalid pet value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid Order + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet + required: true + '/store/order/{order_id}': + get: + tags: + - store + summary: Find purchase order by ID + description: >- + For valid response try integer IDs with value <= 5 or > 10. Other values + will generate exceptions + operationId: getOrderById + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 5 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: >- + For valid response try integer IDs with value < 1000. Anything above + 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + responses: + default: + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + '200': + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + '400': + description: Invalid username supplied + '404': + description: User not found + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + /fake_classname_test: + patch: + tags: + - 'fake_classname_tags 123#$%^' + summary: To test class name in snake case + description: To test class name in snake case + operationId: testClassname + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + security: + - api_key_query: [] + requestBody: + $ref: '#/components/requestBodies/Client' + /fake: + patch: + tags: + - fake + summary: To test "client" model + description: To test "client" model + operationId: testClientModel + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + get: + tags: + - fake + summary: To test enum parameters + description: To test enum parameters + operationId: testEnumParameters + parameters: + - name: enum_header_string_array + in: header + description: Header parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_header_string + in: header + description: Header parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_string_array + in: query + description: Query parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_query_string + in: query + description: Query parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_integer + in: query + description: Query parameter enum test (double) + schema: + type: integer + format: int32 + enum: + - 1 + - -2 + - name: enum_query_double + in: query + description: Query parameter enum test (double) + schema: + type: number + format: double + enum: + - 1.1 + - -1.2 + responses: + '400': + description: Invalid request + '404': + description: Not found + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + enum_form_string: + description: Form parameter enum test (string) + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + post: + tags: + - fake + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + security: + - http_basic_test: [] + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + integer: + description: None + type: integer + minimum: 10 + maximum: 100 + int32: + description: None + type: integer + format: int32 + minimum: 20 + maximum: 200 + int64: + description: None + type: integer + format: int64 + number: + description: None + type: number + minimum: 32.1 + maximum: 543.2 + float: + description: None + type: number + format: float + maximum: 987.6 + double: + description: None + type: number + format: double + minimum: 67.8 + maximum: 123.4 + string: + description: None + type: string + pattern: '/[a-z]/i' + pattern_without_delimiter: + description: None + type: string + pattern: '^[A-Z].*' + byte: + description: None + type: string + format: byte + binary: + description: None + type: string + format: binary + date: + description: None + type: string + format: date + dateTime: + description: None + type: string + format: date-time + default: '2010-02-01T10:20:10.11111+01:00' + example: '2020-02-02T20:20:20.22222Z' + password: + description: None + type: string + format: password + minLength: 10 + maxLength: 64 + callback: + description: None + type: string + required: + - number + - double + - pattern_without_delimiter + - byte + delete: + tags: + - fake + security: + - bearer_test: [] + summary: Fake endpoint to test group parameters (optional) + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + x-group-parameters: true + parameters: + - name: required_string_group + in: query + description: Required String in group parameters + required: true + schema: + type: integer + - name: required_boolean_group + in: header + description: Required Boolean in group parameters + required: true + schema: + type: boolean + - name: required_int64_group + in: query + description: Required Integer in group parameters + required: true + schema: + type: integer + format: int64 + - name: string_group + in: query + description: String in group parameters + schema: + type: integer + - name: boolean_group + in: header + description: Boolean in group parameters + schema: + type: boolean + - name: int64_group + in: query + description: Integer in group parameters + schema: + type: integer + format: int64 + responses: + '400': + description: Something wrong + /fake/outer/number: + post: + tags: + - fake + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + responses: + '200': + description: Output number + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + /fake/outer/string: + post: + summary: "/fake/outer/string" + tags: + - fake + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + responses: + '200': + description: Output string + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + /fake/outer/boolean: + post: + tags: + - fake + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + responses: + '200': + description: Output boolean + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + /fake/outer/composite: + post: + tags: + - fake + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + responses: + '200': + description: Output composite + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + /fake/jsonFormData: + get: + tags: + - fake + summary: test json serialization of form data + description: '' + operationId: testJsonFormData + responses: + '200': + description: successful operation + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + /fake/additionalProperties-reference: + post: + tags: + - fake + summary: test referenced additionalProperties + description: '' + operationId: testAdditionalPropertiesReference + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FreeFormObject' + description: request body + required: true + /fake/oneOfWIthSameErasure: + get: + description: Test route, this shouldn't cause a compiler error + responses: + 200: + description: successful response + content: + application/json: + schema: + oneOf: + - type: array + items: + type: string + - type: array + items: + type: integer + /fake/anyOfWIthSameErasure: + get: + description: Test route, this shouldn't cause a compiler error + responses: + 200: + description: successful response + content: + application/json: + schema: + anyOf: + - type: array + items: + type: string + - type: array + items: + type: integer + /fake/stringMap-reference: + post: + tags: + - fake + summary: test referenced string map + description: '' + operationId: testStringMapReference + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MapOfString' + description: request body + required: true + /fake/inline-additionalProperties: + post: + tags: + - fake + summary: test inline additionalProperties + description: '' + operationId: testInlineAdditionalProperties + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: string + description: request body + required: true + /fake/inline-freeform-additionalProperties: + post: + tags: + - fake + summary: test inline free-form additionalProperties + description: '' + operationId: testInlineFreeformAdditionalProperties + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + type: object + properties: + someProperty: + type: string + additionalProperties: true + description: request body + required: true + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: query + in: query + required: true + schema: + type: string + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + /another-fake/dummy: + patch: + tags: + - $another-fake? + summary: To test special tags + description: To test special tags and operation ID starting with number + operationId: '123_test_@#$%_special_tags' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + /fake/body-with-file-schema: + put: + tags: + - fake + description: >- + For this test, the body for this request much reference a schema named + `File`. + operationId: testBodyWithFileSchema + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + /fake/get-free-form-object: + get: + tags: + - fake + description: Get a free form object or Json string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/FreeFormObjectTestClass' + /fake/test-query-parameters: + put: + tags: + - fake + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - name: pipe + in: query + required: true + schema: + type: array + items: + type: string + - name: ioutil + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: http + in: query + required: true + style: spaceDelimited + schema: + type: array + items: + type: string + - name: url + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: context + in: query + required: true + explode: true + schema: + type: array + items: + type: string + responses: + "200": + description: Success + '/fake/{petId}/uploadImageWithRequiredFile': + post: + tags: + - pet + summary: uploads an image (required) + description: '' + operationId: uploadFileWithRequiredFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + type: string + format: binary + required: + - requiredFile + /fake/health: + get: + tags: + - fake + summary: Health check endpoint + responses: + 200: + description: The instance started successfully + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheckResult' + /fake/array-of-enums: + get: + tags: + - fake + summary: Array of Enums + operationId: getArrayOfEnums + responses: + 200: + description: Got named array of enums + content: + application/json: + schema: + $ref: '#/components/schemas/ArrayOfEnums' + /fake/parameter-name-mapping: + get: + tags: + - fake + summary: parameter name mapping test + operationId: getParameterNameMapping + parameters: + - name: _type + in: header + description: _type + required: true + schema: + type: integer + format: int64 + - name: type + in: query + description: type + required: true + schema: + type: string + - name: type_ + in: header + description: type_ + required: true + schema: + type: string + responses: + 200: + description: OK + /fake/parameter-string-number: + get: + tags: + - another_fake + summary: parameter string number + operationId: getParameterStringNumber + parameters: + - name: string_number + in: header + description: string number + required: true + schema: + type: string + format: number + responses: + 200: + description: OK + /fake/parameter-array-number: + get: + tags: + - another_fake + summary: parameter array number default value + operationId: getParameterArrayNumber + parameters: + - name: array + in: header + description: array integer + required: true + schema: + type: array + items: + type: integer + default: + - 1 + responses: + 200: + description: OK + /fake/null-request-body: + get: + tags: + - another_fake + summary: null request body + operationId: null-request-body + parameters: + - name: Accept-Language + in: header + schema: + type: string + example: application/json + requestBody: + content: + text/plain: + schema: + type: string + examples: + Generar Orden por External ID: + value: |- + { + "external_reference": "{{external_order_ref}}", + "notification_url": "www.yourserver.com/yourendpoint", + "sponsor_id": 446566691, + "items": [ + { + "title": "Papas frita", + "currency_id": "{{currency_id}}", + "unit_price": 6000, + "quantity": 1 + }, + { + "title": "Gaseosa", + "currency_id": "{{currency_id}}", + "unit_price": 3000, + "quantity": 1 + } + ]/*, + "taxes": [ + { + "value": 0, + "type": "IVA" + } + ]*/ + } + responses: + '200': + description: '' + '/fake/pet/{petId}/uploadImage': + post: + tags: + - fake + summary: fake uploads an image with ref request bodies + description: '' + operationId: fake-upload-ref-request-bodies + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/upload_body' + '/pets/multicontent-test': + post: + summary: Add a new pet + requestBody: + description: Optional description in *Markdown* + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/NewPet' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Triangle' + encoding: + name: + style: 'form' + explode: true + text/plain: + schema: + type: integer + '*/*': + schema: {} + 'text/*': + schema: + type: string + multipart/form-data: + schema: + type: object + properties: + id: + type: string + format: uuid + address: + type: object + properties: + street: + type: string + city: + type: string + profileImages: + type: array + items: + type: string + format: binary + encoding: + address: + contentType: 'application/json' + profileImages: + headers: + hello: + schema: + type: string + responses: + '200': + description: 'Successful' + content: + text/plain: + schema: + type: integer + '*/*': + schema: {} + 'text/*': + schema: + type: string + multipart/form-data: + schema: + type: object + properties: + id: + type: string + format: uuid + address: + type: object + properties: + street: + type: string + city: + type: string + profileImages: + type: array + items: + type: string + format: binary + encoding: + address: + contentType: 'application/json' + profileImages: + headers: + hello: + schema: + type: string + '201': + description: 'Created' + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/NewPet' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Triangle' + encoding: + name: + style: 'form' + explode: true + "2XX": + headers: + X-Rate-Limit: + schema: + type: integer + description: 'Calls per hour allowed by the user' + X-RateLimit-Remaining: + schema: + type: integer + description: The number of requests left for the time window. + X-RateLimit-Reset: + schema: + type: string + format: date-time + description: The UTC date/time at which the current rate limit window resets. + description: 'Anything 2XX' + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + default: + description: 'Anything' + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Triangle' + encoding: + name: + style: 'form' + explode: true + /values: + get: + tags: + - values + summary: Get some primitive variable values + description: '' + operationId: getSomeValues + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Variable' + '400': + description: Invalid Value + /internal/only: + get: + x-internal: true + tags: + - values + summary: internal only + description: '' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Variable' + '400': + description: Invalid Value +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: + requestBodies: + upload_body: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + UserArray: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + examples: + simple-list: + summary: Simple list example + description: Should not get into code examples + value: + - username: foo + - username: bar + description: List of user object + required: true + Client: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + Pet: + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header + api_key_query: + type: apiKey + name: api_key_query + in: query + http_basic_test: + type: http + scheme: basic + bearer_test: + type: http + scheme: bearer + bearerFormat: JWT + schemas: + XmlItem: + type: object + xml: + namespace: http://a.com/schema + prefix: pre + properties: + attribute_string: + type: string + example: string + xml: + attribute: true + attribute_number: + type: number + example: 1.234 + xml: + attribute: true + attribute_integer: + type: integer + example: -2 + xml: + attribute: true + attribute_boolean: + type: boolean + example: true + xml: + attribute: true + wrapped_array: + type: array + xml: + wrapped: true + items: + type: integer + name_string: + type: string + example: string + xml: + name: xml_name_string + name_number: + type: number + example: 1.234 + xml: + name: xml_name_number + name_integer: + type: integer + example: -2 + xml: + name: xml_name_integer + name_boolean: + type: boolean + example: true + xml: + name: xml_name_boolean + name_array: + type: array + items: + type: integer + xml: + name: xml_name_array_item + name_wrapped_array: + type: array + xml: + wrapped: true + name: xml_name_wrapped_array + items: + type: integer + xml: + name: xml_name_wrapped_array_item + prefix_string: + type: string + example: string + xml: + prefix: ab + prefix_number: + type: number + example: 1.234 + xml: + prefix: cd + prefix_integer: + type: integer + example: -2 + xml: + prefix: ef + prefix_boolean: + type: boolean + example: true + xml: + prefix: gh + prefix_array: + type: array + items: + type: integer + xml: + prefix: ij + prefix_wrapped_array: + type: array + xml: + wrapped: true + prefix: kl + items: + type: integer + xml: + prefix: mn + namespace_string: + type: string + example: string + xml: + namespace: http://a.com/schema + namespace_number: + type: number + example: 1.234 + xml: + namespace: http://b.com/schema + namespace_integer: + type: integer + example: -2 + xml: + namespace: http://c.com/schema + namespace_boolean: + type: boolean + example: true + xml: + namespace: http://d.com/schema + namespace_array: + type: array + items: + type: integer + xml: + namespace: http://e.com/schema + namespace_wrapped_array: + type: array + xml: + wrapped: true + namespace: http://f.com/schema + items: + type: integer + xml: + namespace: http://g.com/schema + prefix_ns_string: + type: string + example: string + xml: + namespace: http://a.com/schema + prefix: a + prefix_ns_number: + type: number + example: 1.234 + xml: + namespace: http://b.com/schema + prefix: b + prefix_ns_integer: + type: integer + example: -2 + xml: + namespace: http://c.com/schema + prefix: c + prefix_ns_boolean: + type: boolean + example: true + xml: + namespace: http://d.com/schema + prefix: d + prefix_ns_array: + type: array + items: + type: integer + xml: + namespace: http://e.com/schema + prefix: e + prefix_ns_wrapped_array: + type: array + xml: + wrapped: true + namespace: http://f.com/schema + prefix: f + items: + type: integer + xml: + namespace: http://g.com/schema + prefix: g + + Foo: + type: object + properties: + bar: + $ref: '#/components/schemas/Bar' + Bar: + type: string + default: bar + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + example: '2020-02-02T20:20:20.000222Z' + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + type: object + required: + - name + properties: + id: + type: integer + format: int64 + name: + type: string + default: default-name + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + objectWithNoDeclaredProps: + type: object + # Note: the 'additionalProperties' keyword is not specified, which is + # equivalent to allowing undeclared properties of any type. + description: test code generation for objects + Value must be a map of strings to values. It cannot be the 'null' value. + objectWithNoDeclaredPropsNullable: + type: object + # Note: the 'additionalProperties' keyword is not specified, which is + # equivalent to allowing undeclared properties of any type. + description: test code generation for nullable objects. + Value must be a map of strings to values or the 'null' value. + nullable: true + anyTypeProp: + description: test code generation for any type + Here the 'type' attribute is not specified, which means the value can be anything, + including the null value, string, number, boolean, array or object. + See https://github.com/OAI/OpenAPI-Specification/issues/1389 + # TODO: this should be supported, currently there are some issues in the code generation. + #anyTypeExceptNullProp: + # description: any type except 'null' + # Here the 'type' attribute is not specified, which means the value can be anything, + # including the null value, string, number, boolean, array or object. + # not: + # type: 'null' + anyTypePropNullable: + description: test code generation for any type + Here the 'type' attribute is not specified, which means the value can be anything, + including the null value, string, number, boolean, array or object. + The 'nullable' attribute does not change the allowed values. + nullable: true + type: object + xml: + name: User + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + Return: + description: Model for testing reserved words + properties: + return: + type: integer + format: int32 + xml: + name: Return + Name: + description: Model for testing model name same as property name + required: + - name + properties: + name: + type: integer + format: int32 + snake_case: + readOnly: true + type: integer + format: int32 + property: + type: string + 123Number: + type: integer + readOnly: true + xml: + name: Name + 200_response: + description: Model for testing model name starting with number + properties: + name: + type: integer + format: int32 + class: + type: string + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Address' + - type: object + properties: + declawed: + type: boolean + Address: + type: object + additionalProperties: + type: integer + Animal: + type: object + discriminator: + propertyName: className + required: + - className + properties: + className: + type: string + color: + type: string + default: red + AnimalFarm: + type: array + items: + $ref: '#/components/schemas/Animal' + format_test: + type: object + required: + - number + - byte + - date + - password + properties: + integer: + type: integer + maximum: 100 + minimum: 10 + multipleOf: 2 + int32: + type: integer + format: int32 + maximum: 200 + minimum: 20 + int64: + type: integer + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + multipleOf: 32.5 + float: + type: number + format: float + maximum: 987.6 + minimum: 54.3 + double: + type: number + format: double + maximum: 123.4 + minimum: 67.8 + decimal: + type: string + format: number + string: + type: string + pattern: '/[a-z]/i' + byte: + type: string + format: byte + binary: + type: string + format: binary + date: + type: string + format: date + example: '2020-02-02' + dateTime: + type: string + format: date-time + example: '2007-12-03T10:15:30+01:00' + uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + uuid_with_default: + type: string + format: uuid + default: 11111111-206d-4f12-9f12-3d1e525a8e84 + password: + type: string + format: password + maxLength: 64 + minLength: 10 + pattern_with_digits: + description: A string that is a 10 digit number. Can have leading zeros. + type: string + pattern: '^\d{10}$' + pattern_with_digits_and_delimiter: + description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + type: string + pattern: '/^image_\d{1,3}$/i' + EnumClass: + type: string + default: '-efg' + enum: + - _abc + - '-efg' + - (xyz) + Enum_Test: + type: object + required: + - enum_string_required + properties: + enum_string: + type: string + enum: + - UPPER + - lower + - '' + enum_string_required: + type: string + enum: + - UPPER + - lower + - '' + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_integer_only: + type: integer + enum: + - 2 + - -2 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/components/schemas/OuterEnum' + outerEnumInteger: + $ref: '#/components/schemas/OuterEnumInteger' + outerEnumDefaultValue: + $ref: '#/components/schemas/OuterEnumDefaultValue' + outerEnumIntegerDefaultValue: + $ref: '#/components/schemas/OuterEnumIntegerDefaultValue' + AdditionalPropertiesClass: + type: object + properties: + map_property: + type: object + additionalProperties: + type: string + map_of_map_property: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + anytype_1: {} + map_with_undeclared_properties_anytype_1: + type: object + map_with_undeclared_properties_anytype_2: + type: object + properties: {} + map_with_undeclared_properties_anytype_3: + type: object + additionalProperties: true + empty_map: + type: object + description: an object with no declared properties and no undeclared + properties, hence it's an empty map. + additionalProperties: false + map_with_undeclared_properties_string: + type: object + additionalProperties: + type: string + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/components/schemas/Animal' + List: + type: object + properties: + 123-list: + type: string + Client: + type: object + properties: + client: + type: string + ReadOnlyFirst: + type: object + properties: + bar: + type: string + readOnly: true + baz: + type: string + hasOnlyReadOnly: + type: object + properties: + bar: + type: string + readOnly: true + foo: + type: string + readOnly: true + Capitalization: + type: object + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + MapTest: + type: object + properties: + map_map_of_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + direct_map: + type: object + additionalProperties: + type: boolean + indirect_map: + $ref: '#/components/schemas/StringBooleanMap' + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + array_array_of_integer: + type: array + items: + type: array + items: + type: integer + format: int64 + array_array_of_model: + type: array + items: + type: array + items: + $ref: '#/components/schemas/ReadOnlyFirst' + NumberOnly: + type: object + properties: + JustNumber: + type: number + ArrayOfNumberOnly: + type: object + properties: + ArrayNumber: + type: array + items: + type: number + ArrayOfArrayOfNumberOnly: + type: object + properties: + ArrayArrayNumber: + type: array + items: + type: array + items: + type: number + EnumArrays: + type: object + properties: + just_symbol: + type: string + enum: + - '>=' + - $ + array_enum: + type: array + items: + type: string + enum: + - fish + - crab + FreeFormObject: + type: object + description: A schema consisting only of additional properties + additionalProperties: true + MapOfString: + type: object + description: A schema consisting only of additional properties of type string + additionalProperties: + type: string + OuterEnum: + nullable: true + type: string + enum: + - placed + - approved + - delivered + - s + - S + OuterEnumInteger: + type: integer + enum: + - 0 + - 1 + - 2 + OuterEnumDefaultValue: + type: string + enum: + - placed + - approved + - delivered + default: placed + OuterEnumIntegerDefaultValue: + type: integer + enum: + - 0 + - 1 + - 2 + default: 0 + OuterComposite: + type: object + properties: + my_number: + $ref: '#/components/schemas/OuterNumber' + my_string: + $ref: '#/components/schemas/OuterString' + my_boolean: + $ref: '#/components/schemas/OuterBoolean' + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + FileSchemaTestClass: + type: object + properties: + file: + $ref: '#/components/schemas/File' + files: + type: array + items: + $ref: '#/components/schemas/File' + FreeFormObjectTestClass: + type: object + properties: + name: + type: string + properties: + oneOf: + - type: string + - type: object + additionalProperties: true + File: + type: object + description: Must be named `File` for test. + properties: + sourceURI: + description: Test capitalization + type: string + _special_model.name_: + properties: + '$special[property.name]': + type: integer + format: int64 + '_special_model.name_': + type: string + xml: + name: '$special[model.name]' + HealthCheckResult: + type: object + properties: + NullableMessage: + nullable: true + type: string + description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + NullableClass: + type: object + properties: + integer_prop: + type: integer + nullable: true + number_prop: + type: number + nullable: true + boolean_prop: + type: boolean + nullable: true + string_prop: + type: string + nullable: true + date_prop: + type: string + format: date + nullable: true + datetime_prop: + type: string + format: date-time + nullable: true + array_nullable_prop: + type: array + nullable: true + items: + type: object + array_and_items_nullable_prop: + type: array + nullable: true + items: + type: object + nullable: true + array_items_nullable: + type: array + items: + type: object + nullable: true + object_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + object_and_items_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + object_items_nullable: + type: object + additionalProperties: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + fruit: + properties: + color: + type: string + oneOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + # Below additionalProperties is set to false to validate the use + # case when a composed schema has additionalProperties set to false. + additionalProperties: false + apple: + type: object + properties: + cultivar: + type: string + pattern: ^[a-zA-Z\s]*$ + origin: + type: string + pattern: /^[A-Z\s]*$/i + nullable: true + banana: + type: object + required: + - lengthCm + properties: + lengthCm: + type: number + mammal: + oneOf: + - $ref: '#/components/schemas/whale' + - $ref: '#/components/schemas/zebra' + - $ref: '#/components/schemas/Pig' + discriminator: + propertyName: className + whale: + type: object + properties: + hasBaleen: + type: boolean + hasTeeth: + type: boolean + className: + type: string + required: + - className + zebra: + type: object + properties: + type: + type: string + enum: + - plains + - mountain + - grevys + className: + type: string + required: + - className + additionalProperties: true + Pig: + oneOf: + - $ref: '#/components/schemas/BasquePig' + - $ref: '#/components/schemas/DanishPig' + discriminator: + propertyName: className + BasquePig: + type: object + properties: + className: + type: string + required: + - className + DanishPig: + type: object + properties: + className: + type: string + required: + - className + gmFruit: + properties: + color: + type: string + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + additionalProperties: false + fruitReq: + oneOf: + - $ref: '#/components/schemas/appleReq' + - $ref: '#/components/schemas/bananaReq' + additionalProperties: false + appleReq: + type: object + properties: + cultivar: + type: string + mealy: + type: boolean + required: + - cultivar + additionalProperties: false + bananaReq: + type: object + properties: + lengthCm: + type: number + sweet: + type: boolean + required: + - lengthCm + additionalProperties: false + # go-experimental is unable to make Triangle and Quadrilateral models + # correctly https://github.com/OpenAPITools/openapi-generator/issues/6149 + Drawing: + type: object + properties: + mainShape: + # A property whose value is a 'oneOf' type, and the type is referenced instead + # of being defined inline. The value cannot be null. + $ref: '#/components/schemas/Shape' + shapeOrNull: + # A property whose value is a 'oneOf' type, and the type is referenced instead + # of being defined inline. The value may be null because ShapeOrNull has 'null' + # type as a child schema of 'oneOf'. + $ref: '#/components/schemas/ShapeOrNull' + nullableShape: + # A property whose value is a 'oneOf' type, and the type is referenced instead + # of being defined inline. The value may be null because NullableShape has the + # 'nullable: true' attribute. For this specific scenario this is exactly the + # same thing as 'shapeOrNull'. + $ref: '#/components/schemas/NullableShape' + shapes: + type: array + items: + $ref: '#/components/schemas/Shape' + additionalProperties: + # Here the additional properties are specified using a referenced schema. + # This is just to validate the generated code works when using $ref + # under 'additionalProperties'. + $ref: '#/components/schemas/fruit' + Shape: + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + ShapeOrNull: + description: The value may be a shape or the 'null' value. + This is introduced in OAS schema >= 3.1. + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + NullableShape: + description: The value may be a shape or the 'null' value. + The 'nullable' attribute was introduced in OAS schema >= 3.0 + and has been deprecated in OAS schema >= 3.1. + type: object + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + nullable: true + ShapeInterface: + properties: + shapeType: + type: string + required: + - shapeType + TriangleInterface: + properties: + triangleType: + type: string + required: + - triangleType + Triangle: + oneOf: + - $ref: '#/components/schemas/EquilateralTriangle' + - $ref: '#/components/schemas/IsoscelesTriangle' + - $ref: '#/components/schemas/ScaleneTriangle' + discriminator: + propertyName: triangleType + # Note: the 'additionalProperties' keyword is not specified, which is + # equivalent to allowing undeclared properties of any type. + EquilateralTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + IsoscelesTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + additionalProperties: false + ScaleneTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + QuadrilateralInterface: + properties: + quadrilateralType: + type: string + required: + - quadrilateralType + Quadrilateral: + oneOf: + - $ref: '#/components/schemas/SimpleQuadrilateral' + - $ref: '#/components/schemas/ComplexQuadrilateral' + discriminator: + propertyName: quadrilateralType + SimpleQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + ComplexQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + GrandparentAnimal: + type: object + required: + - pet_type + properties: + pet_type: + type: string + discriminator: + propertyName: pet_type + ParentPet: + type: object + allOf: + - $ref: '#/components/schemas/GrandparentAnimal' + #ChildCat: + # allOf: + # - $ref: '#/components/schemas/ParentPet' + # - type: object + # properties: + # name: + # type: string + # pet_type: + # x-enum-as-string: true + # type: string + # enum: + # - ChildCat + # default: ChildCat + ArrayOfEnums: + type: array + items: + $ref: '#/components/schemas/OuterEnum' + DateTimeTest: + type: string + default: '2010-01-01T10:10:10.000111+01:00' + example: '2010-01-01T10:10:10.000111+01:00' + format: date-time + DeprecatedObject: + type: object + deprecated: true + properties: + name: + type: string + ObjectWithDeprecatedFields: + type: object + properties: + uuid: + type: string + id: + type: number + deprecated: true + deprecatedRef: + $ref: '#/components/schemas/DeprecatedObject' + bars: + type: array + deprecated: true + items: + $ref: '#/components/schemas/Bar' + PetWithRequiredTags: + type: object + required: + - name + - photoUrls + - tags + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ArrayOfInlineAllOf: + type: object + required: + - name + properties: + id: + type: integer + format: int64 + name: + type: string + example: doggie + array_allof_dog_property: + type: array + items: + allOf: + - type: object + properties: + breed: + type: string + - type: object + properties: + color: + type: string + EnumStringDiscriminator: + type: object + description: An object to test discriminator of enum string + discriminator: + propertyName: enum_str_type + required: + - enum_str_type + properties: + enum_str_type: + description: enum string type + type: string + enum: + - type_a + - type_b + ArrayDefault: + properties: + WithDefaultEmptyBracket: + default: [] + items: + type: string + type: array + WithoutDefault: + items: + type: string + type: array + Variable: + description: Value object + properties: + name: + type: string + example: 'variable_1' + value: + $ref: '#/components/schemas/Value' + required: + - name + - value + Value: + oneOf: + - $ref: '#/components/schemas/Scalar' + - $ref: '#/components/schemas/Array' + Scalar: + description: Values of scalar type + oneOf: + - type: string + maxLength: 1089 + - type: number + - type: boolean + ScalarAnyOf: + description: Values of scalar type using anyOf + anyOf: + - type: string + maxLength: 1089 + - type: number + - type: boolean + Array: + description: Values of array type + type: array + minItems: 1 + items: + $ref: '#/components/schemas/Scalar' + NewPet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + x-is-unique: true + category_inline_allof: + allOf: + - type: object + required: + - name + properties: + id: + type: integer + format: int64 + name: + type: string + default: default-name + category_tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + category_allOf_ref: + allOf: + - $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + allOf: + - $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + PropertyNameCollision: + x-internal: false + type: object + properties: + _type: + type: string + type: + type: string + type_: + type: string + InteralOnly: + type: object + x-internal: true + properties: + type: + type: string + AllOfModelArrayAnyOf: + allOf: + - $ref: "#/components/schemas/Category" + - type: object + properties: + linkListColumn1: + type: object + properties: + value: + type: array + items: + anyOf: + - $ref: '#/components/schemas/User' + - $ref: '#/components/schemas/Tag' + required: + - value + attributes: + type: object + properties: + C: + oneOf: + - $ref: '#/components/schemas/Pet' + - $ref: '#/components/schemas/Order' + PetUsingAllOf: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + description: | + multi line description + 2nd line + last line + allOf: + - $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + allOf: + - $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + PetComposition: + allOf: + - $ref: '#/components/schemas/Pet' + PetRef: + type: object + required: + - name + - photoUrls + properties: + id: + $ref: '#/components/schemas/Pet/properties/id' + category: + $ref: '#/components/schemas/Pet/properties/category' + name: + $ref: '#/components/schemas/Pet/properties/name' + photoUrls: + $ref: '#/components/schemas/Pet/properties/photoUrls' + tags: + $ref: '#/components/schemas/Pet/properties/tags' + status: + $ref: '#/components/schemas/Pet/properties/status' + xml: + name: Pet + ArrayOneOf: + oneOf: + - type: integer + - type: array + items: + type: string + ArrayAnyOf: + anyOf: + - type: integer + - type: array + items: + type: string + ModelWithOneOfAnyOfProperties: + type: object + properties: + oneof_prop: + $ref: '#/components/schemas/ArrayOneOf' + anyof_prop: + $ref: '#/components/schemas/ArrayAnyOf' + MixedTypeOneOfNumber: + additionalProperties: false + oneOf: + - type: number + format: float + - type: number + format: double + MixedTypeOneOfObject: + type: object + properties: + c: + type: boolean + anyOf: + - type: object + properties: + a: + type: integer + required: + - a + - type: object + properties: + b: + type: number + required: + - b + oneOf: + - properties: + content: + type: string + required: + - content + - properties: + url: + type: string + format: uri + required: + - url \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/.openapi-generator-ignore b/samples/openapi3/client/petstore/dart/next/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/openapi3/client/petstore/dart/next/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart/next/.openapi-generator/FILES new file mode 100644 index 000000000000..41ccc746098f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/.openapi-generator/FILES @@ -0,0 +1,413 @@ +CHANGELOG.md +README.md +lib/_internal.dart +lib/petstore_api.dart +lib/src/api_facade.dart +lib/src/apis/_exports.dart +lib/src/apis/another_fake_api.dart +lib/src/apis/another_fake_api.requests.dart +lib/src/apis/another_fake_api.responses.dart +lib/src/apis/default_api.dart +lib/src/apis/default_api.requests.dart +lib/src/apis/default_api.responses.dart +lib/src/apis/fake_api.dart +lib/src/apis/fake_api.requests.dart +lib/src/apis/fake_api.responses.dart +lib/src/apis/fake_classname_tags123_api.dart +lib/src/apis/fake_classname_tags123_api.requests.dart +lib/src/apis/fake_classname_tags123_api.responses.dart +lib/src/apis/pet_api.dart +lib/src/apis/pet_api.requests.dart +lib/src/apis/pet_api.responses.dart +lib/src/apis/store_api.dart +lib/src/apis/store_api.requests.dart +lib/src/apis/store_api.responses.dart +lib/src/apis/user_api.dart +lib/src/apis/user_api.requests.dart +lib/src/apis/user_api.responses.dart +lib/src/apis/values_api.dart +lib/src/apis/values_api.requests.dart +lib/src/apis/values_api.responses.dart +lib/src/models/__200_response.dart +lib/src/models/__200_response.reflection.dart +lib/src/models/__list.dart +lib/src/models/__list.reflection.dart +lib/src/models/__return.dart +lib/src/models/__return.reflection.dart +lib/src/models/_exports.dart +lib/src/models/additional_properties_class.dart +lib/src/models/additional_properties_class.reflection.dart +lib/src/models/all_of_model_array_any_of.dart +lib/src/models/all_of_model_array_any_of.reflection.dart +lib/src/models/all_of_model_array_any_of_all_of_attributes.dart +lib/src/models/all_of_model_array_any_of_all_of_attributes.reflection.dart +lib/src/models/all_of_model_array_any_of_all_of_attributes_c.dart +lib/src/models/all_of_model_array_any_of_all_of_attributes_c.reflection.dart +lib/src/models/all_of_model_array_any_of_all_of_link_list_column1.dart +lib/src/models/all_of_model_array_any_of_all_of_link_list_column1.reflection.dart +lib/src/models/all_of_model_array_any_of_all_of_link_list_column1_value.dart +lib/src/models/all_of_model_array_any_of_all_of_link_list_column1_value.reflection.dart +lib/src/models/animal.dart +lib/src/models/animal.reflection.dart +lib/src/models/api_response.dart +lib/src/models/api_response.reflection.dart +lib/src/models/apple.dart +lib/src/models/apple.reflection.dart +lib/src/models/apple_req.dart +lib/src/models/apple_req.reflection.dart +lib/src/models/array_any_of.dart +lib/src/models/array_any_of.reflection.dart +lib/src/models/array_default.dart +lib/src/models/array_default.reflection.dart +lib/src/models/array_of_array_of_number_only.dart +lib/src/models/array_of_array_of_number_only.reflection.dart +lib/src/models/array_of_inline_all_of.dart +lib/src/models/array_of_inline_all_of.reflection.dart +lib/src/models/array_of_inline_all_of_array_allof_dog_property_inner.dart +lib/src/models/array_of_inline_all_of_array_allof_dog_property_inner.reflection.dart +lib/src/models/array_of_number_only.dart +lib/src/models/array_of_number_only.reflection.dart +lib/src/models/array_one_of.dart +lib/src/models/array_one_of.reflection.dart +lib/src/models/array_test.dart +lib/src/models/array_test.reflection.dart +lib/src/models/banana.dart +lib/src/models/banana.reflection.dart +lib/src/models/banana_req.dart +lib/src/models/banana_req.reflection.dart +lib/src/models/basque_pig.dart +lib/src/models/basque_pig.reflection.dart +lib/src/models/capitalization.dart +lib/src/models/capitalization.reflection.dart +lib/src/models/cat.dart +lib/src/models/cat.reflection.dart +lib/src/models/category.dart +lib/src/models/category.reflection.dart +lib/src/models/class_model.dart +lib/src/models/class_model.reflection.dart +lib/src/models/client.dart +lib/src/models/client.reflection.dart +lib/src/models/complex_quadrilateral.dart +lib/src/models/complex_quadrilateral.reflection.dart +lib/src/models/danish_pig.dart +lib/src/models/danish_pig.reflection.dart +lib/src/models/deprecated_object.dart +lib/src/models/deprecated_object.reflection.dart +lib/src/models/dog.dart +lib/src/models/dog.reflection.dart +lib/src/models/drawing.dart +lib/src/models/drawing.reflection.dart +lib/src/models/enum_arrays.dart +lib/src/models/enum_arrays.reflection.dart +lib/src/models/enum_class.dart +lib/src/models/enum_class.reflection.dart +lib/src/models/enum_string_discriminator.dart +lib/src/models/enum_string_discriminator.reflection.dart +lib/src/models/enum_test.dart +lib/src/models/enum_test.reflection.dart +lib/src/models/equilateral_triangle.dart +lib/src/models/equilateral_triangle.reflection.dart +lib/src/models/fake_any_of_w_ith_same_erasure_get200_response.dart +lib/src/models/fake_any_of_w_ith_same_erasure_get200_response.reflection.dart +lib/src/models/fake_one_of_w_ith_same_erasure_get200_response.dart +lib/src/models/fake_one_of_w_ith_same_erasure_get200_response.reflection.dart +lib/src/models/file.dart +lib/src/models/file.reflection.dart +lib/src/models/file_schema_test_class.dart +lib/src/models/file_schema_test_class.reflection.dart +lib/src/models/foo.dart +lib/src/models/foo.reflection.dart +lib/src/models/foo_get_default_response.dart +lib/src/models/foo_get_default_response.reflection.dart +lib/src/models/format_test.dart +lib/src/models/format_test.reflection.dart +lib/src/models/free_form_object_test_class.dart +lib/src/models/free_form_object_test_class.reflection.dart +lib/src/models/free_form_object_test_class_properties.dart +lib/src/models/free_form_object_test_class_properties.reflection.dart +lib/src/models/fruit.dart +lib/src/models/fruit.reflection.dart +lib/src/models/fruit_req.dart +lib/src/models/fruit_req.reflection.dart +lib/src/models/gm_fruit.dart +lib/src/models/gm_fruit.reflection.dart +lib/src/models/grandparent_animal.dart +lib/src/models/grandparent_animal.reflection.dart +lib/src/models/has_only_read_only.dart +lib/src/models/has_only_read_only.reflection.dart +lib/src/models/health_check_result.dart +lib/src/models/health_check_result.reflection.dart +lib/src/models/isosceles_triangle.dart +lib/src/models/isosceles_triangle.reflection.dart +lib/src/models/mammal.dart +lib/src/models/mammal.reflection.dart +lib/src/models/map_test.dart +lib/src/models/map_test.reflection.dart +lib/src/models/mixed_properties_and_additional_properties_class.dart +lib/src/models/mixed_properties_and_additional_properties_class.reflection.dart +lib/src/models/mixed_type_one_of_number.dart +lib/src/models/mixed_type_one_of_number.reflection.dart +lib/src/models/mixed_type_one_of_object.dart +lib/src/models/mixed_type_one_of_object.reflection.dart +lib/src/models/mixed_type_one_of_object_any_of.dart +lib/src/models/mixed_type_one_of_object_any_of.reflection.dart +lib/src/models/mixed_type_one_of_object_any_of1.dart +lib/src/models/mixed_type_one_of_object_any_of1.reflection.dart +lib/src/models/mixed_type_one_of_object_one_of.dart +lib/src/models/mixed_type_one_of_object_one_of.reflection.dart +lib/src/models/mixed_type_one_of_object_one_of1.dart +lib/src/models/mixed_type_one_of_object_one_of1.reflection.dart +lib/src/models/model_with_one_of_any_of_properties.dart +lib/src/models/model_with_one_of_any_of_properties.reflection.dart +lib/src/models/name.dart +lib/src/models/name.reflection.dart +lib/src/models/new_pet.dart +lib/src/models/new_pet.reflection.dart +lib/src/models/new_pet_category_inline_allof.dart +lib/src/models/new_pet_category_inline_allof.reflection.dart +lib/src/models/new_pet_category_inline_allof_all_of_category_tag.dart +lib/src/models/new_pet_category_inline_allof_all_of_category_tag.reflection.dart +lib/src/models/nullable_class.dart +lib/src/models/nullable_class.reflection.dart +lib/src/models/nullable_shape.dart +lib/src/models/nullable_shape.reflection.dart +lib/src/models/number_only.dart +lib/src/models/number_only.reflection.dart +lib/src/models/object_with_deprecated_fields.dart +lib/src/models/object_with_deprecated_fields.reflection.dart +lib/src/models/order.dart +lib/src/models/order.reflection.dart +lib/src/models/outer_composite.dart +lib/src/models/outer_composite.reflection.dart +lib/src/models/outer_enum.dart +lib/src/models/outer_enum.reflection.dart +lib/src/models/outer_enum_default_value.dart +lib/src/models/outer_enum_default_value.reflection.dart +lib/src/models/outer_enum_integer.dart +lib/src/models/outer_enum_integer.reflection.dart +lib/src/models/outer_enum_integer_default_value.dart +lib/src/models/outer_enum_integer_default_value.reflection.dart +lib/src/models/parent_pet.dart +lib/src/models/parent_pet.reflection.dart +lib/src/models/pet.dart +lib/src/models/pet.reflection.dart +lib/src/models/pet_composition.dart +lib/src/models/pet_composition.reflection.dart +lib/src/models/pet_ref.dart +lib/src/models/pet_ref.reflection.dart +lib/src/models/pet_using_all_of.dart +lib/src/models/pet_using_all_of.reflection.dart +lib/src/models/pet_with_required_tags.dart +lib/src/models/pet_with_required_tags.reflection.dart +lib/src/models/pets_multicontent_test_post_request.dart +lib/src/models/pets_multicontent_test_post_request.reflection.dart +lib/src/models/pets_multicontent_test_post_request_address.dart +lib/src/models/pets_multicontent_test_post_request_address.reflection.dart +lib/src/models/pig.dart +lib/src/models/pig.reflection.dart +lib/src/models/property_name_collision.dart +lib/src/models/property_name_collision.reflection.dart +lib/src/models/quadrilateral.dart +lib/src/models/quadrilateral.reflection.dart +lib/src/models/quadrilateral_interface.dart +lib/src/models/quadrilateral_interface.reflection.dart +lib/src/models/read_only_first.dart +lib/src/models/read_only_first.reflection.dart +lib/src/models/scalar.dart +lib/src/models/scalar.reflection.dart +lib/src/models/scalar_any_of.dart +lib/src/models/scalar_any_of.reflection.dart +lib/src/models/scalene_triangle.dart +lib/src/models/scalene_triangle.reflection.dart +lib/src/models/shape.dart +lib/src/models/shape.reflection.dart +lib/src/models/shape_interface.dart +lib/src/models/shape_interface.reflection.dart +lib/src/models/shape_or_null.dart +lib/src/models/shape_or_null.reflection.dart +lib/src/models/simple_quadrilateral.dart +lib/src/models/simple_quadrilateral.reflection.dart +lib/src/models/special_model_name.dart +lib/src/models/special_model_name.reflection.dart +lib/src/models/tag.dart +lib/src/models/tag.reflection.dart +lib/src/models/test_endpoint_parameters_request.dart +lib/src/models/test_endpoint_parameters_request.reflection.dart +lib/src/models/test_enum_parameters_request.dart +lib/src/models/test_enum_parameters_request.reflection.dart +lib/src/models/test_inline_freeform_additional_properties_request.dart +lib/src/models/test_inline_freeform_additional_properties_request.reflection.dart +lib/src/models/test_json_form_data_request.dart +lib/src/models/test_json_form_data_request.reflection.dart +lib/src/models/triangle.dart +lib/src/models/triangle.reflection.dart +lib/src/models/triangle_interface.dart +lib/src/models/triangle_interface.reflection.dart +lib/src/models/update_pet_with_form_request.dart +lib/src/models/update_pet_with_form_request.reflection.dart +lib/src/models/upload_file_request.dart +lib/src/models/upload_file_request.reflection.dart +lib/src/models/upload_file_with_required_file_request.dart +lib/src/models/upload_file_with_required_file_request.reflection.dart +lib/src/models/user.dart +lib/src/models/user.reflection.dart +lib/src/models/value.dart +lib/src/models/value.reflection.dart +lib/src/models/variable.dart +lib/src/models/variable.reflection.dart +lib/src/models/whale.dart +lib/src/models/whale.reflection.dart +lib/src/models/xml_item.dart +lib/src/models/xml_item.reflection.dart +lib/src/models/zebra.dart +lib/src/models/zebra.reflection.dart +lib/src/networking/_exports.dart +lib/src/networking/_internal.dart +lib/src/networking/helpers.dart +lib/src/networking/multipart.dart +lib/src/networking/package_http_client.dart +lib/src/networking/property_encoding_rule.dart +lib/src/networking/wire_serialization_options.dart +lib/src/serialization/_exports.dart +lib/src/serialization/_internal.dart +lib/src/serialization/additional_properties.dart +lib/src/serialization/container_reflection.dart +lib/src/serialization/context.dart +lib/src/serialization/examples.dart +lib/src/serialization/generated_reflections.dart +lib/src/serialization/json_extensions.dart +lib/src/serialization/model_reflection.dart +lib/src/serialization/open_api_object.dart +lib/src/serialization/parameter_serialization.dart +lib/src/serialization/primitive_reflection.dart +lib/src/serialization/reflection.dart +lib/src/serialization/xml_extensions.dart +lib/src/serialization/xml_reflection.dart +pubspec.yaml +test/apis/another_fake_api_test.dart +test/apis/default_api_test.dart +test/apis/fake_api_test.dart +test/apis/fake_classname_tags123_api_test.dart +test/apis/pet_api_test.dart +test/apis/store_api_test.dart +test/apis/user_api_test.dart +test/apis/values_api_test.dart +test/models/__200_response_test.dart +test/models/__list_test.dart +test/models/__return_test.dart +test/models/additional_properties_class_test.dart +test/models/all_of_model_array_any_of_all_of_attributes_c_test.dart +test/models/all_of_model_array_any_of_all_of_attributes_test.dart +test/models/all_of_model_array_any_of_all_of_link_list_column1_test.dart +test/models/all_of_model_array_any_of_all_of_link_list_column1_value_test.dart +test/models/all_of_model_array_any_of_test.dart +test/models/animal_test.dart +test/models/api_response_test.dart +test/models/apple_req_test.dart +test/models/apple_test.dart +test/models/array_any_of_test.dart +test/models/array_default_test.dart +test/models/array_of_array_of_number_only_test.dart +test/models/array_of_inline_all_of_array_allof_dog_property_inner_test.dart +test/models/array_of_inline_all_of_test.dart +test/models/array_of_number_only_test.dart +test/models/array_one_of_test.dart +test/models/array_test_test.dart +test/models/banana_req_test.dart +test/models/banana_test.dart +test/models/basque_pig_test.dart +test/models/capitalization_test.dart +test/models/cat_test.dart +test/models/category_test.dart +test/models/class_model_test.dart +test/models/client_test.dart +test/models/complex_quadrilateral_test.dart +test/models/danish_pig_test.dart +test/models/deprecated_object_test.dart +test/models/dog_test.dart +test/models/drawing_test.dart +test/models/enum_arrays_test.dart +test/models/enum_class_test.dart +test/models/enum_string_discriminator_test.dart +test/models/enum_test_test.dart +test/models/equilateral_triangle_test.dart +test/models/fake_any_of_w_ith_same_erasure_get200_response_test.dart +test/models/fake_one_of_w_ith_same_erasure_get200_response_test.dart +test/models/file_schema_test_class_test.dart +test/models/file_test.dart +test/models/foo_get_default_response_test.dart +test/models/foo_test.dart +test/models/format_test_test.dart +test/models/free_form_object_test_class_properties_test.dart +test/models/free_form_object_test_class_test.dart +test/models/fruit_req_test.dart +test/models/fruit_test.dart +test/models/gm_fruit_test.dart +test/models/grandparent_animal_test.dart +test/models/has_only_read_only_test.dart +test/models/health_check_result_test.dart +test/models/isosceles_triangle_test.dart +test/models/mammal_test.dart +test/models/map_test_test.dart +test/models/mixed_properties_and_additional_properties_class_test.dart +test/models/mixed_type_one_of_number_test.dart +test/models/mixed_type_one_of_object_any_of1_test.dart +test/models/mixed_type_one_of_object_any_of_test.dart +test/models/mixed_type_one_of_object_one_of1_test.dart +test/models/mixed_type_one_of_object_one_of_test.dart +test/models/mixed_type_one_of_object_test.dart +test/models/model_with_one_of_any_of_properties_test.dart +test/models/name_test.dart +test/models/new_pet_category_inline_allof_all_of_category_tag_test.dart +test/models/new_pet_category_inline_allof_test.dart +test/models/new_pet_test.dart +test/models/nullable_class_test.dart +test/models/nullable_shape_test.dart +test/models/number_only_test.dart +test/models/object_with_deprecated_fields_test.dart +test/models/order_test.dart +test/models/outer_composite_test.dart +test/models/outer_enum_default_value_test.dart +test/models/outer_enum_integer_default_value_test.dart +test/models/outer_enum_integer_test.dart +test/models/outer_enum_test.dart +test/models/parent_pet_test.dart +test/models/pet_composition_test.dart +test/models/pet_ref_test.dart +test/models/pet_test.dart +test/models/pet_using_all_of_test.dart +test/models/pet_with_required_tags_test.dart +test/models/pets_multicontent_test_post_request_address_test.dart +test/models/pets_multicontent_test_post_request_test.dart +test/models/pig_test.dart +test/models/property_name_collision_test.dart +test/models/quadrilateral_interface_test.dart +test/models/quadrilateral_test.dart +test/models/read_only_first_test.dart +test/models/scalar_any_of_test.dart +test/models/scalar_test.dart +test/models/scalene_triangle_test.dart +test/models/shape_interface_test.dart +test/models/shape_or_null_test.dart +test/models/shape_test.dart +test/models/simple_quadrilateral_test.dart +test/models/special_model_name_test.dart +test/models/tag_test.dart +test/models/test_endpoint_parameters_request_test.dart +test/models/test_enum_parameters_request_test.dart +test/models/test_inline_freeform_additional_properties_request_test.dart +test/models/test_json_form_data_request_test.dart +test/models/triangle_interface_test.dart +test/models/triangle_test.dart +test/models/update_pet_with_form_request_test.dart +test/models/upload_file_request_test.dart +test/models/upload_file_with_required_file_request_test.dart +test/models/user_test.dart +test/models/value_test.dart +test/models/variable_test.dart +test/models/whale_test.dart +test/models/xml_item_test.dart +test/models/zebra_test.dart +test/networking/helpers_test.dart +test/serialization/helpers_test.dart +test/utils.dart diff --git a/samples/openapi3/client/petstore/dart/next/.openapi-generator/VERSION b/samples/openapi3/client/petstore/dart/next/.openapi-generator/VERSION new file mode 100644 index 000000000000..884119126398 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.11.0-SNAPSHOT diff --git a/samples/openapi3/client/petstore/dart/next/CHANGELOG.md b/samples/openapi3/client/petstore/dart/next/CHANGELOG.md new file mode 100644 index 000000000000..effe43c82c8a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/samples/openapi3/client/petstore/dart/next/README.md b/samples/openapi3/client/petstore/dart/next/README.md new file mode 100644 index 000000000000..dc8305fc967f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/README.md @@ -0,0 +1,8 @@ +# petstore_api (EXPERIMENTAL) +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 1.0.0 +- Generator version: 7.11.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.DartNextClientCodegen diff --git a/samples/openapi3/client/petstore/dart/next/lib/_internal.dart b/samples/openapi3/client/petstore/dart/next/lib/_internal.dart new file mode 100644 index 000000000000..2e301696b353 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/_internal.dart @@ -0,0 +1,11 @@ +export 'src/serialization/_internal.dart'; +export 'src/networking/_internal.dart'; +export 'dart:core'; +export 'petstore_api.dart'; +export 'package:cross_file/cross_file.dart'; +export 'dart:convert'; +export 'dart:typed_data'; +export 'package:xml/xml.dart'; +export 'package:http_parser/http_parser.dart'; +export 'package:meta/meta.dart'; +export 'dart:math'; \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/petstore_api.dart b/samples/openapi3/client/petstore/dart/next/lib/petstore_api.dart new file mode 100644 index 000000000000..a489e94158ae --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/petstore_api.dart @@ -0,0 +1,10 @@ +/// Auto generated openapi bindings +library; + +export 'src/api_facade.dart'; +export 'src/apis/_exports.dart'; +export 'src/models/_exports.dart'; +export 'src/networking/_exports.dart'; +export 'src/serialization/_exports.dart'; + +export 'package:openapi_infrastructure/openapi_infrastructure.dart'; \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/api_facade.dart b/samples/openapi3/client/petstore/dart/next/lib/src/api_facade.dart new file mode 100644 index 000000000000..b05a4e64dfd5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/api_facade.dart @@ -0,0 +1,59 @@ +import 'package:openapi_infrastructure/openapi_infrastructure.dart'; + +import 'apis/_exports.dart'; + +/// A facade class as an entry point to the generated APIs +class PetstoreApi { + static final defaultBaseUrl = Uri.parse(r'http://petstore.swagger.io:80/v2'); + + final NetworkingClientBase networkingClient; + final Uri baseUrl; + + PetstoreApi({ + required this.networkingClient, + Uri? baseUrl, + }) : baseUrl = defaultBaseUrl; + + + + late final anotherFakeApi = AnotherFakeApi( + networkingClient: networkingClient, + baseUrl: baseUrl, + ); + + late final defaultApi = DefaultApi( + networkingClient: networkingClient, + baseUrl: baseUrl, + ); + + late final fakeApi = FakeApi( + networkingClient: networkingClient, + baseUrl: baseUrl, + ); + + late final fakeClassnameTags123Api = FakeClassnameTags123Api( + networkingClient: networkingClient, + baseUrl: baseUrl, + ); + + late final petApi = PetApi( + networkingClient: networkingClient, + baseUrl: baseUrl, + ); + + late final storeApi = StoreApi( + networkingClient: networkingClient, + baseUrl: baseUrl, + ); + + late final userApi = UserApi( + networkingClient: networkingClient, + baseUrl: baseUrl, + ); + + late final valuesApi = ValuesApi( + networkingClient: networkingClient, + baseUrl: baseUrl, + ); + +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/_exports.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/_exports.dart new file mode 100644 index 000000000000..0884ec8fb270 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/_exports.dart @@ -0,0 +1,8 @@ +export 'another_fake_api.dart'; +export 'default_api.dart'; +export 'fake_api.dart'; +export 'fake_classname_tags123_api.dart'; +export 'pet_api.dart'; +export 'store_api.dart'; +export 'user_api.dart'; +export 'values_api.dart'; diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/another_fake_api.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/another_fake_api.dart new file mode 100644 index 000000000000..7ead6b46717b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/another_fake_api.dart @@ -0,0 +1,81 @@ +import 'package:petstore_api/_internal.dart'; + +part 'another_fake_api.requests.dart'; +part 'another_fake_api.responses.dart'; + +class AnotherFakeApi { + final NetworkingClientBase networkingClient; + final Uri baseUrl; + final Map userContext; + + const AnotherFakeApi({ + required this.networkingClient, + required this.baseUrl, + this.userContext = const {}, + }); + + Future $123testSpecialTags( + AnotherFakeApi$123testSpecialTagsRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return AnotherFakeApi$123testSpecialTagsResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future getParameterArrayNumber( + AnotherFakeApiGetParameterArrayNumberRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return AnotherFakeApiGetParameterArrayNumberResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future getParameterStringNumber( + AnotherFakeApiGetParameterStringNumberRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return AnotherFakeApiGetParameterStringNumberResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future nullRequestBody( + AnotherFakeApiNullRequestBodyRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return AnotherFakeApiNullRequestBodyResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/another_fake_api.requests.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/another_fake_api.requests.dart new file mode 100644 index 000000000000..b34d7d12e507 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/another_fake_api.requests.dart @@ -0,0 +1,578 @@ +// ignore_for_file: unnecessary_type_check + +part of 'another_fake_api.dart'; + + + + + + + + +abstract class AnotherFakeApi$123testSpecialTagsRequest { + static const pathTemplate = r'/another-fake/dummy'; + static String method = r'PATCH'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory AnotherFakeApi$123testSpecialTagsRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = AnotherFakeApi$123testSpecialTagsRequestUnsafe; + + + const factory AnotherFakeApi$123testSpecialTagsRequest.applicationJson({ + required + Client + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = AnotherFakeApi$123testSpecialTagsRequestApplicationJson; + + + const AnotherFakeApi$123testSpecialTagsRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [AnotherFakeApi$123testSpecialTagsRequest], where you can send arbitrary bytes in the body. +class AnotherFakeApi$123testSpecialTagsRequestUnsafe extends AnotherFakeApi$123testSpecialTagsRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const AnotherFakeApi$123testSpecialTagsRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class AnotherFakeApi$123testSpecialTagsRequestApplicationJson extends AnotherFakeApi$123testSpecialTagsRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Client + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Client.$reflection + +, +) +; + + + const AnotherFakeApi$123testSpecialTagsRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + + + class AnotherFakeApiGetParameterArrayNumberRequest { + static const pathTemplate = r'/fake/parameter-array-number'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// array integer + /// spec name: array + final + List< + + int +> + array; + + + + const AnotherFakeApiGetParameterArrayNumberRequest({ + + this.array = + const + [1] + +, + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + + r'array': OpenApiParameterSerializationHeader(parameterName: r'array',explode: false).serialize(array), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + class AnotherFakeApiGetParameterStringNumberRequest { + static const pathTemplate = r'/fake/parameter-string-number'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// string number + /// spec name: string_number + final + double + stringNumber; + + + + const AnotherFakeApiGetParameterStringNumberRequest({ + + required this.stringNumber , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + + r'string_number': OpenApiParameterSerializationHeader(parameterName: r'string_number',explode: false).serialize(stringNumber), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + + + + + class AnotherFakeApiNullRequestBodyRequest { + static const pathTemplate = r'/fake/null-request-body'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// + /// spec name: Accept-Language + final UndefinedWrapper< + String +> acceptLanguage; + + + + + const AnotherFakeApiNullRequestBodyRequest({ + + this.acceptLanguage= const UndefinedWrapper + .undefined() +, + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + if (acceptLanguage.isDefined) + r'Accept-Language': OpenApiParameterSerializationHeader(parameterName: r'Accept-Language',explode: false).serialize(acceptLanguage.valueRequired), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/another_fake_api.responses.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/another_fake_api.responses.dart new file mode 100644 index 000000000000..8cb86d287d90 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/another_fake_api.responses.dart @@ -0,0 +1,417 @@ +// ignore_for_file: unnecessary_type_check, unnecessary_null_comparison, unnecessary_cast + +part of 'another_fake_api.dart'; + + +class AnotherFakeApi$123testSpecialTagsResponse { + AnotherFakeApi$123testSpecialTagsResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(AnotherFakeApi$123testSpecialTagsResponse200 response) on200, + required T Function(AnotherFakeApi$123testSpecialTagsResponse response) other, + }) { + return switch (this) { + AnotherFakeApi$123testSpecialTagsResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => AnotherFakeApi$123testSpecialTagsResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return AnotherFakeApi$123testSpecialTagsResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class AnotherFakeApi$123testSpecialTagsResponse200 extends AnotherFakeApi$123testSpecialTagsResponse { + AnotherFakeApi$123testSpecialTagsResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson response) onApplicationJson, + + required T Function(AnotherFakeApi$123testSpecialTagsResponse200 response) other, + }) { + return switch (this) { + + AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return AnotherFakeApi$123testSpecialTagsResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson extends AnotherFakeApi$123testSpecialTagsResponse200 { + final UndefinedWrapper< + Client +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Client.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class AnotherFakeApiGetParameterArrayNumberResponse { + AnotherFakeApiGetParameterArrayNumberResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(AnotherFakeApiGetParameterArrayNumberResponse200 response) on200, + required T Function(AnotherFakeApiGetParameterArrayNumberResponse response) other, + }) { + return switch (this) { + AnotherFakeApiGetParameterArrayNumberResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => AnotherFakeApiGetParameterArrayNumberResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return AnotherFakeApiGetParameterArrayNumberResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class AnotherFakeApiGetParameterArrayNumberResponse200 extends AnotherFakeApiGetParameterArrayNumberResponse { + AnotherFakeApiGetParameterArrayNumberResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return AnotherFakeApiGetParameterArrayNumberResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class AnotherFakeApiGetParameterStringNumberResponse { + AnotherFakeApiGetParameterStringNumberResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(AnotherFakeApiGetParameterStringNumberResponse200 response) on200, + required T Function(AnotherFakeApiGetParameterStringNumberResponse response) other, + }) { + return switch (this) { + AnotherFakeApiGetParameterStringNumberResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => AnotherFakeApiGetParameterStringNumberResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return AnotherFakeApiGetParameterStringNumberResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class AnotherFakeApiGetParameterStringNumberResponse200 extends AnotherFakeApiGetParameterStringNumberResponse { + AnotherFakeApiGetParameterStringNumberResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return AnotherFakeApiGetParameterStringNumberResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class AnotherFakeApiNullRequestBodyResponse { + AnotherFakeApiNullRequestBodyResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(AnotherFakeApiNullRequestBodyResponse200 response) on200, + required T Function(AnotherFakeApiNullRequestBodyResponse response) other, + }) { + return switch (this) { + AnotherFakeApiNullRequestBodyResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => AnotherFakeApiNullRequestBodyResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return AnotherFakeApiNullRequestBodyResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class AnotherFakeApiNullRequestBodyResponse200 extends AnotherFakeApiNullRequestBodyResponse { + AnotherFakeApiNullRequestBodyResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return AnotherFakeApiNullRequestBodyResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/default_api.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/default_api.dart new file mode 100644 index 000000000000..b20e713fe560 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/default_api.dart @@ -0,0 +1,81 @@ +import 'package:petstore_api/_internal.dart'; + +part 'default_api.requests.dart'; +part 'default_api.responses.dart'; + +class DefaultApi { + final NetworkingClientBase networkingClient; + final Uri baseUrl; + final Map userContext; + + const DefaultApi({ + required this.networkingClient, + required this.baseUrl, + this.userContext = const {}, + }); + + Future fakeAnyOfWIthSameErasureGet( + DefaultApiFakeAnyOfWIthSameErasureGetRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return DefaultApiFakeAnyOfWIthSameErasureGetResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future fakeOneOfWIthSameErasureGet( + DefaultApiFakeOneOfWIthSameErasureGetRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return DefaultApiFakeOneOfWIthSameErasureGetResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future fooGet( + DefaultApiFooGetRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return DefaultApiFooGetResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future petsMulticontentTestPost( + DefaultApiPetsMulticontentTestPostRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return DefaultApiPetsMulticontentTestPostResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/default_api.requests.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/default_api.requests.dart new file mode 100644 index 000000000000..f2b250811d75 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/default_api.requests.dart @@ -0,0 +1,956 @@ +// ignore_for_file: unnecessary_type_check + +part of 'default_api.dart'; + + + + + class DefaultApiFakeAnyOfWIthSameErasureGetRequest { + static const pathTemplate = r'/fake/anyOfWIthSameErasure'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const DefaultApiFakeAnyOfWIthSameErasureGetRequest({ + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + class DefaultApiFakeOneOfWIthSameErasureGetRequest { + static const pathTemplate = r'/fake/oneOfWIthSameErasure'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const DefaultApiFakeOneOfWIthSameErasureGetRequest({ + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + class DefaultApiFooGetRequest { + static const pathTemplate = r'/foo'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const DefaultApiFooGetRequest({ + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + +abstract class DefaultApiPetsMulticontentTestPostRequest { + static const pathTemplate = r'/pets/multicontent-test'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory DefaultApiPetsMulticontentTestPostRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = DefaultApiPetsMulticontentTestPostRequestUnsafe; + + + const factory DefaultApiPetsMulticontentTestPostRequest.applicationJson({ + required + Pet + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = DefaultApiPetsMulticontentTestPostRequestApplicationJson; + + const factory DefaultApiPetsMulticontentTestPostRequest.applicationXml({ + required + NewPet + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = DefaultApiPetsMulticontentTestPostRequestApplicationXml; + + const factory DefaultApiPetsMulticontentTestPostRequest.applicationXWwwFormUrlencoded({ + required + Triangle + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = DefaultApiPetsMulticontentTestPostRequestApplicationXWwwFormUrlencoded; + + const factory DefaultApiPetsMulticontentTestPostRequest.textPlain({ + required + int + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = DefaultApiPetsMulticontentTestPostRequestTextPlain; + + const factory DefaultApiPetsMulticontentTestPostRequest.anyAny({ + required Object +? data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = DefaultApiPetsMulticontentTestPostRequestAnyAny; + + const factory DefaultApiPetsMulticontentTestPostRequest.textAny({ + required + String + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = DefaultApiPetsMulticontentTestPostRequestTextAny; + + const factory DefaultApiPetsMulticontentTestPostRequest.multipartFormData({ + required + PetsMulticontentTestPostRequest + data, + UndefinedWrapper< + String +> profileImagesHelloHeader, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = DefaultApiPetsMulticontentTestPostRequestMultipartFormData; + + + const DefaultApiPetsMulticontentTestPostRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [DefaultApiPetsMulticontentTestPostRequest], where you can send arbitrary bytes in the body. +class DefaultApiPetsMulticontentTestPostRequestUnsafe extends DefaultApiPetsMulticontentTestPostRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const DefaultApiPetsMulticontentTestPostRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class DefaultApiPetsMulticontentTestPostRequestApplicationJson extends DefaultApiPetsMulticontentTestPostRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Pet + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + + const DefaultApiPetsMulticontentTestPostRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + +class DefaultApiPetsMulticontentTestPostRequestApplicationXml extends DefaultApiPetsMulticontentTestPostRequest { + static const specMediaType = r'application/xml'; + + @override + String get contentType => specMediaType; + + final + NewPet + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + NewPet.$reflection + +, +) +; + + + const DefaultApiPetsMulticontentTestPostRequestApplicationXml({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + +class DefaultApiPetsMulticontentTestPostRequestApplicationXWwwFormUrlencoded extends DefaultApiPetsMulticontentTestPostRequest { + static const specMediaType = r'application/x-www-form-urlencoded'; + + @override + String get contentType => specMediaType; + + final + Triangle + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Triangle.$reflection + +, +) +; + + + const DefaultApiPetsMulticontentTestPostRequestApplicationXWwwFormUrlencoded({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + r'name': PropertyEncodingRule( + style: r'form', + explode: true, + + + + ), + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + +class DefaultApiPetsMulticontentTestPostRequestTextPlain extends DefaultApiPetsMulticontentTestPostRequest { + static const specMediaType = r'text/plain'; + + @override + String get contentType => specMediaType; + + final + int + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +; + + + const DefaultApiPetsMulticontentTestPostRequestTextPlain({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + +class DefaultApiPetsMulticontentTestPostRequestAnyAny extends DefaultApiPetsMulticontentTestPostRequest { + static const specMediaType = r'*/*'; + + @override + String get contentType => specMediaType; + + final Object +? data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +; + + + const DefaultApiPetsMulticontentTestPostRequestAnyAny({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + +class DefaultApiPetsMulticontentTestPostRequestTextAny extends DefaultApiPetsMulticontentTestPostRequest { + static const specMediaType = r'text/*'; + + @override + String get contentType => specMediaType; + + final + String + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +; + + + const DefaultApiPetsMulticontentTestPostRequestTextAny({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + +class DefaultApiPetsMulticontentTestPostRequestMultipartFormData extends DefaultApiPetsMulticontentTestPostRequest { + static const specMediaType = r'multipart/form-data'; + + @override + String get contentType => specMediaType; + + final + PetsMulticontentTestPostRequest + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PetsMulticontentTestPostRequest.$reflection + +, +) +; + + final UndefinedWrapper< + String +> profileImagesHelloHeader; + + const DefaultApiPetsMulticontentTestPostRequestMultipartFormData({ + required this.data, + this.profileImagesHelloHeader= const UndefinedWrapper + .undefined() +, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + r'address': PropertyEncodingRule( + style: r'form', + + + contentType: MediaType.parse(r'application/json'), + + ), + r'profileImages': PropertyEncodingRule( + style: r'form', + + + + + headers: { + if (profileImagesHelloHeader.isDefined) + r'hello': OpenApiParameterSerializationHeader(parameterName: r'hello',explode: false).serialize(profileImagesHelloHeader.valueRequired), + }, + + ), + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/default_api.responses.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/default_api.responses.dart new file mode 100644 index 000000000000..880610064f6c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/default_api.responses.dart @@ -0,0 +1,1833 @@ +// ignore_for_file: unnecessary_type_check, unnecessary_null_comparison, unnecessary_cast + +part of 'default_api.dart'; + + +class DefaultApiFakeAnyOfWIthSameErasureGetResponse { + DefaultApiFakeAnyOfWIthSameErasureGetResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(DefaultApiFakeAnyOfWIthSameErasureGetResponse200 response) on200, + required T Function(DefaultApiFakeAnyOfWIthSameErasureGetResponse response) other, + }) { + return switch (this) { + DefaultApiFakeAnyOfWIthSameErasureGetResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => DefaultApiFakeAnyOfWIthSameErasureGetResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return DefaultApiFakeAnyOfWIthSameErasureGetResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class DefaultApiFakeAnyOfWIthSameErasureGetResponse200 extends DefaultApiFakeAnyOfWIthSameErasureGetResponse { + DefaultApiFakeAnyOfWIthSameErasureGetResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson response) onApplicationJson, + + required T Function(DefaultApiFakeAnyOfWIthSameErasureGetResponse200 response) other, + }) { + return switch (this) { + + DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return DefaultApiFakeAnyOfWIthSameErasureGetResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson extends DefaultApiFakeAnyOfWIthSameErasureGetResponse200 { + final UndefinedWrapper< + FakeAnyOfWIthSameErasureGet200Response +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + FakeAnyOfWIthSameErasureGet200Response.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class DefaultApiFakeOneOfWIthSameErasureGetResponse { + DefaultApiFakeOneOfWIthSameErasureGetResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(DefaultApiFakeOneOfWIthSameErasureGetResponse200 response) on200, + required T Function(DefaultApiFakeOneOfWIthSameErasureGetResponse response) other, + }) { + return switch (this) { + DefaultApiFakeOneOfWIthSameErasureGetResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => DefaultApiFakeOneOfWIthSameErasureGetResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return DefaultApiFakeOneOfWIthSameErasureGetResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class DefaultApiFakeOneOfWIthSameErasureGetResponse200 extends DefaultApiFakeOneOfWIthSameErasureGetResponse { + DefaultApiFakeOneOfWIthSameErasureGetResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson response) onApplicationJson, + + required T Function(DefaultApiFakeOneOfWIthSameErasureGetResponse200 response) other, + }) { + return switch (this) { + + DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return DefaultApiFakeOneOfWIthSameErasureGetResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson extends DefaultApiFakeOneOfWIthSameErasureGetResponse200 { + final UndefinedWrapper< + FakeOneOfWIthSameErasureGet200Response +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + FakeOneOfWIthSameErasureGet200Response.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class DefaultApiFooGetResponse { + DefaultApiFooGetResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(DefaultApiFooGetResponseDefault response) onDefault, + required T Function(DefaultApiFooGetResponse response) other, + }) { + return switch (this) { + DefaultApiFooGetResponseDefault response => onDefault(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'default'), + () => DefaultApiFooGetResponseDefault.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return DefaultApiFooGetResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class DefaultApiFooGetResponseDefault extends DefaultApiFooGetResponse { + DefaultApiFooGetResponseDefault({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T splitDefault({ + + required T Function(DefaultApiFooGetResponseDefaultApplicationJson response) onApplicationJson, + + required T Function(DefaultApiFooGetResponseDefault response) other, + }) { + return switch (this) { + + DefaultApiFooGetResponseDefaultApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => DefaultApiFooGetResponseDefaultApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return DefaultApiFooGetResponseDefault( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class DefaultApiFooGetResponseDefaultApplicationJson extends DefaultApiFooGetResponseDefault { + final UndefinedWrapper< + FooGetDefaultResponse +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + FooGetDefaultResponse.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + DefaultApiFooGetResponseDefaultApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiFooGetResponseDefaultApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiFooGetResponseDefaultApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return DefaultApiFooGetResponseDefaultApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class DefaultApiPetsMulticontentTestPostResponse { + DefaultApiPetsMulticontentTestPostResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(DefaultApiPetsMulticontentTestPostResponse200 response) on200, + required T Function(DefaultApiPetsMulticontentTestPostResponse201 response) on201, + required T Function(DefaultApiPetsMulticontentTestPostResponse2XX response) on2XX, + required T Function(DefaultApiPetsMulticontentTestPostResponseDefault response) onDefault, + required T Function(DefaultApiPetsMulticontentTestPostResponse response) other, + }) { + return switch (this) { + DefaultApiPetsMulticontentTestPostResponse200 response => on200(response), + DefaultApiPetsMulticontentTestPostResponse201 response => on201(response), + DefaultApiPetsMulticontentTestPostResponse2XX response => on2XX(response), + DefaultApiPetsMulticontentTestPostResponseDefault response => onDefault(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => DefaultApiPetsMulticontentTestPostResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'201'), + () => DefaultApiPetsMulticontentTestPostResponse201.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'2XX'), + () => DefaultApiPetsMulticontentTestPostResponse2XX.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'default'), + () => DefaultApiPetsMulticontentTestPostResponseDefault.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return DefaultApiPetsMulticontentTestPostResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class DefaultApiPetsMulticontentTestPostResponse200 extends DefaultApiPetsMulticontentTestPostResponse { + DefaultApiPetsMulticontentTestPostResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(DefaultApiPetsMulticontentTestPostResponse200TextPlain response) onTextPlain, + + required T Function(DefaultApiPetsMulticontentTestPostResponse200AnyAny response) onAnyAny, + + required T Function(DefaultApiPetsMulticontentTestPostResponse200TextAny response) onTextAny, + + required T Function(DefaultApiPetsMulticontentTestPostResponse200MultipartFormData response) onMultipartFormData, + + required T Function(DefaultApiPetsMulticontentTestPostResponse200 response) other, + }) { + return switch (this) { + + DefaultApiPetsMulticontentTestPostResponse200TextPlain response => onTextPlain(response), + + DefaultApiPetsMulticontentTestPostResponse200AnyAny response => onAnyAny(response), + + DefaultApiPetsMulticontentTestPostResponse200TextAny response => onTextAny(response), + + DefaultApiPetsMulticontentTestPostResponse200MultipartFormData response => onMultipartFormData(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'text/plain')), + () => DefaultApiPetsMulticontentTestPostResponse200TextPlain.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'*/*')), + () => DefaultApiPetsMulticontentTestPostResponse200AnyAny.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'text/*')), + () => DefaultApiPetsMulticontentTestPostResponse200TextAny.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'multipart/form-data')), + () => DefaultApiPetsMulticontentTestPostResponse200MultipartFormData.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return DefaultApiPetsMulticontentTestPostResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is text/plain. +class DefaultApiPetsMulticontentTestPostResponse200TextPlain extends DefaultApiPetsMulticontentTestPostResponse200 { + final UndefinedWrapper< + int +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +; + + /// The raw result of decoding bytes to text. + final String? rawText; + + DefaultApiPetsMulticontentTestPostResponse200TextPlain({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawText, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'text'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = serialized; + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiPetsMulticontentTestPostResponse200TextPlain( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiPetsMulticontentTestPostResponse200TextPlain( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawText: v, + + ); + } + default: + } + return DefaultApiPetsMulticontentTestPostResponse200TextPlain( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is */*. +class DefaultApiPetsMulticontentTestPostResponse200AnyAny extends DefaultApiPetsMulticontentTestPostResponse200 { + final UndefinedWrapper body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +; + + + DefaultApiPetsMulticontentTestPostResponse200AnyAny({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + default: + } + return DefaultApiPetsMulticontentTestPostResponse200AnyAny( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is text/*. +class DefaultApiPetsMulticontentTestPostResponse200TextAny extends DefaultApiPetsMulticontentTestPostResponse200 { + final UndefinedWrapper< + String +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +; + + /// The raw result of decoding bytes to text. + final String? rawText; + + DefaultApiPetsMulticontentTestPostResponse200TextAny({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawText, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'text'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = serialized; + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiPetsMulticontentTestPostResponse200TextAny( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiPetsMulticontentTestPostResponse200TextAny( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawText: v, + + ); + } + default: + } + return DefaultApiPetsMulticontentTestPostResponse200TextAny( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is multipart/form-data. +class DefaultApiPetsMulticontentTestPostResponse200MultipartFormData extends DefaultApiPetsMulticontentTestPostResponse200 { + final UndefinedWrapper< + PetsMulticontentTestPostRequest +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PetsMulticontentTestPostRequest.$reflection + +, +) +; + + + DefaultApiPetsMulticontentTestPostResponse200MultipartFormData({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + r'address': PropertyEncodingRule( + style: r'form', + + + contentType: MediaType.parse(r'application/json'), + ), + r'profileImages': PropertyEncodingRule( + style: r'form', + + + + ), + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + default: + } + return DefaultApiPetsMulticontentTestPostResponse200MultipartFormData( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + +class DefaultApiPetsMulticontentTestPostResponse201 extends DefaultApiPetsMulticontentTestPostResponse { + DefaultApiPetsMulticontentTestPostResponse201({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split201({ + + required T Function(DefaultApiPetsMulticontentTestPostResponse201ApplicationJson response) onApplicationJson, + + required T Function(DefaultApiPetsMulticontentTestPostResponse201ApplicationXml response) onApplicationXml, + + required T Function(DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded response) onApplicationXWwwFormUrlencoded, + + required T Function(DefaultApiPetsMulticontentTestPostResponse201 response) other, + }) { + return switch (this) { + + DefaultApiPetsMulticontentTestPostResponse201ApplicationJson response => onApplicationJson(response), + + DefaultApiPetsMulticontentTestPostResponse201ApplicationXml response => onApplicationXml(response), + + DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded response => onApplicationXWwwFormUrlencoded(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => DefaultApiPetsMulticontentTestPostResponse201ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/xml')), + () => DefaultApiPetsMulticontentTestPostResponse201ApplicationXml.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/x-www-form-urlencoded')), + () => DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return DefaultApiPetsMulticontentTestPostResponse201( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class DefaultApiPetsMulticontentTestPostResponse201ApplicationJson extends DefaultApiPetsMulticontentTestPostResponse201 { + final UndefinedWrapper< + Pet +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + DefaultApiPetsMulticontentTestPostResponse201ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiPetsMulticontentTestPostResponse201ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiPetsMulticontentTestPostResponse201ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return DefaultApiPetsMulticontentTestPostResponse201ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is application/xml. +class DefaultApiPetsMulticontentTestPostResponse201ApplicationXml extends DefaultApiPetsMulticontentTestPostResponse201 { + final UndefinedWrapper< + NewPet +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + NewPet.$reflection + +, +) +; + + /// The raw result of calling XmlDocumentFragment.parse + final XmlDocumentFragment? rawXml; + + DefaultApiPetsMulticontentTestPostResponse201ApplicationXml({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawXml, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'xml'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = XmlDocumentFragment.parse(serialized); + // check if v can be deserialized to xml + return DefaultApiPetsMulticontentTestPostResponse201ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawXml: v, + + ); + default: + } + return DefaultApiPetsMulticontentTestPostResponse201ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is application/x-www-form-urlencoded. +class DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded extends DefaultApiPetsMulticontentTestPostResponse201 { + final UndefinedWrapper< + Triangle +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Triangle.$reflection + +, +) +; + + final Map? rawQueryParameters; + + DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawQueryParameters, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + r'name': PropertyEncodingRule( + style: r'form', + explode: true, + + + ), + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'x-www-form-urlencoded'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final queryParametersAll = Uri(query: serialized).queryParametersAll; + final v = queryParametersAll.map((k,v) => MapEntry(k, v.isEmpty ? null : v.length == 1 ? v.first.isEmpty ? null : v.first : v)); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawQueryParameters: v, + + ); + } + default: + } + return DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + + + + + + + + + + +class DefaultApiPetsMulticontentTestPostResponse2XX extends DefaultApiPetsMulticontentTestPostResponse { + DefaultApiPetsMulticontentTestPostResponse2XX({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.xRateLimit= const UndefinedWrapper + .undefined() +, + this.xRateLimitRemaining= const UndefinedWrapper + .undefined() +, + this.xRateLimitReset= const UndefinedWrapper + .undefined() +, + }); + + final UndefinedWrapper< + int +> xRateLimit; + final UndefinedWrapper< + int +> xRateLimitRemaining; + final UndefinedWrapper< + DateTime +> xRateLimitReset; + + T split2XX({ + + required T Function(DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson response) onApplicationJson, + + required T Function(DefaultApiPetsMulticontentTestPostResponse2XX response) other, + }) { + return switch (this) { + + DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return DefaultApiPetsMulticontentTestPostResponse2XX( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson extends DefaultApiPetsMulticontentTestPostResponse2XX { + final UndefinedWrapper< + Pet +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + super.xRateLimit, + super.xRateLimitRemaining, + super.xRateLimitReset, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + xRateLimit: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Rate-Limit')), +xRateLimitRemaining: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-RateLimit-Remaining')), +xRateLimitReset: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-RateLimit-Reset')), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + xRateLimit: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Rate-Limit')), +xRateLimitRemaining: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-RateLimit-Remaining')), +xRateLimitReset: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-RateLimit-Reset')), + + ); + } + default: + } + return DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + xRateLimit: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Rate-Limit')), +xRateLimitRemaining: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-RateLimit-Remaining')), +xRateLimitReset: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-RateLimit-Reset')), + + ); + } +} + + + +class DefaultApiPetsMulticontentTestPostResponseDefault extends DefaultApiPetsMulticontentTestPostResponse { + DefaultApiPetsMulticontentTestPostResponseDefault({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T splitDefault({ + + required T Function(DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson response) onApplicationJson, + + required T Function(DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded response) onApplicationXWwwFormUrlencoded, + + required T Function(DefaultApiPetsMulticontentTestPostResponseDefault response) other, + }) { + return switch (this) { + + DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson response => onApplicationJson(response), + + DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded response => onApplicationXWwwFormUrlencoded(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/x-www-form-urlencoded')), + () => DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return DefaultApiPetsMulticontentTestPostResponseDefault( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson extends DefaultApiPetsMulticontentTestPostResponseDefault { + final UndefinedWrapper< + Pet +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is application/x-www-form-urlencoded. +class DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded extends DefaultApiPetsMulticontentTestPostResponseDefault { + final UndefinedWrapper< + Triangle +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Triangle.$reflection + +, +) +; + + final Map? rawQueryParameters; + + DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawQueryParameters, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + r'name': PropertyEncodingRule( + style: r'form', + explode: true, + + + ), + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'x-www-form-urlencoded'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final queryParametersAll = Uri(query: serialized).queryParametersAll; + final v = queryParametersAll.map((k,v) => MapEntry(k, v.isEmpty ? null : v.length == 1 ? v.first.isEmpty ? null : v.first : v)); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawQueryParameters: v, + + ); + } + default: + } + return DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_api.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_api.dart new file mode 100644 index 000000000000..9f51c2a51d4a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_api.dart @@ -0,0 +1,353 @@ +import 'package:petstore_api/_internal.dart'; + +part 'fake_api.requests.dart'; +part 'fake_api.responses.dart'; + +class FakeApi { + final NetworkingClientBase networkingClient; + final Uri baseUrl; + final Map userContext; + + const FakeApi({ + required this.networkingClient, + required this.baseUrl, + this.userContext = const {}, + }); + + Future fakeGetFreeFormObjectGet( + FakeApiFakeGetFreeFormObjectGetRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiFakeGetFreeFormObjectGetResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future fakeOuterBooleanSerialize( + FakeApiFakeOuterBooleanSerializeRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiFakeOuterBooleanSerializeResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future fakeOuterCompositeSerialize( + FakeApiFakeOuterCompositeSerializeRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiFakeOuterCompositeSerializeResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future fakeOuterNumberSerialize( + FakeApiFakeOuterNumberSerializeRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiFakeOuterNumberSerializeResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future fakeOuterStringSerialize( + FakeApiFakeOuterStringSerializeRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiFakeOuterStringSerializeResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future fakeUploadRefRequestBodies( + FakeApiFakeUploadRefRequestBodiesRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiFakeUploadRefRequestBodiesResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future getFakeArrayofenums( + FakeApiGetFakeArrayofenumsRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiGetFakeArrayofenumsResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future getFakeHealth( + FakeApiGetFakeHealthRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiGetFakeHealthResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future getParameterNameMapping( + FakeApiGetParameterNameMappingRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiGetParameterNameMappingResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testAdditionalPropertiesReference( + FakeApiTestAdditionalPropertiesReferenceRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestAdditionalPropertiesReferenceResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testBodyWithFileSchema( + FakeApiTestBodyWithFileSchemaRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestBodyWithFileSchemaResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testBodyWithQueryParams( + FakeApiTestBodyWithQueryParamsRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestBodyWithQueryParamsResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testClientModel( + FakeApiTestClientModelRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestClientModelResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testEndpointParameters( + FakeApiTestEndpointParametersRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestEndpointParametersResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testEnumParameters( + FakeApiTestEnumParametersRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestEnumParametersResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testGroupParameters( + FakeApiTestGroupParametersRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestGroupParametersResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testInlineAdditionalProperties( + FakeApiTestInlineAdditionalPropertiesRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestInlineAdditionalPropertiesResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testInlineFreeformAdditionalProperties( + FakeApiTestInlineFreeformAdditionalPropertiesRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestInlineFreeformAdditionalPropertiesResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testJsonFormData( + FakeApiTestJsonFormDataRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestJsonFormDataResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testQueryParameterCollectionFormat( + FakeApiTestQueryParameterCollectionFormatRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestQueryParameterCollectionFormatResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future testStringMapReference( + FakeApiTestStringMapReferenceRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeApiTestStringMapReferenceResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_api.requests.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_api.requests.dart new file mode 100644 index 000000000000..86320c188591 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_api.requests.dart @@ -0,0 +1,4534 @@ +// ignore_for_file: unnecessary_type_check + +part of 'fake_api.dart'; + + + + + class FakeApiFakeGetFreeFormObjectGetRequest { + static const pathTemplate = r'/fake/get-free-form-object'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const FakeApiFakeGetFreeFormObjectGetRequest({ + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + +abstract class FakeApiFakeOuterBooleanSerializeRequest { + static const pathTemplate = r'/fake/outer/boolean'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiFakeOuterBooleanSerializeRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiFakeOuterBooleanSerializeRequestUnsafe; + + + const factory FakeApiFakeOuterBooleanSerializeRequest.applicationJson({ + required + bool + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiFakeOuterBooleanSerializeRequestApplicationJson; + + + const FakeApiFakeOuterBooleanSerializeRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiFakeOuterBooleanSerializeRequest], where you can send arbitrary bytes in the body. +class FakeApiFakeOuterBooleanSerializeRequestUnsafe extends FakeApiFakeOuterBooleanSerializeRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiFakeOuterBooleanSerializeRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiFakeOuterBooleanSerializeRequestApplicationJson extends FakeApiFakeOuterBooleanSerializeRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + bool + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +; + + + const FakeApiFakeOuterBooleanSerializeRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + +abstract class FakeApiFakeOuterCompositeSerializeRequest { + static const pathTemplate = r'/fake/outer/composite'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiFakeOuterCompositeSerializeRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiFakeOuterCompositeSerializeRequestUnsafe; + + + const factory FakeApiFakeOuterCompositeSerializeRequest.applicationJson({ + required + OuterComposite + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiFakeOuterCompositeSerializeRequestApplicationJson; + + + const FakeApiFakeOuterCompositeSerializeRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiFakeOuterCompositeSerializeRequest], where you can send arbitrary bytes in the body. +class FakeApiFakeOuterCompositeSerializeRequestUnsafe extends FakeApiFakeOuterCompositeSerializeRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiFakeOuterCompositeSerializeRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiFakeOuterCompositeSerializeRequestApplicationJson extends FakeApiFakeOuterCompositeSerializeRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + OuterComposite + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + OuterComposite.$reflection + +, +) +; + + + const FakeApiFakeOuterCompositeSerializeRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + +abstract class FakeApiFakeOuterNumberSerializeRequest { + static const pathTemplate = r'/fake/outer/number'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiFakeOuterNumberSerializeRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiFakeOuterNumberSerializeRequestUnsafe; + + + const factory FakeApiFakeOuterNumberSerializeRequest.applicationJson({ + required + num + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiFakeOuterNumberSerializeRequestApplicationJson; + + + const FakeApiFakeOuterNumberSerializeRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiFakeOuterNumberSerializeRequest], where you can send arbitrary bytes in the body. +class FakeApiFakeOuterNumberSerializeRequestUnsafe extends FakeApiFakeOuterNumberSerializeRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiFakeOuterNumberSerializeRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiFakeOuterNumberSerializeRequestApplicationJson extends FakeApiFakeOuterNumberSerializeRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + num + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +; + + + const FakeApiFakeOuterNumberSerializeRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + +abstract class FakeApiFakeOuterStringSerializeRequest { + static const pathTemplate = r'/fake/outer/string'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiFakeOuterStringSerializeRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiFakeOuterStringSerializeRequestUnsafe; + + + const factory FakeApiFakeOuterStringSerializeRequest.applicationJson({ + required + String + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiFakeOuterStringSerializeRequestApplicationJson; + + + const FakeApiFakeOuterStringSerializeRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiFakeOuterStringSerializeRequest], where you can send arbitrary bytes in the body. +class FakeApiFakeOuterStringSerializeRequestUnsafe extends FakeApiFakeOuterStringSerializeRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiFakeOuterStringSerializeRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiFakeOuterStringSerializeRequestApplicationJson extends FakeApiFakeOuterStringSerializeRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + String + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +; + + + const FakeApiFakeOuterStringSerializeRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + + + + + + + + +abstract class FakeApiFakeUploadRefRequestBodiesRequest { + static const pathTemplate = r'/fake/pet/{petId}/uploadImage'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// ID of pet to update + /// spec name: petId + final + int + petId; + + + + + const factory FakeApiFakeUploadRefRequestBodiesRequest.unsafe({ + + required + int + petId, + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiFakeUploadRefRequestBodiesRequestUnsafe; + + + + const FakeApiFakeUploadRefRequestBodiesRequest({ + + required this.petId , + + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'petId',).expand(resolvedPath, petId); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiFakeUploadRefRequestBodiesRequest], where you can send arbitrary bytes in the body. +class FakeApiFakeUploadRefRequestBodiesRequestUnsafe extends FakeApiFakeUploadRefRequestBodiesRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiFakeUploadRefRequestBodiesRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + required super.petId, + + + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + + + + class FakeApiGetFakeArrayofenumsRequest { + static const pathTemplate = r'/fake/array-of-enums'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const FakeApiGetFakeArrayofenumsRequest({ + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + class FakeApiGetFakeHealthRequest { + static const pathTemplate = r'/fake/health'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const FakeApiGetFakeHealthRequest({ + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + + + + + + + + + class FakeApiGetParameterNameMappingRequest { + static const pathTemplate = r'/fake/parameter-name-mapping'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// _type + /// spec name: _type + final + int + $type; + + + /// type + /// spec name: type + final + String + type; + + + /// type_ + /// spec name: type_ + final + String + type$; + + + + const FakeApiGetParameterNameMappingRequest({ + + required this.$type , + + + required this.type , + + + required this.type$ , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'type', allowEmptyValue: false,).expandUri(methodUri, type); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + + r'_type': OpenApiParameterSerializationHeader(parameterName: r'_type',explode: false).serialize($type), + + r'type_': OpenApiParameterSerializationHeader(parameterName: r'type_',explode: false).serialize(type$), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + + +abstract class FakeApiTestAdditionalPropertiesReferenceRequest { + static const pathTemplate = r'/fake/additionalProperties-reference'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiTestAdditionalPropertiesReferenceRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiTestAdditionalPropertiesReferenceRequestUnsafe; + + + const factory FakeApiTestAdditionalPropertiesReferenceRequest.applicationJson({ + required + Map + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiTestAdditionalPropertiesReferenceRequestApplicationJson; + + + const FakeApiTestAdditionalPropertiesReferenceRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiTestAdditionalPropertiesReferenceRequest], where you can send arbitrary bytes in the body. +class FakeApiTestAdditionalPropertiesReferenceRequestUnsafe extends FakeApiTestAdditionalPropertiesReferenceRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiTestAdditionalPropertiesReferenceRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiTestAdditionalPropertiesReferenceRequestApplicationJson extends FakeApiTestAdditionalPropertiesReferenceRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Map + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +) +, +) +; + + + const FakeApiTestAdditionalPropertiesReferenceRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + +abstract class FakeApiTestBodyWithFileSchemaRequest { + static const pathTemplate = r'/fake/body-with-file-schema'; + static String method = r'PUT'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiTestBodyWithFileSchemaRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiTestBodyWithFileSchemaRequestUnsafe; + + + const factory FakeApiTestBodyWithFileSchemaRequest.applicationJson({ + required + FileSchemaTestClass + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiTestBodyWithFileSchemaRequestApplicationJson; + + + const FakeApiTestBodyWithFileSchemaRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiTestBodyWithFileSchemaRequest], where you can send arbitrary bytes in the body. +class FakeApiTestBodyWithFileSchemaRequestUnsafe extends FakeApiTestBodyWithFileSchemaRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiTestBodyWithFileSchemaRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiTestBodyWithFileSchemaRequestApplicationJson extends FakeApiTestBodyWithFileSchemaRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + FileSchemaTestClass + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + FileSchemaTestClass.$reflection + +, +) +; + + + const FakeApiTestBodyWithFileSchemaRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + + + + +abstract class FakeApiTestBodyWithQueryParamsRequest { + static const pathTemplate = r'/fake/body-with-query-params'; + static String method = r'PUT'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// + /// spec name: query + final + String + query; + + + + const factory FakeApiTestBodyWithQueryParamsRequest.unsafe({ + + required + String + query, + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiTestBodyWithQueryParamsRequestUnsafe; + + + const factory FakeApiTestBodyWithQueryParamsRequest.applicationJson({ + required + User + data, + + required + String + query, + + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiTestBodyWithQueryParamsRequestApplicationJson; + + + const FakeApiTestBodyWithQueryParamsRequest({ + + required this.query , + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'query', allowEmptyValue: false,).expandUri(methodUri, query); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiTestBodyWithQueryParamsRequest], where you can send arbitrary bytes in the body. +class FakeApiTestBodyWithQueryParamsRequestUnsafe extends FakeApiTestBodyWithQueryParamsRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiTestBodyWithQueryParamsRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + required super.query, + + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiTestBodyWithQueryParamsRequestApplicationJson extends FakeApiTestBodyWithQueryParamsRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + User + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + User.$reflection + +, +) +; + + + const FakeApiTestBodyWithQueryParamsRequestApplicationJson({ + required this.data, + + required super.query, + + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + +abstract class FakeApiTestClientModelRequest { + static const pathTemplate = r'/fake'; + static String method = r'PATCH'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiTestClientModelRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiTestClientModelRequestUnsafe; + + + const factory FakeApiTestClientModelRequest.applicationJson({ + required + Client + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiTestClientModelRequestApplicationJson; + + + const FakeApiTestClientModelRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiTestClientModelRequest], where you can send arbitrary bytes in the body. +class FakeApiTestClientModelRequestUnsafe extends FakeApiTestClientModelRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiTestClientModelRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiTestClientModelRequestApplicationJson extends FakeApiTestClientModelRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Client + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Client.$reflection + +, +) +; + + + const FakeApiTestClientModelRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +abstract class FakeApiTestEndpointParametersRequest { + static const pathTemplate = r'/fake'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + + + + + + + + + + + + + + const factory FakeApiTestEndpointParametersRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiTestEndpointParametersRequestUnsafe; + + + + const FakeApiTestEndpointParametersRequest({ + + + + + + + + + + + + + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiTestEndpointParametersRequest], where you can send arbitrary bytes in the body. +class FakeApiTestEndpointParametersRequestUnsafe extends FakeApiTestEndpointParametersRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiTestEndpointParametersRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + + + + + + + + + + + + + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + + + +extension type const EnumHeaderStringArrayEnum._(String value) implements String { + const EnumHeaderStringArrayEnum.greaterThan() : this._(r'>'); + const EnumHeaderStringArrayEnum.value() : this._(r'$'); + + /// Creates a [EnumHeaderStringArrayEnum] enum from a value and safely checking if it exists. + factory EnumHeaderStringArrayEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'greaterThan', oasValue: r'>', value: EnumHeaderStringArrayEnum.greaterThan()), + + EnumMemberReflection(dartName: r'value', oasValue: r'$', value: EnumHeaderStringArrayEnum.value()), + + ], + ); + + factory EnumHeaderStringArrayEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumHeaderStringArrayEnum] enum from a value without checking if it exists. + const EnumHeaderStringArrayEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumHeaderStringArrayEnum.greaterThan(), + EnumHeaderStringArrayEnum.value(), + + ]; +} + + + + + +extension type const EnumHeaderStringEnum._(String value) implements String { + const EnumHeaderStringEnum.abc() : this._(r'_abc'); + const EnumHeaderStringEnum.efg() : this._(r'-efg'); + const EnumHeaderStringEnum.xyz() : this._(r'(xyz)'); + + /// Creates a [EnumHeaderStringEnum] enum from a value and safely checking if it exists. + factory EnumHeaderStringEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'abc', oasValue: r'_abc', value: EnumHeaderStringEnum.abc()), + + EnumMemberReflection(dartName: r'efg', oasValue: r'-efg', value: EnumHeaderStringEnum.efg()), + + EnumMemberReflection(dartName: r'xyz', oasValue: r'(xyz)', value: EnumHeaderStringEnum.xyz()), + + ], + ); + + factory EnumHeaderStringEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumHeaderStringEnum] enum from a value without checking if it exists. + const EnumHeaderStringEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumHeaderStringEnum.abc(), + EnumHeaderStringEnum.efg(), + EnumHeaderStringEnum.xyz(), + + ]; +} + + + +extension type const EnumQueryStringArrayEnum._(String value) implements String { + const EnumQueryStringArrayEnum.greaterThan() : this._(r'>'); + const EnumQueryStringArrayEnum.value() : this._(r'$'); + + /// Creates a [EnumQueryStringArrayEnum] enum from a value and safely checking if it exists. + factory EnumQueryStringArrayEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'greaterThan', oasValue: r'>', value: EnumQueryStringArrayEnum.greaterThan()), + + EnumMemberReflection(dartName: r'value', oasValue: r'$', value: EnumQueryStringArrayEnum.value()), + + ], + ); + + factory EnumQueryStringArrayEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumQueryStringArrayEnum] enum from a value without checking if it exists. + const EnumQueryStringArrayEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumQueryStringArrayEnum.greaterThan(), + EnumQueryStringArrayEnum.value(), + + ]; +} + + + + + +extension type const EnumQueryStringEnum._(String value) implements String { + const EnumQueryStringEnum.abc() : this._(r'_abc'); + const EnumQueryStringEnum.efg() : this._(r'-efg'); + const EnumQueryStringEnum.xyz() : this._(r'(xyz)'); + + /// Creates a [EnumQueryStringEnum] enum from a value and safely checking if it exists. + factory EnumQueryStringEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'abc', oasValue: r'_abc', value: EnumQueryStringEnum.abc()), + + EnumMemberReflection(dartName: r'efg', oasValue: r'-efg', value: EnumQueryStringEnum.efg()), + + EnumMemberReflection(dartName: r'xyz', oasValue: r'(xyz)', value: EnumQueryStringEnum.xyz()), + + ], + ); + + factory EnumQueryStringEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumQueryStringEnum] enum from a value without checking if it exists. + const EnumQueryStringEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumQueryStringEnum.abc(), + EnumQueryStringEnum.efg(), + EnumQueryStringEnum.xyz(), + + ]; +} + + + +extension type const EnumQueryIntegerEnum._(int value) implements int { + const EnumQueryIntegerEnum.number1() : this._(1); + const EnumQueryIntegerEnum.numberNegative2() : this._(-2); + + /// Creates a [EnumQueryIntegerEnum] enum from a value and safely checking if it exists. + factory EnumQueryIntegerEnum.$safe(int value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forint, + members: [ + + EnumMemberReflection(dartName: r'number1', oasValue: 1, value: EnumQueryIntegerEnum.number1()), + + EnumMemberReflection(dartName: r'numberNegative2', oasValue: -2, value: EnumQueryIntegerEnum.numberNegative2()), + + ], + ); + + factory EnumQueryIntegerEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumQueryIntegerEnum] enum from a value without checking if it exists. + const EnumQueryIntegerEnum.$unsafe(int value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumQueryIntegerEnum.number1(), + EnumQueryIntegerEnum.numberNegative2(), + + ]; +} + + + +extension type const EnumQueryDoubleEnum._(double value) implements double { + const EnumQueryDoubleEnum.number11() : this._(1.1); + const EnumQueryDoubleEnum.numberNegative12() : this._(-1.2); + + /// Creates a [EnumQueryDoubleEnum] enum from a value and safely checking if it exists. + factory EnumQueryDoubleEnum.$safe(double value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.fordouble, + members: [ + + EnumMemberReflection(dartName: r'number11', oasValue: 1.1, value: EnumQueryDoubleEnum.number11()), + + EnumMemberReflection(dartName: r'numberNegative12', oasValue: -1.2, value: EnumQueryDoubleEnum.numberNegative12()), + + ], + ); + + factory EnumQueryDoubleEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumQueryDoubleEnum] enum from a value without checking if it exists. + const EnumQueryDoubleEnum.$unsafe(double value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumQueryDoubleEnum.number11(), + EnumQueryDoubleEnum.numberNegative12(), + + ]; +} + + + + +extension type const InnerEnum._(String value) implements String { + + /// Creates a [InnerEnum] enum from a value and safely checking if it exists. + factory InnerEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + ], + ); + + factory InnerEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [InnerEnum] enum from a value without checking if it exists. + const InnerEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + + ]; +} + + + + + +extension type const EnumFormStringEnum._(String value) implements String { + /// Form parameter enum test (string) + const EnumFormStringEnum.abc() : this._(r'_abc'); + /// Form parameter enum test (string) + const EnumFormStringEnum.efg() : this._(r'-efg'); + /// Form parameter enum test (string) + const EnumFormStringEnum.xyz() : this._(r'(xyz)'); + + /// Creates a [EnumFormStringEnum] enum from a value and safely checking if it exists. + factory EnumFormStringEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'abc', oasValue: r'_abc', value: EnumFormStringEnum.abc()), + + EnumMemberReflection(dartName: r'efg', oasValue: r'-efg', value: EnumFormStringEnum.efg()), + + EnumMemberReflection(dartName: r'xyz', oasValue: r'(xyz)', value: EnumFormStringEnum.xyz()), + + ], + ); + + factory EnumFormStringEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumFormStringEnum] enum from a value without checking if it exists. + const EnumFormStringEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumFormStringEnum.abc(), + EnumFormStringEnum.efg(), + EnumFormStringEnum.xyz(), + + ]; +} + + + class FakeApiTestEnumParametersRequest { + static const pathTemplate = r'/fake'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// Header parameter enum test (string array) + /// spec name: enum_header_string_array + final UndefinedWrapper< + List< + + EnumHeaderStringArrayEnum +> +> enumHeaderStringArray; + + + /// Header parameter enum test (string) + /// spec name: enum_header_string + final UndefinedWrapper< + EnumHeaderStringEnum +> enumHeaderString; + + + /// Query parameter enum test (string array) + /// spec name: enum_query_string_array + final UndefinedWrapper< + List< + + EnumQueryStringArrayEnum +> +> enumQueryStringArray; + + + /// Query parameter enum test (string) + /// spec name: enum_query_string + final UndefinedWrapper< + EnumQueryStringEnum +> enumQueryString; + + + /// Query parameter enum test (double) + /// spec name: enum_query_integer + final UndefinedWrapper< + EnumQueryIntegerEnum +> enumQueryInteger; + + + /// Query parameter enum test (double) + /// spec name: enum_query_double + final UndefinedWrapper< + EnumQueryDoubleEnum +> enumQueryDouble; + + + + + + const FakeApiTestEnumParametersRequest({ + + this.enumHeaderStringArray= const UndefinedWrapper + .undefined() +, + + + this.enumHeaderString= const UndefinedWrapper + ( + EnumHeaderStringEnum.$unsafe('-efg') + + ) + +, + + + this.enumQueryStringArray= const UndefinedWrapper + .undefined() +, + + + this.enumQueryString= const UndefinedWrapper + ( + EnumQueryStringEnum.$unsafe('-efg') + + ) + +, + + + this.enumQueryInteger= const UndefinedWrapper + .undefined() +, + + + this.enumQueryDouble= const UndefinedWrapper + .undefined() +, + + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + if (enumQueryStringArray.isDefined) { + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'enum_query_string_array', allowEmptyValue: false,).expandUri(methodUri, enumQueryStringArray.valueRequired); + } + if (enumQueryString.isDefined) { + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'enum_query_string', allowEmptyValue: false,).expandUri(methodUri, enumQueryString.valueRequired); + } + if (enumQueryInteger.isDefined) { + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'enum_query_integer', allowEmptyValue: false,).expandUri(methodUri, enumQueryInteger.valueRequired); + } + if (enumQueryDouble.isDefined) { + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'enum_query_double', allowEmptyValue: false,).expandUri(methodUri, enumQueryDouble.valueRequired); + } + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + if (enumHeaderStringArray.isDefined) + r'enum_header_string_array': OpenApiParameterSerializationHeader(parameterName: r'enum_header_string_array',explode: false).serialize(enumHeaderStringArray.valueRequired), + if (enumHeaderString.isDefined) + r'enum_header_string': OpenApiParameterSerializationHeader(parameterName: r'enum_header_string',explode: false).serialize(enumHeaderString.valueRequired), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + class FakeApiTestGroupParametersRequest { + static const pathTemplate = r'/fake'; + static String method = r'DELETE'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// Required String in group parameters + /// spec name: required_string_group + final + int + requiredStringGroup; + + + /// Required Boolean in group parameters + /// spec name: required_boolean_group + final + bool + requiredBooleanGroup; + + + /// Required Integer in group parameters + /// spec name: required_int64_group + final + int + requiredInt64Group; + + + /// String in group parameters + /// spec name: string_group + final UndefinedWrapper< + int +> stringGroup; + + + /// Boolean in group parameters + /// spec name: boolean_group + final UndefinedWrapper< + bool +> booleanGroup; + + + /// Integer in group parameters + /// spec name: int64_group + final UndefinedWrapper< + int +> int64Group; + + + + const FakeApiTestGroupParametersRequest({ + + required this.requiredStringGroup , + + + required this.requiredBooleanGroup , + + + required this.requiredInt64Group , + + + this.stringGroup= const UndefinedWrapper + .undefined() +, + + + this.booleanGroup= const UndefinedWrapper + .undefined() +, + + + this.int64Group= const UndefinedWrapper + .undefined() +, + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'required_string_group', allowEmptyValue: false,).expandUri(methodUri, requiredStringGroup); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'required_int64_group', allowEmptyValue: false,).expandUri(methodUri, requiredInt64Group); + if (stringGroup.isDefined) { + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'string_group', allowEmptyValue: false,).expandUri(methodUri, stringGroup.valueRequired); + } + if (int64Group.isDefined) { + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'int64_group', allowEmptyValue: false,).expandUri(methodUri, int64Group.valueRequired); + } + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + + r'required_boolean_group': OpenApiParameterSerializationHeader(parameterName: r'required_boolean_group',explode: false).serialize(requiredBooleanGroup), + if (booleanGroup.isDefined) + r'boolean_group': OpenApiParameterSerializationHeader(parameterName: r'boolean_group',explode: false).serialize(booleanGroup.valueRequired), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + + +abstract class FakeApiTestInlineAdditionalPropertiesRequest { + static const pathTemplate = r'/fake/inline-additionalProperties'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiTestInlineAdditionalPropertiesRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiTestInlineAdditionalPropertiesRequestUnsafe; + + + const factory FakeApiTestInlineAdditionalPropertiesRequest.applicationJson({ + required + Map + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiTestInlineAdditionalPropertiesRequestApplicationJson; + + + const FakeApiTestInlineAdditionalPropertiesRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiTestInlineAdditionalPropertiesRequest], where you can send arbitrary bytes in the body. +class FakeApiTestInlineAdditionalPropertiesRequestUnsafe extends FakeApiTestInlineAdditionalPropertiesRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiTestInlineAdditionalPropertiesRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiTestInlineAdditionalPropertiesRequestApplicationJson extends FakeApiTestInlineAdditionalPropertiesRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Map + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +; + + + const FakeApiTestInlineAdditionalPropertiesRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + +abstract class FakeApiTestInlineFreeformAdditionalPropertiesRequest { + static const pathTemplate = r'/fake/inline-freeform-additionalProperties'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiTestInlineFreeformAdditionalPropertiesRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiTestInlineFreeformAdditionalPropertiesRequestUnsafe; + + + const factory FakeApiTestInlineFreeformAdditionalPropertiesRequest.applicationJson({ + required + TestInlineFreeformAdditionalPropertiesRequest + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiTestInlineFreeformAdditionalPropertiesRequestApplicationJson; + + + const FakeApiTestInlineFreeformAdditionalPropertiesRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiTestInlineFreeformAdditionalPropertiesRequest], where you can send arbitrary bytes in the body. +class FakeApiTestInlineFreeformAdditionalPropertiesRequestUnsafe extends FakeApiTestInlineFreeformAdditionalPropertiesRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiTestInlineFreeformAdditionalPropertiesRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiTestInlineFreeformAdditionalPropertiesRequestApplicationJson extends FakeApiTestInlineFreeformAdditionalPropertiesRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + TestInlineFreeformAdditionalPropertiesRequest + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + TestInlineFreeformAdditionalPropertiesRequest.$reflection + +, +) +; + + + const FakeApiTestInlineFreeformAdditionalPropertiesRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + + + + + class FakeApiTestJsonFormDataRequest { + static const pathTemplate = r'/fake/jsonFormData'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + + + const FakeApiTestJsonFormDataRequest({ + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +abstract class FakeApiTestQueryParameterCollectionFormatRequest { + static const pathTemplate = r'/fake/test-query-parameters'; + static String method = r'PUT'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// + /// spec name: pipe + final + List< + + String +> + pipe; + + + /// + /// spec name: ioutil + final + List< + + String +> + ioutil; + + + /// + /// spec name: http + final + List< + + String +> + http; + + + /// + /// spec name: url + final + List< + + String +> + url; + + + /// + /// spec name: context + final + List< + + String +> + context; + + + const factory FakeApiTestQueryParameterCollectionFormatRequest.unsafe({ + + required + List< + + String +> + pipe, + + required + List< + + String +> + ioutil, + + required + List< + + String +> + http, + + required + List< + + String +> + url, + + required + List< + + String +> + context, + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiTestQueryParameterCollectionFormatRequestUnsafe; + + + + const FakeApiTestQueryParameterCollectionFormatRequest({ + + required this.pipe , + + + required this.ioutil , + + + required this.http , + + + required this.url , + + + required this.context , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'pipe', allowEmptyValue: false,).expandUri(methodUri, pipe); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: false, parameterName: r'ioutil', allowEmptyValue: false,).expandUri(methodUri, ioutil); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'spaceDelimited', explode: false, parameterName: r'http', allowEmptyValue: false,).expandUri(methodUri, http); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: false, parameterName: r'url', allowEmptyValue: false,).expandUri(methodUri, url); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'context', allowEmptyValue: false,).expandUri(methodUri, context); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiTestQueryParameterCollectionFormatRequest], where you can send arbitrary bytes in the body. +class FakeApiTestQueryParameterCollectionFormatRequestUnsafe extends FakeApiTestQueryParameterCollectionFormatRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiTestQueryParameterCollectionFormatRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + required super.pipe, + + + required super.ioutil, + + + required super.http, + + + required super.url, + + + required super.context, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + + + + + + + + + +abstract class FakeApiTestStringMapReferenceRequest { + static const pathTemplate = r'/fake/stringMap-reference'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeApiTestStringMapReferenceRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeApiTestStringMapReferenceRequestUnsafe; + + + const factory FakeApiTestStringMapReferenceRequest.applicationJson({ + required + Map + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeApiTestStringMapReferenceRequestApplicationJson; + + + const FakeApiTestStringMapReferenceRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeApiTestStringMapReferenceRequest], where you can send arbitrary bytes in the body. +class FakeApiTestStringMapReferenceRequestUnsafe extends FakeApiTestStringMapReferenceRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeApiTestStringMapReferenceRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeApiTestStringMapReferenceRequestApplicationJson extends FakeApiTestStringMapReferenceRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Map + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +; + + + const FakeApiTestStringMapReferenceRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_api.responses.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_api.responses.dart new file mode 100644 index 000000000000..8fe24290e1a0 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_api.responses.dart @@ -0,0 +1,2537 @@ +// ignore_for_file: unnecessary_type_check, unnecessary_null_comparison, unnecessary_cast + +part of 'fake_api.dart'; + + +class FakeApiFakeGetFreeFormObjectGetResponse { + FakeApiFakeGetFreeFormObjectGetResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiFakeGetFreeFormObjectGetResponse200 response) on200, + required T Function(FakeApiFakeGetFreeFormObjectGetResponse response) other, + }) { + return switch (this) { + FakeApiFakeGetFreeFormObjectGetResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiFakeGetFreeFormObjectGetResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiFakeGetFreeFormObjectGetResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiFakeGetFreeFormObjectGetResponse200 extends FakeApiFakeGetFreeFormObjectGetResponse { + FakeApiFakeGetFreeFormObjectGetResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson response) onApplicationJson, + + required T Function(FakeApiFakeGetFreeFormObjectGetResponse200 response) other, + }) { + return switch (this) { + + FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeApiFakeGetFreeFormObjectGetResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson extends FakeApiFakeGetFreeFormObjectGetResponse200 { + final UndefinedWrapper< + FreeFormObjectTestClass +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + FreeFormObjectTestClass.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class FakeApiFakeOuterBooleanSerializeResponse { + FakeApiFakeOuterBooleanSerializeResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiFakeOuterBooleanSerializeResponse200 response) on200, + required T Function(FakeApiFakeOuterBooleanSerializeResponse response) other, + }) { + return switch (this) { + FakeApiFakeOuterBooleanSerializeResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiFakeOuterBooleanSerializeResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiFakeOuterBooleanSerializeResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiFakeOuterBooleanSerializeResponse200 extends FakeApiFakeOuterBooleanSerializeResponse { + FakeApiFakeOuterBooleanSerializeResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeApiFakeOuterBooleanSerializeResponse200AnyAny response) onAnyAny, + + required T Function(FakeApiFakeOuterBooleanSerializeResponse200 response) other, + }) { + return switch (this) { + + FakeApiFakeOuterBooleanSerializeResponse200AnyAny response => onAnyAny(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'*/*')), + () => FakeApiFakeOuterBooleanSerializeResponse200AnyAny.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeApiFakeOuterBooleanSerializeResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is */*. +class FakeApiFakeOuterBooleanSerializeResponse200AnyAny extends FakeApiFakeOuterBooleanSerializeResponse200 { + final UndefinedWrapper< + bool +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +; + + + FakeApiFakeOuterBooleanSerializeResponse200AnyAny({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + default: + } + return FakeApiFakeOuterBooleanSerializeResponse200AnyAny( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class FakeApiFakeOuterCompositeSerializeResponse { + FakeApiFakeOuterCompositeSerializeResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiFakeOuterCompositeSerializeResponse200 response) on200, + required T Function(FakeApiFakeOuterCompositeSerializeResponse response) other, + }) { + return switch (this) { + FakeApiFakeOuterCompositeSerializeResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiFakeOuterCompositeSerializeResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiFakeOuterCompositeSerializeResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiFakeOuterCompositeSerializeResponse200 extends FakeApiFakeOuterCompositeSerializeResponse { + FakeApiFakeOuterCompositeSerializeResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeApiFakeOuterCompositeSerializeResponse200AnyAny response) onAnyAny, + + required T Function(FakeApiFakeOuterCompositeSerializeResponse200 response) other, + }) { + return switch (this) { + + FakeApiFakeOuterCompositeSerializeResponse200AnyAny response => onAnyAny(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'*/*')), + () => FakeApiFakeOuterCompositeSerializeResponse200AnyAny.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeApiFakeOuterCompositeSerializeResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is */*. +class FakeApiFakeOuterCompositeSerializeResponse200AnyAny extends FakeApiFakeOuterCompositeSerializeResponse200 { + final UndefinedWrapper< + OuterComposite +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + OuterComposite.$reflection + +, +) +; + + + FakeApiFakeOuterCompositeSerializeResponse200AnyAny({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + default: + } + return FakeApiFakeOuterCompositeSerializeResponse200AnyAny( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class FakeApiFakeOuterNumberSerializeResponse { + FakeApiFakeOuterNumberSerializeResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiFakeOuterNumberSerializeResponse200 response) on200, + required T Function(FakeApiFakeOuterNumberSerializeResponse response) other, + }) { + return switch (this) { + FakeApiFakeOuterNumberSerializeResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiFakeOuterNumberSerializeResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiFakeOuterNumberSerializeResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiFakeOuterNumberSerializeResponse200 extends FakeApiFakeOuterNumberSerializeResponse { + FakeApiFakeOuterNumberSerializeResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeApiFakeOuterNumberSerializeResponse200AnyAny response) onAnyAny, + + required T Function(FakeApiFakeOuterNumberSerializeResponse200 response) other, + }) { + return switch (this) { + + FakeApiFakeOuterNumberSerializeResponse200AnyAny response => onAnyAny(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'*/*')), + () => FakeApiFakeOuterNumberSerializeResponse200AnyAny.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeApiFakeOuterNumberSerializeResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is */*. +class FakeApiFakeOuterNumberSerializeResponse200AnyAny extends FakeApiFakeOuterNumberSerializeResponse200 { + final UndefinedWrapper< + num +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +; + + + FakeApiFakeOuterNumberSerializeResponse200AnyAny({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + default: + } + return FakeApiFakeOuterNumberSerializeResponse200AnyAny( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class FakeApiFakeOuterStringSerializeResponse { + FakeApiFakeOuterStringSerializeResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiFakeOuterStringSerializeResponse200 response) on200, + required T Function(FakeApiFakeOuterStringSerializeResponse response) other, + }) { + return switch (this) { + FakeApiFakeOuterStringSerializeResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiFakeOuterStringSerializeResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiFakeOuterStringSerializeResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiFakeOuterStringSerializeResponse200 extends FakeApiFakeOuterStringSerializeResponse { + FakeApiFakeOuterStringSerializeResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeApiFakeOuterStringSerializeResponse200AnyAny response) onAnyAny, + + required T Function(FakeApiFakeOuterStringSerializeResponse200 response) other, + }) { + return switch (this) { + + FakeApiFakeOuterStringSerializeResponse200AnyAny response => onAnyAny(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'*/*')), + () => FakeApiFakeOuterStringSerializeResponse200AnyAny.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeApiFakeOuterStringSerializeResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is */*. +class FakeApiFakeOuterStringSerializeResponse200AnyAny extends FakeApiFakeOuterStringSerializeResponse200 { + final UndefinedWrapper< + String +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +; + + + FakeApiFakeOuterStringSerializeResponse200AnyAny({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + default: + } + return FakeApiFakeOuterStringSerializeResponse200AnyAny( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class FakeApiFakeUploadRefRequestBodiesResponse { + FakeApiFakeUploadRefRequestBodiesResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiFakeUploadRefRequestBodiesResponse200 response) on200, + required T Function(FakeApiFakeUploadRefRequestBodiesResponse response) other, + }) { + return switch (this) { + FakeApiFakeUploadRefRequestBodiesResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiFakeUploadRefRequestBodiesResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiFakeUploadRefRequestBodiesResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiFakeUploadRefRequestBodiesResponse200 extends FakeApiFakeUploadRefRequestBodiesResponse { + FakeApiFakeUploadRefRequestBodiesResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson response) onApplicationJson, + + required T Function(FakeApiFakeUploadRefRequestBodiesResponse200 response) other, + }) { + return switch (this) { + + FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeApiFakeUploadRefRequestBodiesResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson extends FakeApiFakeUploadRefRequestBodiesResponse200 { + final UndefinedWrapper< + ApiResponse +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ApiResponse.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class FakeApiGetFakeArrayofenumsResponse { + FakeApiGetFakeArrayofenumsResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiGetFakeArrayofenumsResponse200 response) on200, + required T Function(FakeApiGetFakeArrayofenumsResponse response) other, + }) { + return switch (this) { + FakeApiGetFakeArrayofenumsResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiGetFakeArrayofenumsResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiGetFakeArrayofenumsResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiGetFakeArrayofenumsResponse200 extends FakeApiGetFakeArrayofenumsResponse { + FakeApiGetFakeArrayofenumsResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeApiGetFakeArrayofenumsResponse200ApplicationJson response) onApplicationJson, + + required T Function(FakeApiGetFakeArrayofenumsResponse200 response) other, + }) { + return switch (this) { + + FakeApiGetFakeArrayofenumsResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => FakeApiGetFakeArrayofenumsResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeApiGetFakeArrayofenumsResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + + + +/// Represent the response when content-type is application/json. +class FakeApiGetFakeArrayofenumsResponse200ApplicationJson extends FakeApiGetFakeArrayofenumsResponse200 { + final UndefinedWrapper< + List< + + OuterEnum +?> +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + OuterEnum.$reflection + +), +) +) +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + FakeApiGetFakeArrayofenumsResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return FakeApiGetFakeArrayofenumsResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return FakeApiGetFakeArrayofenumsResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return FakeApiGetFakeArrayofenumsResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class FakeApiGetFakeHealthResponse { + FakeApiGetFakeHealthResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiGetFakeHealthResponse200 response) on200, + required T Function(FakeApiGetFakeHealthResponse response) other, + }) { + return switch (this) { + FakeApiGetFakeHealthResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiGetFakeHealthResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiGetFakeHealthResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiGetFakeHealthResponse200 extends FakeApiGetFakeHealthResponse { + FakeApiGetFakeHealthResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeApiGetFakeHealthResponse200ApplicationJson response) onApplicationJson, + + required T Function(FakeApiGetFakeHealthResponse200 response) other, + }) { + return switch (this) { + + FakeApiGetFakeHealthResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => FakeApiGetFakeHealthResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeApiGetFakeHealthResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class FakeApiGetFakeHealthResponse200ApplicationJson extends FakeApiGetFakeHealthResponse200 { + final UndefinedWrapper< + HealthCheckResult +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + HealthCheckResult.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + FakeApiGetFakeHealthResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return FakeApiGetFakeHealthResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return FakeApiGetFakeHealthResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return FakeApiGetFakeHealthResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class FakeApiGetParameterNameMappingResponse { + FakeApiGetParameterNameMappingResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiGetParameterNameMappingResponse200 response) on200, + required T Function(FakeApiGetParameterNameMappingResponse response) other, + }) { + return switch (this) { + FakeApiGetParameterNameMappingResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiGetParameterNameMappingResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiGetParameterNameMappingResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiGetParameterNameMappingResponse200 extends FakeApiGetParameterNameMappingResponse { + FakeApiGetParameterNameMappingResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiGetParameterNameMappingResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestAdditionalPropertiesReferenceResponse { + FakeApiTestAdditionalPropertiesReferenceResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestAdditionalPropertiesReferenceResponse200 response) on200, + required T Function(FakeApiTestAdditionalPropertiesReferenceResponse response) other, + }) { + return switch (this) { + FakeApiTestAdditionalPropertiesReferenceResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiTestAdditionalPropertiesReferenceResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestAdditionalPropertiesReferenceResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestAdditionalPropertiesReferenceResponse200 extends FakeApiTestAdditionalPropertiesReferenceResponse { + FakeApiTestAdditionalPropertiesReferenceResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestAdditionalPropertiesReferenceResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestBodyWithFileSchemaResponse { + FakeApiTestBodyWithFileSchemaResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestBodyWithFileSchemaResponse200 response) on200, + required T Function(FakeApiTestBodyWithFileSchemaResponse response) other, + }) { + return switch (this) { + FakeApiTestBodyWithFileSchemaResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiTestBodyWithFileSchemaResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestBodyWithFileSchemaResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestBodyWithFileSchemaResponse200 extends FakeApiTestBodyWithFileSchemaResponse { + FakeApiTestBodyWithFileSchemaResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestBodyWithFileSchemaResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestBodyWithQueryParamsResponse { + FakeApiTestBodyWithQueryParamsResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestBodyWithQueryParamsResponse200 response) on200, + required T Function(FakeApiTestBodyWithQueryParamsResponse response) other, + }) { + return switch (this) { + FakeApiTestBodyWithQueryParamsResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiTestBodyWithQueryParamsResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestBodyWithQueryParamsResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestBodyWithQueryParamsResponse200 extends FakeApiTestBodyWithQueryParamsResponse { + FakeApiTestBodyWithQueryParamsResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestBodyWithQueryParamsResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestClientModelResponse { + FakeApiTestClientModelResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestClientModelResponse200 response) on200, + required T Function(FakeApiTestClientModelResponse response) other, + }) { + return switch (this) { + FakeApiTestClientModelResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiTestClientModelResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestClientModelResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestClientModelResponse200 extends FakeApiTestClientModelResponse { + FakeApiTestClientModelResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeApiTestClientModelResponse200ApplicationJson response) onApplicationJson, + + required T Function(FakeApiTestClientModelResponse200 response) other, + }) { + return switch (this) { + + FakeApiTestClientModelResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => FakeApiTestClientModelResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeApiTestClientModelResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class FakeApiTestClientModelResponse200ApplicationJson extends FakeApiTestClientModelResponse200 { + final UndefinedWrapper< + Client +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Client.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + FakeApiTestClientModelResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return FakeApiTestClientModelResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return FakeApiTestClientModelResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return FakeApiTestClientModelResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class FakeApiTestEndpointParametersResponse { + FakeApiTestEndpointParametersResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestEndpointParametersResponse400 response) on400, + required T Function(FakeApiTestEndpointParametersResponse404 response) on404, + required T Function(FakeApiTestEndpointParametersResponse response) other, + }) { + return switch (this) { + FakeApiTestEndpointParametersResponse400 response => on400(response), + FakeApiTestEndpointParametersResponse404 response => on404(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => FakeApiTestEndpointParametersResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'404'), + () => FakeApiTestEndpointParametersResponse404.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestEndpointParametersResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestEndpointParametersResponse400 extends FakeApiTestEndpointParametersResponse { + FakeApiTestEndpointParametersResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestEndpointParametersResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class FakeApiTestEndpointParametersResponse404 extends FakeApiTestEndpointParametersResponse { + FakeApiTestEndpointParametersResponse404({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestEndpointParametersResponse404( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestEnumParametersResponse { + FakeApiTestEnumParametersResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestEnumParametersResponse400 response) on400, + required T Function(FakeApiTestEnumParametersResponse404 response) on404, + required T Function(FakeApiTestEnumParametersResponse response) other, + }) { + return switch (this) { + FakeApiTestEnumParametersResponse400 response => on400(response), + FakeApiTestEnumParametersResponse404 response => on404(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => FakeApiTestEnumParametersResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'404'), + () => FakeApiTestEnumParametersResponse404.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestEnumParametersResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestEnumParametersResponse400 extends FakeApiTestEnumParametersResponse { + FakeApiTestEnumParametersResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestEnumParametersResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class FakeApiTestEnumParametersResponse404 extends FakeApiTestEnumParametersResponse { + FakeApiTestEnumParametersResponse404({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestEnumParametersResponse404( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestGroupParametersResponse { + FakeApiTestGroupParametersResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestGroupParametersResponse400 response) on400, + required T Function(FakeApiTestGroupParametersResponse response) other, + }) { + return switch (this) { + FakeApiTestGroupParametersResponse400 response => on400(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => FakeApiTestGroupParametersResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestGroupParametersResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestGroupParametersResponse400 extends FakeApiTestGroupParametersResponse { + FakeApiTestGroupParametersResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestGroupParametersResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestInlineAdditionalPropertiesResponse { + FakeApiTestInlineAdditionalPropertiesResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestInlineAdditionalPropertiesResponse200 response) on200, + required T Function(FakeApiTestInlineAdditionalPropertiesResponse response) other, + }) { + return switch (this) { + FakeApiTestInlineAdditionalPropertiesResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiTestInlineAdditionalPropertiesResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestInlineAdditionalPropertiesResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestInlineAdditionalPropertiesResponse200 extends FakeApiTestInlineAdditionalPropertiesResponse { + FakeApiTestInlineAdditionalPropertiesResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestInlineAdditionalPropertiesResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestInlineFreeformAdditionalPropertiesResponse { + FakeApiTestInlineFreeformAdditionalPropertiesResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestInlineFreeformAdditionalPropertiesResponse200 response) on200, + required T Function(FakeApiTestInlineFreeformAdditionalPropertiesResponse response) other, + }) { + return switch (this) { + FakeApiTestInlineFreeformAdditionalPropertiesResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiTestInlineFreeformAdditionalPropertiesResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestInlineFreeformAdditionalPropertiesResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestInlineFreeformAdditionalPropertiesResponse200 extends FakeApiTestInlineFreeformAdditionalPropertiesResponse { + FakeApiTestInlineFreeformAdditionalPropertiesResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestInlineFreeformAdditionalPropertiesResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestJsonFormDataResponse { + FakeApiTestJsonFormDataResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestJsonFormDataResponse200 response) on200, + required T Function(FakeApiTestJsonFormDataResponse response) other, + }) { + return switch (this) { + FakeApiTestJsonFormDataResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiTestJsonFormDataResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestJsonFormDataResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestJsonFormDataResponse200 extends FakeApiTestJsonFormDataResponse { + FakeApiTestJsonFormDataResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestJsonFormDataResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestQueryParameterCollectionFormatResponse { + FakeApiTestQueryParameterCollectionFormatResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestQueryParameterCollectionFormatResponse200 response) on200, + required T Function(FakeApiTestQueryParameterCollectionFormatResponse response) other, + }) { + return switch (this) { + FakeApiTestQueryParameterCollectionFormatResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiTestQueryParameterCollectionFormatResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestQueryParameterCollectionFormatResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestQueryParameterCollectionFormatResponse200 extends FakeApiTestQueryParameterCollectionFormatResponse { + FakeApiTestQueryParameterCollectionFormatResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestQueryParameterCollectionFormatResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class FakeApiTestStringMapReferenceResponse { + FakeApiTestStringMapReferenceResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeApiTestStringMapReferenceResponse200 response) on200, + required T Function(FakeApiTestStringMapReferenceResponse response) other, + }) { + return switch (this) { + FakeApiTestStringMapReferenceResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeApiTestStringMapReferenceResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeApiTestStringMapReferenceResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeApiTestStringMapReferenceResponse200 extends FakeApiTestStringMapReferenceResponse { + FakeApiTestStringMapReferenceResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return FakeApiTestStringMapReferenceResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_classname_tags123_api.dart new file mode 100644 index 000000000000..15f9bed5b863 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_classname_tags123_api.dart @@ -0,0 +1,33 @@ +import 'package:petstore_api/_internal.dart'; + +part 'fake_classname_tags123_api.requests.dart'; +part 'fake_classname_tags123_api.responses.dart'; + +class FakeClassnameTags123Api { + final NetworkingClientBase networkingClient; + final Uri baseUrl; + final Map userContext; + + const FakeClassnameTags123Api({ + required this.networkingClient, + required this.baseUrl, + this.userContext = const {}, + }); + + Future testClassname( + FakeClassnameTags123ApiTestClassnameRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return FakeClassnameTags123ApiTestClassnameResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_classname_tags123_api.requests.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_classname_tags123_api.requests.dart new file mode 100644 index 000000000000..cc3d1869baa6 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_classname_tags123_api.requests.dart @@ -0,0 +1,222 @@ +// ignore_for_file: unnecessary_type_check + +part of 'fake_classname_tags123_api.dart'; + + + + + + + + +abstract class FakeClassnameTags123ApiTestClassnameRequest { + static const pathTemplate = r'/fake_classname_test'; + static String method = r'PATCH'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory FakeClassnameTags123ApiTestClassnameRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = FakeClassnameTags123ApiTestClassnameRequestUnsafe; + + + const factory FakeClassnameTags123ApiTestClassnameRequest.applicationJson({ + required + Client + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = FakeClassnameTags123ApiTestClassnameRequestApplicationJson; + + + const FakeClassnameTags123ApiTestClassnameRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [FakeClassnameTags123ApiTestClassnameRequest], where you can send arbitrary bytes in the body. +class FakeClassnameTags123ApiTestClassnameRequestUnsafe extends FakeClassnameTags123ApiTestClassnameRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const FakeClassnameTags123ApiTestClassnameRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class FakeClassnameTags123ApiTestClassnameRequestApplicationJson extends FakeClassnameTags123ApiTestClassnameRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Client + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Client.$reflection + +, +) +; + + + const FakeClassnameTags123ApiTestClassnameRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_classname_tags123_api.responses.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_classname_tags123_api.responses.dart new file mode 100644 index 000000000000..f36bb2a2910d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/fake_classname_tags123_api.responses.dart @@ -0,0 +1,192 @@ +// ignore_for_file: unnecessary_type_check, unnecessary_null_comparison, unnecessary_cast + +part of 'fake_classname_tags123_api.dart'; + + +class FakeClassnameTags123ApiTestClassnameResponse { + FakeClassnameTags123ApiTestClassnameResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(FakeClassnameTags123ApiTestClassnameResponse200 response) on200, + required T Function(FakeClassnameTags123ApiTestClassnameResponse response) other, + }) { + return switch (this) { + FakeClassnameTags123ApiTestClassnameResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => FakeClassnameTags123ApiTestClassnameResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return FakeClassnameTags123ApiTestClassnameResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class FakeClassnameTags123ApiTestClassnameResponse200 extends FakeClassnameTags123ApiTestClassnameResponse { + FakeClassnameTags123ApiTestClassnameResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson response) onApplicationJson, + + required T Function(FakeClassnameTags123ApiTestClassnameResponse200 response) other, + }) { + return switch (this) { + + FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return FakeClassnameTags123ApiTestClassnameResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson extends FakeClassnameTags123ApiTestClassnameResponse200 { + final UndefinedWrapper< + Client +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Client.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/pet_api.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/pet_api.dart new file mode 100644 index 000000000000..175c9a212f26 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/pet_api.dart @@ -0,0 +1,162 @@ +import 'package:petstore_api/_internal.dart'; + +part 'pet_api.requests.dart'; +part 'pet_api.responses.dart'; + +class PetApi { + final NetworkingClientBase networkingClient; + final Uri baseUrl; + final Map userContext; + + const PetApi({ + required this.networkingClient, + required this.baseUrl, + this.userContext = const {}, + }); + + Future addPet( + PetApiAddPetRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return PetApiAddPetResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future deletePet( + PetApiDeletePetRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return PetApiDeletePetResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future findPetsByStatus( + PetApiFindPetsByStatusRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return PetApiFindPetsByStatusResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + @Deprecated('This operation has been deprecated') + Future findPetsByTags( + PetApiFindPetsByTagsRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return PetApiFindPetsByTagsResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future getPetById( + PetApiGetPetByIdRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return PetApiGetPetByIdResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future updatePet( + PetApiUpdatePetRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return PetApiUpdatePetResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future updatePetWithForm( + PetApiUpdatePetWithFormRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return PetApiUpdatePetWithFormResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future uploadFile( + PetApiUploadFileRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return PetApiUploadFileResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future uploadFileWithRequiredFile( + PetApiUploadFileWithRequiredFileRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return PetApiUploadFileWithRequiredFileResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/pet_api.requests.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/pet_api.requests.dart new file mode 100644 index 000000000000..6620f5c56881 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/pet_api.requests.dart @@ -0,0 +1,1643 @@ +// ignore_for_file: unnecessary_type_check + +part of 'pet_api.dart'; + + + + + + + + +abstract class PetApiAddPetRequest { + static const pathTemplate = r'/pet'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory PetApiAddPetRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = PetApiAddPetRequestUnsafe; + + + const factory PetApiAddPetRequest.applicationJson({ + required + Pet + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = PetApiAddPetRequestApplicationJson; + + const factory PetApiAddPetRequest.applicationXml({ + required + Pet + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = PetApiAddPetRequestApplicationXml; + + + const PetApiAddPetRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [PetApiAddPetRequest], where you can send arbitrary bytes in the body. +class PetApiAddPetRequestUnsafe extends PetApiAddPetRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const PetApiAddPetRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class PetApiAddPetRequestApplicationJson extends PetApiAddPetRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Pet + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + + const PetApiAddPetRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + +class PetApiAddPetRequestApplicationXml extends PetApiAddPetRequest { + static const specMediaType = r'application/xml'; + + @override + String get contentType => specMediaType; + + final + Pet + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + + const PetApiAddPetRequestApplicationXml({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + + + + + class PetApiDeletePetRequest { + static const pathTemplate = r'/pet/{petId}'; + static String method = r'DELETE'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// Pet id to delete + /// spec name: petId + final + int + petId; + + + /// + /// spec name: api_key + final UndefinedWrapper< + String +> apiKey; + + + + const PetApiDeletePetRequest({ + + required this.petId , + + + this.apiKey= const UndefinedWrapper + .undefined() +, + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'petId',).expand(resolvedPath, petId); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + if (apiKey.isDefined) + r'api_key': OpenApiParameterSerializationHeader(parameterName: r'api_key',explode: false).serialize(apiKey.valueRequired), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + +extension type const StatusEnum._(String value) implements String { + const StatusEnum.available() : this._(r'available'); + const StatusEnum.pending() : this._(r'pending'); + const StatusEnum.sold() : this._(r'sold'); + + /// Creates a [StatusEnum] enum from a value and safely checking if it exists. + factory StatusEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'available', oasValue: r'available', value: StatusEnum.available()), + + EnumMemberReflection(dartName: r'pending', oasValue: r'pending', value: StatusEnum.pending()), + + EnumMemberReflection(dartName: r'sold', oasValue: r'sold', value: StatusEnum.sold()), + + ], + ); + + factory StatusEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [StatusEnum] enum from a value without checking if it exists. + const StatusEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + StatusEnum.available(), + StatusEnum.pending(), + StatusEnum.sold(), + + ]; +} + + + + + + class PetApiFindPetsByStatusRequest { + static const pathTemplate = r'/pet/findByStatus'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// Status values that need to be considered for filter + /// spec name: status + final + List< + + StatusEnum +> + status; + + + + const PetApiFindPetsByStatusRequest({ + + required this.status , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: false, parameterName: r'status', allowEmptyValue: false,).expandUri(methodUri, status); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + + +@Deprecated('This operation has been deprecated') + class PetApiFindPetsByTagsRequest { + static const pathTemplate = r'/pet/findByTags'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// Tags to filter by + /// spec name: tags + final + List< + + String +> + tags; + + + + const PetApiFindPetsByTagsRequest({ + + required this.tags , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: false, parameterName: r'tags', allowEmptyValue: false,).expandUri(methodUri, tags); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + class PetApiGetPetByIdRequest { + static const pathTemplate = r'/pet/{petId}'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// ID of pet to return + /// spec name: petId + final + int + petId; + + + + const PetApiGetPetByIdRequest({ + + required this.petId , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'petId',).expand(resolvedPath, petId); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + +abstract class PetApiUpdatePetRequest { + static const pathTemplate = r'/pet'; + static String method = r'PUT'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory PetApiUpdatePetRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = PetApiUpdatePetRequestUnsafe; + + + const factory PetApiUpdatePetRequest.applicationJson({ + required + Pet + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = PetApiUpdatePetRequestApplicationJson; + + const factory PetApiUpdatePetRequest.applicationXml({ + required + Pet + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = PetApiUpdatePetRequestApplicationXml; + + + const PetApiUpdatePetRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [PetApiUpdatePetRequest], where you can send arbitrary bytes in the body. +class PetApiUpdatePetRequestUnsafe extends PetApiUpdatePetRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const PetApiUpdatePetRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class PetApiUpdatePetRequestApplicationJson extends PetApiUpdatePetRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Pet + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + + const PetApiUpdatePetRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + +class PetApiUpdatePetRequestApplicationXml extends PetApiUpdatePetRequest { + static const specMediaType = r'application/xml'; + + @override + String get contentType => specMediaType; + + final + Pet + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + + const PetApiUpdatePetRequestApplicationXml({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + + + + + + + + +abstract class PetApiUpdatePetWithFormRequest { + static const pathTemplate = r'/pet/{petId}'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// ID of pet that needs to be updated + /// spec name: petId + final + int + petId; + + + + + const factory PetApiUpdatePetWithFormRequest.unsafe({ + + required + int + petId, + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = PetApiUpdatePetWithFormRequestUnsafe; + + + + const PetApiUpdatePetWithFormRequest({ + + required this.petId , + + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'petId',).expand(resolvedPath, petId); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [PetApiUpdatePetWithFormRequest], where you can send arbitrary bytes in the body. +class PetApiUpdatePetWithFormRequestUnsafe extends PetApiUpdatePetWithFormRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const PetApiUpdatePetWithFormRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + required super.petId, + + + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + + + + + + + + + + + + + + + +abstract class PetApiUploadFileRequest { + static const pathTemplate = r'/pet/{petId}/uploadImage'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// ID of pet to update + /// spec name: petId + final + int + petId; + + + + + const factory PetApiUploadFileRequest.unsafe({ + + required + int + petId, + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = PetApiUploadFileRequestUnsafe; + + + + const PetApiUploadFileRequest({ + + required this.petId , + + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'petId',).expand(resolvedPath, petId); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [PetApiUploadFileRequest], where you can send arbitrary bytes in the body. +class PetApiUploadFileRequestUnsafe extends PetApiUploadFileRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const PetApiUploadFileRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + required super.petId, + + + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + + + + + + + + + + + + + + + +abstract class PetApiUploadFileWithRequiredFileRequest { + static const pathTemplate = r'/fake/{petId}/uploadImageWithRequiredFile'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// ID of pet to update + /// spec name: petId + final + int + petId; + + + + + const factory PetApiUploadFileWithRequiredFileRequest.unsafe({ + + required + int + petId, + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = PetApiUploadFileWithRequiredFileRequestUnsafe; + + + + const PetApiUploadFileWithRequiredFileRequest({ + + required this.petId , + + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'petId',).expand(resolvedPath, petId); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [PetApiUploadFileWithRequiredFileRequest], where you can send arbitrary bytes in the body. +class PetApiUploadFileWithRequiredFileRequestUnsafe extends PetApiUploadFileWithRequiredFileRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const PetApiUploadFileWithRequiredFileRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + required super.petId, + + + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/pet_api.responses.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/pet_api.responses.dart new file mode 100644 index 000000000000..258e1d07e9b6 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/pet_api.responses.dart @@ -0,0 +1,1729 @@ +// ignore_for_file: unnecessary_type_check, unnecessary_null_comparison, unnecessary_cast + +part of 'pet_api.dart'; + + +class PetApiAddPetResponse { + PetApiAddPetResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(PetApiAddPetResponse405 response) on405, + required T Function(PetApiAddPetResponse response) other, + }) { + return switch (this) { + PetApiAddPetResponse405 response => on405(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'405'), + () => PetApiAddPetResponse405.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return PetApiAddPetResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class PetApiAddPetResponse405 extends PetApiAddPetResponse { + PetApiAddPetResponse405({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiAddPetResponse405( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class PetApiDeletePetResponse { + PetApiDeletePetResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(PetApiDeletePetResponse400 response) on400, + required T Function(PetApiDeletePetResponse response) other, + }) { + return switch (this) { + PetApiDeletePetResponse400 response => on400(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => PetApiDeletePetResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return PetApiDeletePetResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class PetApiDeletePetResponse400 extends PetApiDeletePetResponse { + PetApiDeletePetResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiDeletePetResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class PetApiFindPetsByStatusResponse { + PetApiFindPetsByStatusResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(PetApiFindPetsByStatusResponse200 response) on200, + required T Function(PetApiFindPetsByStatusResponse400 response) on400, + required T Function(PetApiFindPetsByStatusResponse response) other, + }) { + return switch (this) { + PetApiFindPetsByStatusResponse200 response => on200(response), + PetApiFindPetsByStatusResponse400 response => on400(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => PetApiFindPetsByStatusResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => PetApiFindPetsByStatusResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return PetApiFindPetsByStatusResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class PetApiFindPetsByStatusResponse200 extends PetApiFindPetsByStatusResponse { + PetApiFindPetsByStatusResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(PetApiFindPetsByStatusResponse200ApplicationXml response) onApplicationXml, + + required T Function(PetApiFindPetsByStatusResponse200ApplicationJson response) onApplicationJson, + + required T Function(PetApiFindPetsByStatusResponse200 response) other, + }) { + return switch (this) { + + PetApiFindPetsByStatusResponse200ApplicationXml response => onApplicationXml(response), + + PetApiFindPetsByStatusResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/xml')), + () => PetApiFindPetsByStatusResponse200ApplicationXml.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => PetApiFindPetsByStatusResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return PetApiFindPetsByStatusResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + + + +/// Represent the response when content-type is application/xml. +class PetApiFindPetsByStatusResponse200ApplicationXml extends PetApiFindPetsByStatusResponse200 { + final UndefinedWrapper< + List< + + Pet +> +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +) +, +) +; + + /// The raw result of calling XmlDocumentFragment.parse + final XmlDocumentFragment? rawXml; + + PetApiFindPetsByStatusResponse200ApplicationXml({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawXml, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'xml'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = XmlDocumentFragment.parse(serialized); + // check if v can be deserialized to xml + return PetApiFindPetsByStatusResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawXml: v, + + ); + default: + } + return PetApiFindPetsByStatusResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class PetApiFindPetsByStatusResponse200ApplicationJson extends PetApiFindPetsByStatusResponse200 { + final UndefinedWrapper< + List< + + Pet +> +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +) +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + PetApiFindPetsByStatusResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return PetApiFindPetsByStatusResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return PetApiFindPetsByStatusResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return PetApiFindPetsByStatusResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + +class PetApiFindPetsByStatusResponse400 extends PetApiFindPetsByStatusResponse { + PetApiFindPetsByStatusResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiFindPetsByStatusResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +@Deprecated('This operation has been deprecated') +class PetApiFindPetsByTagsResponse { + PetApiFindPetsByTagsResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(PetApiFindPetsByTagsResponse200 response) on200, + required T Function(PetApiFindPetsByTagsResponse400 response) on400, + required T Function(PetApiFindPetsByTagsResponse response) other, + }) { + return switch (this) { + PetApiFindPetsByTagsResponse200 response => on200(response), + PetApiFindPetsByTagsResponse400 response => on400(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => PetApiFindPetsByTagsResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => PetApiFindPetsByTagsResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return PetApiFindPetsByTagsResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +@Deprecated('This operation has been deprecated') +class PetApiFindPetsByTagsResponse200 extends PetApiFindPetsByTagsResponse { + PetApiFindPetsByTagsResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(PetApiFindPetsByTagsResponse200ApplicationXml response) onApplicationXml, + + required T Function(PetApiFindPetsByTagsResponse200ApplicationJson response) onApplicationJson, + + required T Function(PetApiFindPetsByTagsResponse200 response) other, + }) { + return switch (this) { + + PetApiFindPetsByTagsResponse200ApplicationXml response => onApplicationXml(response), + + PetApiFindPetsByTagsResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/xml')), + () => PetApiFindPetsByTagsResponse200ApplicationXml.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => PetApiFindPetsByTagsResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return PetApiFindPetsByTagsResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + + + +/// Represent the response when content-type is application/xml. +@Deprecated('This operation has been deprecated') +class PetApiFindPetsByTagsResponse200ApplicationXml extends PetApiFindPetsByTagsResponse200 { + final UndefinedWrapper< + List< + + Pet +> +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +) +, +) +; + + /// The raw result of calling XmlDocumentFragment.parse + final XmlDocumentFragment? rawXml; + + PetApiFindPetsByTagsResponse200ApplicationXml({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawXml, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'xml'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = XmlDocumentFragment.parse(serialized); + // check if v can be deserialized to xml + return PetApiFindPetsByTagsResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawXml: v, + + ); + default: + } + return PetApiFindPetsByTagsResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +@Deprecated('This operation has been deprecated') +class PetApiFindPetsByTagsResponse200ApplicationJson extends PetApiFindPetsByTagsResponse200 { + final UndefinedWrapper< + List< + + Pet +> +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +) +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + PetApiFindPetsByTagsResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return PetApiFindPetsByTagsResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return PetApiFindPetsByTagsResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return PetApiFindPetsByTagsResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + +@Deprecated('This operation has been deprecated') +class PetApiFindPetsByTagsResponse400 extends PetApiFindPetsByTagsResponse { + PetApiFindPetsByTagsResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiFindPetsByTagsResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class PetApiGetPetByIdResponse { + PetApiGetPetByIdResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(PetApiGetPetByIdResponse200 response) on200, + required T Function(PetApiGetPetByIdResponse400 response) on400, + required T Function(PetApiGetPetByIdResponse404 response) on404, + required T Function(PetApiGetPetByIdResponse response) other, + }) { + return switch (this) { + PetApiGetPetByIdResponse200 response => on200(response), + PetApiGetPetByIdResponse400 response => on400(response), + PetApiGetPetByIdResponse404 response => on404(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => PetApiGetPetByIdResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => PetApiGetPetByIdResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'404'), + () => PetApiGetPetByIdResponse404.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return PetApiGetPetByIdResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class PetApiGetPetByIdResponse200 extends PetApiGetPetByIdResponse { + PetApiGetPetByIdResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(PetApiGetPetByIdResponse200ApplicationXml response) onApplicationXml, + + required T Function(PetApiGetPetByIdResponse200ApplicationJson response) onApplicationJson, + + required T Function(PetApiGetPetByIdResponse200 response) other, + }) { + return switch (this) { + + PetApiGetPetByIdResponse200ApplicationXml response => onApplicationXml(response), + + PetApiGetPetByIdResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/xml')), + () => PetApiGetPetByIdResponse200ApplicationXml.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => PetApiGetPetByIdResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return PetApiGetPetByIdResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/xml. +class PetApiGetPetByIdResponse200ApplicationXml extends PetApiGetPetByIdResponse200 { + final UndefinedWrapper< + Pet +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + /// The raw result of calling XmlDocumentFragment.parse + final XmlDocumentFragment? rawXml; + + PetApiGetPetByIdResponse200ApplicationXml({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawXml, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'xml'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = XmlDocumentFragment.parse(serialized); + // check if v can be deserialized to xml + return PetApiGetPetByIdResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawXml: v, + + ); + default: + } + return PetApiGetPetByIdResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is application/json. +class PetApiGetPetByIdResponse200ApplicationJson extends PetApiGetPetByIdResponse200 { + final UndefinedWrapper< + Pet +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + PetApiGetPetByIdResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return PetApiGetPetByIdResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return PetApiGetPetByIdResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return PetApiGetPetByIdResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + +class PetApiGetPetByIdResponse400 extends PetApiGetPetByIdResponse { + PetApiGetPetByIdResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiGetPetByIdResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class PetApiGetPetByIdResponse404 extends PetApiGetPetByIdResponse { + PetApiGetPetByIdResponse404({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiGetPetByIdResponse404( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class PetApiUpdatePetResponse { + PetApiUpdatePetResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(PetApiUpdatePetResponse400 response) on400, + required T Function(PetApiUpdatePetResponse404 response) on404, + required T Function(PetApiUpdatePetResponse405 response) on405, + required T Function(PetApiUpdatePetResponse response) other, + }) { + return switch (this) { + PetApiUpdatePetResponse400 response => on400(response), + PetApiUpdatePetResponse404 response => on404(response), + PetApiUpdatePetResponse405 response => on405(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => PetApiUpdatePetResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'404'), + () => PetApiUpdatePetResponse404.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'405'), + () => PetApiUpdatePetResponse405.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return PetApiUpdatePetResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class PetApiUpdatePetResponse400 extends PetApiUpdatePetResponse { + PetApiUpdatePetResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiUpdatePetResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class PetApiUpdatePetResponse404 extends PetApiUpdatePetResponse { + PetApiUpdatePetResponse404({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiUpdatePetResponse404( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class PetApiUpdatePetResponse405 extends PetApiUpdatePetResponse { + PetApiUpdatePetResponse405({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiUpdatePetResponse405( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class PetApiUpdatePetWithFormResponse { + PetApiUpdatePetWithFormResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(PetApiUpdatePetWithFormResponse405 response) on405, + required T Function(PetApiUpdatePetWithFormResponse response) other, + }) { + return switch (this) { + PetApiUpdatePetWithFormResponse405 response => on405(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'405'), + () => PetApiUpdatePetWithFormResponse405.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return PetApiUpdatePetWithFormResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class PetApiUpdatePetWithFormResponse405 extends PetApiUpdatePetWithFormResponse { + PetApiUpdatePetWithFormResponse405({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return PetApiUpdatePetWithFormResponse405( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class PetApiUploadFileResponse { + PetApiUploadFileResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(PetApiUploadFileResponse200 response) on200, + required T Function(PetApiUploadFileResponse response) other, + }) { + return switch (this) { + PetApiUploadFileResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => PetApiUploadFileResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return PetApiUploadFileResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class PetApiUploadFileResponse200 extends PetApiUploadFileResponse { + PetApiUploadFileResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(PetApiUploadFileResponse200ApplicationJson response) onApplicationJson, + + required T Function(PetApiUploadFileResponse200 response) other, + }) { + return switch (this) { + + PetApiUploadFileResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => PetApiUploadFileResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return PetApiUploadFileResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class PetApiUploadFileResponse200ApplicationJson extends PetApiUploadFileResponse200 { + final UndefinedWrapper< + ApiResponse +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ApiResponse.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + PetApiUploadFileResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return PetApiUploadFileResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return PetApiUploadFileResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return PetApiUploadFileResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class PetApiUploadFileWithRequiredFileResponse { + PetApiUploadFileWithRequiredFileResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(PetApiUploadFileWithRequiredFileResponse200 response) on200, + required T Function(PetApiUploadFileWithRequiredFileResponse response) other, + }) { + return switch (this) { + PetApiUploadFileWithRequiredFileResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => PetApiUploadFileWithRequiredFileResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return PetApiUploadFileWithRequiredFileResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class PetApiUploadFileWithRequiredFileResponse200 extends PetApiUploadFileWithRequiredFileResponse { + PetApiUploadFileWithRequiredFileResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(PetApiUploadFileWithRequiredFileResponse200ApplicationJson response) onApplicationJson, + + required T Function(PetApiUploadFileWithRequiredFileResponse200 response) other, + }) { + return switch (this) { + + PetApiUploadFileWithRequiredFileResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => PetApiUploadFileWithRequiredFileResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return PetApiUploadFileWithRequiredFileResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class PetApiUploadFileWithRequiredFileResponse200ApplicationJson extends PetApiUploadFileWithRequiredFileResponse200 { + final UndefinedWrapper< + ApiResponse +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ApiResponse.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + PetApiUploadFileWithRequiredFileResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return PetApiUploadFileWithRequiredFileResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return PetApiUploadFileWithRequiredFileResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return PetApiUploadFileWithRequiredFileResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/store_api.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/store_api.dart new file mode 100644 index 000000000000..56fa44cce2f5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/store_api.dart @@ -0,0 +1,81 @@ +import 'package:petstore_api/_internal.dart'; + +part 'store_api.requests.dart'; +part 'store_api.responses.dart'; + +class StoreApi { + final NetworkingClientBase networkingClient; + final Uri baseUrl; + final Map userContext; + + const StoreApi({ + required this.networkingClient, + required this.baseUrl, + this.userContext = const {}, + }); + + Future deleteOrder( + StoreApiDeleteOrderRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return StoreApiDeleteOrderResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future getInventory( + StoreApiGetInventoryRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return StoreApiGetInventoryResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future getOrderById( + StoreApiGetOrderByIdRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return StoreApiGetOrderByIdResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future placeOrder( + StoreApiPlaceOrderRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return StoreApiPlaceOrderResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/store_api.requests.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/store_api.requests.dart new file mode 100644 index 000000000000..0b5e6b6328c5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/store_api.requests.dart @@ -0,0 +1,544 @@ +// ignore_for_file: unnecessary_type_check + +part of 'store_api.dart'; + + + + + + + + + class StoreApiDeleteOrderRequest { + static const pathTemplate = r'/store/order/{order_id}'; + static String method = r'DELETE'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// ID of the order that needs to be deleted + /// spec name: order_id + final + String + orderId; + + + + const StoreApiDeleteOrderRequest({ + + required this.orderId , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'order_id',).expand(resolvedPath, orderId); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + class StoreApiGetInventoryRequest { + static const pathTemplate = r'/store/inventory'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const StoreApiGetInventoryRequest({ + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + class StoreApiGetOrderByIdRequest { + static const pathTemplate = r'/store/order/{order_id}'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// ID of pet that needs to be fetched + /// spec name: order_id + final + int + orderId; + + + + const StoreApiGetOrderByIdRequest({ + + required this.orderId , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'order_id',).expand(resolvedPath, orderId); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + +abstract class StoreApiPlaceOrderRequest { + static const pathTemplate = r'/store/order'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory StoreApiPlaceOrderRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = StoreApiPlaceOrderRequestUnsafe; + + + const factory StoreApiPlaceOrderRequest.applicationJson({ + required + Order + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = StoreApiPlaceOrderRequestApplicationJson; + + + const StoreApiPlaceOrderRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [StoreApiPlaceOrderRequest], where you can send arbitrary bytes in the body. +class StoreApiPlaceOrderRequestUnsafe extends StoreApiPlaceOrderRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const StoreApiPlaceOrderRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class StoreApiPlaceOrderRequestApplicationJson extends StoreApiPlaceOrderRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + Order + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Order', +), + + + + + + Order.$reflection + +, +) +; + + + const StoreApiPlaceOrderRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/store_api.responses.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/store_api.responses.dart new file mode 100644 index 000000000000..6daac45095d5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/store_api.responses.dart @@ -0,0 +1,945 @@ +// ignore_for_file: unnecessary_type_check, unnecessary_null_comparison, unnecessary_cast + +part of 'store_api.dart'; + + +class StoreApiDeleteOrderResponse { + StoreApiDeleteOrderResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(StoreApiDeleteOrderResponse400 response) on400, + required T Function(StoreApiDeleteOrderResponse404 response) on404, + required T Function(StoreApiDeleteOrderResponse response) other, + }) { + return switch (this) { + StoreApiDeleteOrderResponse400 response => on400(response), + StoreApiDeleteOrderResponse404 response => on404(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => StoreApiDeleteOrderResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'404'), + () => StoreApiDeleteOrderResponse404.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return StoreApiDeleteOrderResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class StoreApiDeleteOrderResponse400 extends StoreApiDeleteOrderResponse { + StoreApiDeleteOrderResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return StoreApiDeleteOrderResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class StoreApiDeleteOrderResponse404 extends StoreApiDeleteOrderResponse { + StoreApiDeleteOrderResponse404({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return StoreApiDeleteOrderResponse404( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class StoreApiGetInventoryResponse { + StoreApiGetInventoryResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(StoreApiGetInventoryResponse200 response) on200, + required T Function(StoreApiGetInventoryResponse response) other, + }) { + return switch (this) { + StoreApiGetInventoryResponse200 response => on200(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => StoreApiGetInventoryResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return StoreApiGetInventoryResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class StoreApiGetInventoryResponse200 extends StoreApiGetInventoryResponse { + StoreApiGetInventoryResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(StoreApiGetInventoryResponse200ApplicationJson response) onApplicationJson, + + required T Function(StoreApiGetInventoryResponse200 response) other, + }) { + return switch (this) { + + StoreApiGetInventoryResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => StoreApiGetInventoryResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return StoreApiGetInventoryResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + + + +/// Represent the response when content-type is application/json. +class StoreApiGetInventoryResponse200ApplicationJson extends StoreApiGetInventoryResponse200 { + final UndefinedWrapper< + Map +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + StoreApiGetInventoryResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return StoreApiGetInventoryResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return StoreApiGetInventoryResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return StoreApiGetInventoryResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + +class StoreApiGetOrderByIdResponse { + StoreApiGetOrderByIdResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(StoreApiGetOrderByIdResponse200 response) on200, + required T Function(StoreApiGetOrderByIdResponse400 response) on400, + required T Function(StoreApiGetOrderByIdResponse404 response) on404, + required T Function(StoreApiGetOrderByIdResponse response) other, + }) { + return switch (this) { + StoreApiGetOrderByIdResponse200 response => on200(response), + StoreApiGetOrderByIdResponse400 response => on400(response), + StoreApiGetOrderByIdResponse404 response => on404(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => StoreApiGetOrderByIdResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => StoreApiGetOrderByIdResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'404'), + () => StoreApiGetOrderByIdResponse404.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return StoreApiGetOrderByIdResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class StoreApiGetOrderByIdResponse200 extends StoreApiGetOrderByIdResponse { + StoreApiGetOrderByIdResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(StoreApiGetOrderByIdResponse200ApplicationXml response) onApplicationXml, + + required T Function(StoreApiGetOrderByIdResponse200ApplicationJson response) onApplicationJson, + + required T Function(StoreApiGetOrderByIdResponse200 response) other, + }) { + return switch (this) { + + StoreApiGetOrderByIdResponse200ApplicationXml response => onApplicationXml(response), + + StoreApiGetOrderByIdResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/xml')), + () => StoreApiGetOrderByIdResponse200ApplicationXml.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => StoreApiGetOrderByIdResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return StoreApiGetOrderByIdResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/xml. +class StoreApiGetOrderByIdResponse200ApplicationXml extends StoreApiGetOrderByIdResponse200 { + final UndefinedWrapper< + Order +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Order', +), + + + + + + Order.$reflection + +, +) +; + + /// The raw result of calling XmlDocumentFragment.parse + final XmlDocumentFragment? rawXml; + + StoreApiGetOrderByIdResponse200ApplicationXml({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawXml, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'xml'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = XmlDocumentFragment.parse(serialized); + // check if v can be deserialized to xml + return StoreApiGetOrderByIdResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawXml: v, + + ); + default: + } + return StoreApiGetOrderByIdResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is application/json. +class StoreApiGetOrderByIdResponse200ApplicationJson extends StoreApiGetOrderByIdResponse200 { + final UndefinedWrapper< + Order +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Order', +), + + + + + + Order.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + StoreApiGetOrderByIdResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return StoreApiGetOrderByIdResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return StoreApiGetOrderByIdResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return StoreApiGetOrderByIdResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + +class StoreApiGetOrderByIdResponse400 extends StoreApiGetOrderByIdResponse { + StoreApiGetOrderByIdResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return StoreApiGetOrderByIdResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class StoreApiGetOrderByIdResponse404 extends StoreApiGetOrderByIdResponse { + StoreApiGetOrderByIdResponse404({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return StoreApiGetOrderByIdResponse404( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class StoreApiPlaceOrderResponse { + StoreApiPlaceOrderResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(StoreApiPlaceOrderResponse200 response) on200, + required T Function(StoreApiPlaceOrderResponse400 response) on400, + required T Function(StoreApiPlaceOrderResponse response) other, + }) { + return switch (this) { + StoreApiPlaceOrderResponse200 response => on200(response), + StoreApiPlaceOrderResponse400 response => on400(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => StoreApiPlaceOrderResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => StoreApiPlaceOrderResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return StoreApiPlaceOrderResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class StoreApiPlaceOrderResponse200 extends StoreApiPlaceOrderResponse { + StoreApiPlaceOrderResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(StoreApiPlaceOrderResponse200ApplicationXml response) onApplicationXml, + + required T Function(StoreApiPlaceOrderResponse200ApplicationJson response) onApplicationJson, + + required T Function(StoreApiPlaceOrderResponse200 response) other, + }) { + return switch (this) { + + StoreApiPlaceOrderResponse200ApplicationXml response => onApplicationXml(response), + + StoreApiPlaceOrderResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/xml')), + () => StoreApiPlaceOrderResponse200ApplicationXml.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => StoreApiPlaceOrderResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return StoreApiPlaceOrderResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/xml. +class StoreApiPlaceOrderResponse200ApplicationXml extends StoreApiPlaceOrderResponse200 { + final UndefinedWrapper< + Order +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Order', +), + + + + + + Order.$reflection + +, +) +; + + /// The raw result of calling XmlDocumentFragment.parse + final XmlDocumentFragment? rawXml; + + StoreApiPlaceOrderResponse200ApplicationXml({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawXml, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'xml'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = XmlDocumentFragment.parse(serialized); + // check if v can be deserialized to xml + return StoreApiPlaceOrderResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawXml: v, + + ); + default: + } + return StoreApiPlaceOrderResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is application/json. +class StoreApiPlaceOrderResponse200ApplicationJson extends StoreApiPlaceOrderResponse200 { + final UndefinedWrapper< + Order +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Order', +), + + + + + + Order.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + StoreApiPlaceOrderResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return StoreApiPlaceOrderResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return StoreApiPlaceOrderResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return StoreApiPlaceOrderResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + +class StoreApiPlaceOrderResponse400 extends StoreApiPlaceOrderResponse { + StoreApiPlaceOrderResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return StoreApiPlaceOrderResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/user_api.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/user_api.dart new file mode 100644 index 000000000000..1732fdb45ece --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/user_api.dart @@ -0,0 +1,145 @@ +import 'package:petstore_api/_internal.dart'; + +part 'user_api.requests.dart'; +part 'user_api.responses.dart'; + +class UserApi { + final NetworkingClientBase networkingClient; + final Uri baseUrl; + final Map userContext; + + const UserApi({ + required this.networkingClient, + required this.baseUrl, + this.userContext = const {}, + }); + + Future createUser( + UserApiCreateUserRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return UserApiCreateUserResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future createUsersWithArrayInput( + UserApiCreateUsersWithArrayInputRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return UserApiCreateUsersWithArrayInputResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future createUsersWithListInput( + UserApiCreateUsersWithListInputRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return UserApiCreateUsersWithListInputResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future deleteUser( + UserApiDeleteUserRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return UserApiDeleteUserResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future getUserByName( + UserApiGetUserByNameRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return UserApiGetUserByNameResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future loginUser( + UserApiLoginUserRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return UserApiLoginUserResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future logoutUser( + UserApiLogoutUserRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return UserApiLogoutUserResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } + Future updateUser( + UserApiUpdateUserRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return UserApiUpdateUserResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/user_api.requests.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/user_api.requests.dart new file mode 100644 index 000000000000..582191c60f03 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/user_api.requests.dart @@ -0,0 +1,1388 @@ +// ignore_for_file: unnecessary_type_check + +part of 'user_api.dart'; + + + + + + + + +abstract class UserApiCreateUserRequest { + static const pathTemplate = r'/user'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory UserApiCreateUserRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = UserApiCreateUserRequestUnsafe; + + + const factory UserApiCreateUserRequest.applicationJson({ + required + User + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = UserApiCreateUserRequestApplicationJson; + + + const UserApiCreateUserRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [UserApiCreateUserRequest], where you can send arbitrary bytes in the body. +class UserApiCreateUserRequestUnsafe extends UserApiCreateUserRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const UserApiCreateUserRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class UserApiCreateUserRequestApplicationJson extends UserApiCreateUserRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + User + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + User.$reflection + +, +) +; + + + const UserApiCreateUserRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + + +abstract class UserApiCreateUsersWithArrayInputRequest { + static const pathTemplate = r'/user/createWithArray'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory UserApiCreateUsersWithArrayInputRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = UserApiCreateUsersWithArrayInputRequestUnsafe; + + + const factory UserApiCreateUsersWithArrayInputRequest.applicationJson({ + required + List< + + User +> + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = UserApiCreateUsersWithArrayInputRequestApplicationJson; + + + const UserApiCreateUsersWithArrayInputRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [UserApiCreateUsersWithArrayInputRequest], where you can send arbitrary bytes in the body. +class UserApiCreateUsersWithArrayInputRequestUnsafe extends UserApiCreateUsersWithArrayInputRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const UserApiCreateUsersWithArrayInputRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class UserApiCreateUsersWithArrayInputRequestApplicationJson extends UserApiCreateUsersWithArrayInputRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + List< + + User +> + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + User.$reflection + +, +) +) +, +) +; + + + const UserApiCreateUsersWithArrayInputRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + + +abstract class UserApiCreateUsersWithListInputRequest { + static const pathTemplate = r'/user/createWithList'; + static String method = r'POST'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const factory UserApiCreateUsersWithListInputRequest.unsafe({ + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = UserApiCreateUsersWithListInputRequestUnsafe; + + + const factory UserApiCreateUsersWithListInputRequest.applicationJson({ + required + List< + + User +> + data, + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = UserApiCreateUsersWithListInputRequestApplicationJson; + + + const UserApiCreateUsersWithListInputRequest({ + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [UserApiCreateUsersWithListInputRequest], where you can send arbitrary bytes in the body. +class UserApiCreateUsersWithListInputRequestUnsafe extends UserApiCreateUsersWithListInputRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const UserApiCreateUsersWithListInputRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class UserApiCreateUsersWithListInputRequestApplicationJson extends UserApiCreateUsersWithListInputRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + List< + + User +> + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + User.$reflection + +, +) +) +, +) +; + + + const UserApiCreateUsersWithListInputRequestApplicationJson({ + required this.data, + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + + + + + + + + + class UserApiDeleteUserRequest { + static const pathTemplate = r'/user/{username}'; + static String method = r'DELETE'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// The name that needs to be deleted + /// spec name: username + final + String + username; + + + + const UserApiDeleteUserRequest({ + + required this.username , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'username',).expand(resolvedPath, username); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + class UserApiGetUserByNameRequest { + static const pathTemplate = r'/user/{username}'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// The name that needs to be fetched. Use user1 for testing. + /// spec name: username + final + String + username; + + + + const UserApiGetUserByNameRequest({ + + required this.username , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'username',).expand(resolvedPath, username); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + + + + + class UserApiLoginUserRequest { + static const pathTemplate = r'/user/login'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// The user name for login + /// spec name: username + final + String + username; + + + /// The password for login in clear text + /// spec name: password + final + String + password; + + + + const UserApiLoginUserRequest({ + + required this.username , + + + required this.password , + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'username', allowEmptyValue: false,).expandUri(methodUri, username); + methodUri = OpenApiParameterSerializationQuery.fromStyle(r'form', explode: true, parameterName: r'password', allowEmptyValue: false,).expandUri(methodUri, password); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + class UserApiLogoutUserRequest { + static const pathTemplate = r'/user/logout'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const UserApiLogoutUserRequest({ + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + + + + + + + + + + + + +abstract class UserApiUpdateUserRequest { + static const pathTemplate = r'/user/{username}'; + static String method = r'PUT'; + + String get contentType; + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + /// name that need to be deleted + /// spec name: username + final + String + username; + + + + const factory UserApiUpdateUserRequest.unsafe({ + + required + String + username, + + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + WireSerializationOptions wireSerializationOptions, + Stream? bodyBytesStream, + }) = UserApiUpdateUserRequestUnsafe; + + + const factory UserApiUpdateUserRequest.applicationJson({ + required + User + data, + + required + String + username, + + + WireSerializationOptions wireSerializationOptions, + Map extraHeaders, + Map extraQueryParameters, + Map extraCookies, + }) = UserApiUpdateUserRequestApplicationJson; + + + const UserApiUpdateUserRequest({ + + required this.username , + + + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + resolvedPath = OpenApiParameterSerializationPath.fromStyle(r'simple', explode: false, parameterName: r'username',).expand(resolvedPath, username); + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + 'Content-Type': this.contentType, + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }); + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: getResolvedBody(userContext: userContext, headers: headers), + context: userContext, + ); + } +} + +/// A version of [UserApiUpdateUserRequest], where you can send arbitrary bytes in the body. +class UserApiUpdateUserRequestUnsafe extends UserApiUpdateUserRequest { + final Stream? bodyBytesStream; + + @override + final String contentType; + + const UserApiUpdateUserRequestUnsafe({ + this.bodyBytesStream, + this.contentType = 'application/octet-stream', + + required super.username, + + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) async* { + final body = this.bodyBytesStream; + if (body == null) { + return; + } + yield* body; + } +} + + + + + + +class UserApiUpdateUserRequestApplicationJson extends UserApiUpdateUserRequest { + static const specMediaType = r'application/json'; + + @override + String get contentType => specMediaType; + + final + User + data; + static const dataReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + User.$reflection + +, +) +; + + + const UserApiUpdateUserRequestApplicationJson({ + required this.data, + + required super.username, + + + super.extraHeaders, + super.extraQueryParameters, + super.extraCookies, + super.wireSerializationOptions, + }); + + Map get encodingRules => { + + }; + + @override + Stream> getResolvedBody({ + required Map headers, + Map userContext = const {}, + }) { + final contentType = headers['Content-Type']!; + final resolvedMediaType = MediaType.parse(contentType); + final wireSerializationOptions = this.wireSerializationOptions.withEncodingRules({...encodingRules, ...this.wireSerializationOptions.encodingRules}); + final context = wireSerializationOptions.createSerializationContext(resolvedMediaType); + final v = data; + var serialized = dataReflection.serialize(v, context); + return wireSerializationOptions.getBodyFromSerialized( + headers: headers, + serialized: serialized, + resolvedMediaType: resolvedMediaType, + ); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/user_api.responses.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/user_api.responses.dart new file mode 100644 index 000000000000..408a104b8aa7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/user_api.responses.dart @@ -0,0 +1,1308 @@ +// ignore_for_file: unnecessary_type_check, unnecessary_null_comparison, unnecessary_cast + +part of 'user_api.dart'; + + +class UserApiCreateUserResponse { + UserApiCreateUserResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(UserApiCreateUserResponseDefault response) onDefault, + required T Function(UserApiCreateUserResponse response) other, + }) { + return switch (this) { + UserApiCreateUserResponseDefault response => onDefault(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'default'), + () => UserApiCreateUserResponseDefault.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return UserApiCreateUserResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class UserApiCreateUserResponseDefault extends UserApiCreateUserResponse { + UserApiCreateUserResponseDefault({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiCreateUserResponseDefault( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class UserApiCreateUsersWithArrayInputResponse { + UserApiCreateUsersWithArrayInputResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(UserApiCreateUsersWithArrayInputResponseDefault response) onDefault, + required T Function(UserApiCreateUsersWithArrayInputResponse response) other, + }) { + return switch (this) { + UserApiCreateUsersWithArrayInputResponseDefault response => onDefault(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'default'), + () => UserApiCreateUsersWithArrayInputResponseDefault.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return UserApiCreateUsersWithArrayInputResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class UserApiCreateUsersWithArrayInputResponseDefault extends UserApiCreateUsersWithArrayInputResponse { + UserApiCreateUsersWithArrayInputResponseDefault({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiCreateUsersWithArrayInputResponseDefault( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class UserApiCreateUsersWithListInputResponse { + UserApiCreateUsersWithListInputResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(UserApiCreateUsersWithListInputResponseDefault response) onDefault, + required T Function(UserApiCreateUsersWithListInputResponse response) other, + }) { + return switch (this) { + UserApiCreateUsersWithListInputResponseDefault response => onDefault(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'default'), + () => UserApiCreateUsersWithListInputResponseDefault.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return UserApiCreateUsersWithListInputResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class UserApiCreateUsersWithListInputResponseDefault extends UserApiCreateUsersWithListInputResponse { + UserApiCreateUsersWithListInputResponseDefault({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiCreateUsersWithListInputResponseDefault( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class UserApiDeleteUserResponse { + UserApiDeleteUserResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(UserApiDeleteUserResponse400 response) on400, + required T Function(UserApiDeleteUserResponse404 response) on404, + required T Function(UserApiDeleteUserResponse response) other, + }) { + return switch (this) { + UserApiDeleteUserResponse400 response => on400(response), + UserApiDeleteUserResponse404 response => on404(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => UserApiDeleteUserResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'404'), + () => UserApiDeleteUserResponse404.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return UserApiDeleteUserResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class UserApiDeleteUserResponse400 extends UserApiDeleteUserResponse { + UserApiDeleteUserResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiDeleteUserResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class UserApiDeleteUserResponse404 extends UserApiDeleteUserResponse { + UserApiDeleteUserResponse404({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiDeleteUserResponse404( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class UserApiGetUserByNameResponse { + UserApiGetUserByNameResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(UserApiGetUserByNameResponse200 response) on200, + required T Function(UserApiGetUserByNameResponse400 response) on400, + required T Function(UserApiGetUserByNameResponse404 response) on404, + required T Function(UserApiGetUserByNameResponse response) other, + }) { + return switch (this) { + UserApiGetUserByNameResponse200 response => on200(response), + UserApiGetUserByNameResponse400 response => on400(response), + UserApiGetUserByNameResponse404 response => on404(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => UserApiGetUserByNameResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => UserApiGetUserByNameResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'404'), + () => UserApiGetUserByNameResponse404.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return UserApiGetUserByNameResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class UserApiGetUserByNameResponse200 extends UserApiGetUserByNameResponse { + UserApiGetUserByNameResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(UserApiGetUserByNameResponse200ApplicationXml response) onApplicationXml, + + required T Function(UserApiGetUserByNameResponse200ApplicationJson response) onApplicationJson, + + required T Function(UserApiGetUserByNameResponse200 response) other, + }) { + return switch (this) { + + UserApiGetUserByNameResponse200ApplicationXml response => onApplicationXml(response), + + UserApiGetUserByNameResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/xml')), + () => UserApiGetUserByNameResponse200ApplicationXml.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => UserApiGetUserByNameResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return UserApiGetUserByNameResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/xml. +class UserApiGetUserByNameResponse200ApplicationXml extends UserApiGetUserByNameResponse200 { + final UndefinedWrapper< + User +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + User.$reflection + +, +) +; + + /// The raw result of calling XmlDocumentFragment.parse + final XmlDocumentFragment? rawXml; + + UserApiGetUserByNameResponse200ApplicationXml({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawXml, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'xml'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = XmlDocumentFragment.parse(serialized); + // check if v can be deserialized to xml + return UserApiGetUserByNameResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawXml: v, + + ); + default: + } + return UserApiGetUserByNameResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + + + + +/// Represent the response when content-type is application/json. +class UserApiGetUserByNameResponse200ApplicationJson extends UserApiGetUserByNameResponse200 { + final UndefinedWrapper< + User +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + User.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + UserApiGetUserByNameResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return UserApiGetUserByNameResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return UserApiGetUserByNameResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return UserApiGetUserByNameResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + +class UserApiGetUserByNameResponse400 extends UserApiGetUserByNameResponse { + UserApiGetUserByNameResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiGetUserByNameResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class UserApiGetUserByNameResponse404 extends UserApiGetUserByNameResponse { + UserApiGetUserByNameResponse404({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiGetUserByNameResponse404( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class UserApiLoginUserResponse { + UserApiLoginUserResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(UserApiLoginUserResponse200 response) on200, + required T Function(UserApiLoginUserResponse400 response) on400, + required T Function(UserApiLoginUserResponse response) other, + }) { + return switch (this) { + UserApiLoginUserResponse200 response => on200(response), + UserApiLoginUserResponse400 response => on400(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => UserApiLoginUserResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => UserApiLoginUserResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return UserApiLoginUserResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + + + + +class UserApiLoginUserResponse200 extends UserApiLoginUserResponse { + UserApiLoginUserResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.xRateLimit= const UndefinedWrapper + .undefined() +, + this.xExpiresAfter= const UndefinedWrapper + .undefined() +, + }); + + final UndefinedWrapper< + int +> xRateLimit; + final UndefinedWrapper< + DateTime +> xExpiresAfter; + + T split200({ + + required T Function(UserApiLoginUserResponse200ApplicationXml response) onApplicationXml, + + required T Function(UserApiLoginUserResponse200ApplicationJson response) onApplicationJson, + + required T Function(UserApiLoginUserResponse200 response) other, + }) { + return switch (this) { + + UserApiLoginUserResponse200ApplicationXml response => onApplicationXml(response), + + UserApiLoginUserResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/xml')), + () => UserApiLoginUserResponse200ApplicationXml.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => UserApiLoginUserResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return UserApiLoginUserResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/xml. +class UserApiLoginUserResponse200ApplicationXml extends UserApiLoginUserResponse200 { + final UndefinedWrapper< + String +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +; + + /// The raw result of calling XmlDocumentFragment.parse + final XmlDocumentFragment? rawXml; + + UserApiLoginUserResponse200ApplicationXml({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + super.xRateLimit, + super.xExpiresAfter, + this.rawXml, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'xml'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = XmlDocumentFragment.parse(serialized); + // check if v can be deserialized to xml + return UserApiLoginUserResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawXml: v, + xRateLimit: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Rate-Limit')), +xExpiresAfter: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Expires-After')), + + ); + default: + } + return UserApiLoginUserResponse200ApplicationXml( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + xRateLimit: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Rate-Limit')), +xExpiresAfter: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Expires-After')), + + ); + } +} + + + + + + +/// Represent the response when content-type is application/json. +class UserApiLoginUserResponse200ApplicationJson extends UserApiLoginUserResponse200 { + final UndefinedWrapper< + String +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + UserApiLoginUserResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + super.xRateLimit, + super.xExpiresAfter, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return UserApiLoginUserResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + xRateLimit: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Rate-Limit')), +xExpiresAfter: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Expires-After')), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return UserApiLoginUserResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + xRateLimit: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Rate-Limit')), +xExpiresAfter: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Expires-After')), + + ); + } + default: + } + return UserApiLoginUserResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + xRateLimit: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Rate-Limit')), +xExpiresAfter: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +).deserializeFunction(response.headers.getOrUndefined(r'X-Expires-After')), + + ); + } +} + + + +class UserApiLoginUserResponse400 extends UserApiLoginUserResponse { + UserApiLoginUserResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiLoginUserResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class UserApiLogoutUserResponse { + UserApiLogoutUserResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(UserApiLogoutUserResponseDefault response) onDefault, + required T Function(UserApiLogoutUserResponse response) other, + }) { + return switch (this) { + UserApiLogoutUserResponseDefault response => onDefault(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'default'), + () => UserApiLogoutUserResponseDefault.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return UserApiLogoutUserResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class UserApiLogoutUserResponseDefault extends UserApiLogoutUserResponse { + UserApiLogoutUserResponseDefault({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiLogoutUserResponseDefault( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + +class UserApiUpdateUserResponse { + UserApiUpdateUserResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(UserApiUpdateUserResponse400 response) on400, + required T Function(UserApiUpdateUserResponse404 response) on404, + required T Function(UserApiUpdateUserResponse response) other, + }) { + return switch (this) { + UserApiUpdateUserResponse400 response => on400(response), + UserApiUpdateUserResponse404 response => on404(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => UserApiUpdateUserResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'404'), + () => UserApiUpdateUserResponse404.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return UserApiUpdateUserResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class UserApiUpdateUserResponse400 extends UserApiUpdateUserResponse { + UserApiUpdateUserResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiUpdateUserResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + +class UserApiUpdateUserResponse404 extends UserApiUpdateUserResponse { + UserApiUpdateUserResponse404({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return UserApiUpdateUserResponse404( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/values_api.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/values_api.dart new file mode 100644 index 000000000000..2e8688e76de8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/values_api.dart @@ -0,0 +1,33 @@ +import 'package:petstore_api/_internal.dart'; + +part 'values_api.requests.dart'; +part 'values_api.responses.dart'; + +class ValuesApi { + final NetworkingClientBase networkingClient; + final Uri baseUrl; + final Map userContext; + + const ValuesApi({ + required this.networkingClient, + required this.baseUrl, + this.userContext = const {}, + }); + + Future getSomeValues( + ValuesApiGetSomeValuesRequest request, { + Map userContext = const {}, + }) async { + final newContext = {...this.userContext, ...userContext}; + final httpRequest = await request.createHttpRequest( + userContext: newContext, + baseUrl: baseUrl, + ); + final response = await networkingClient.sendRequest(httpRequest); + return ValuesApiGetSomeValuesResponse.fromResponse( + response, + userContext: newContext, + wireSerializationOptions: request.wireSerializationOptions, + ); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/values_api.requests.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/values_api.requests.dart new file mode 100644 index 000000000000..8470c09afca5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/values_api.requests.dart @@ -0,0 +1,101 @@ +// ignore_for_file: unnecessary_type_check + +part of 'values_api.dart'; + + + + + class ValuesApiGetSomeValuesRequest { + static const pathTemplate = r'/values'; + static String method = r'GET'; + + final Map extraHeaders; + final Map extraCookies; + final Map */> extraQueryParameters; + final WireSerializationOptions wireSerializationOptions; + + + const ValuesApiGetSomeValuesRequest({ + this.wireSerializationOptions = const WireSerializationOptions(), + this.extraHeaders = const {}, + this.extraQueryParameters = const {}, + this.extraCookies = const {}, + }); + + Future getResolvedUri({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + var resolvedPath = pathTemplate; + var methodUri = Uri(path: resolvedPath); + + return baseUrl.replace( + pathSegments: [ + ...baseUrl.pathSegments, + ...methodUri.pathSegments, + ], + queryParameters: { + ...baseUrl.queryParameters, + ...methodUri.queryParameters, + ...extraQueryParameters, + }, + ); + } + + Future> getResolvedHeaders({ + Map userContext = const {}, + }) async { + + final cookieParts = { + ...extraCookies, + }; + + var headers = CaseInsensitiveMap.from({ + if (cookieParts.isNotEmpty) + 'Cookie': cookieParts.entries.map((e) => '${e.key}=${e.value}').join('; '), + ...extraHeaders, + }); + + var contentType = headers['content-type']; + if (contentType != null) { + var parsedContentType = MediaType.parse(contentType).fillDefaults(); + if (parsedContentType.type == 'multipart' && parsedContentType.parameters['boundary'] == null) { + parsedContentType = parsedContentType.change( + parameters: { + ...parsedContentType.parameters, + 'boundary': MultiPartBodySerializer.getRandomBoundaryString(Random()), + } + ); + } + headers['content-type'] = parsedContentType.toString(); + } + return headers; + } + + + + Future createHttpRequest({ + required Uri baseUrl, + Map userContext = const {}, + }) async { + final futures = [ + getResolvedUri( + userContext: userContext, + baseUrl: baseUrl, + ), + getResolvedHeaders(userContext: userContext), + ]; + final futureResults = await Future.wait(futures); + final headers = futureResults[1] as Map; + return HttpRequestBase.stream( + url: futureResults[0] as Uri, + headers: headers, + method: method, + bodyBytesStream: Stream.empty(), + context: userContext, + ); + } +} + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/apis/values_api.responses.dart b/samples/openapi3/client/petstore/dart/next/lib/src/apis/values_api.responses.dart new file mode 100644 index 000000000000..558923a42fb0 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/apis/values_api.responses.dart @@ -0,0 +1,225 @@ +// ignore_for_file: unnecessary_type_check, unnecessary_null_comparison, unnecessary_cast + +part of 'values_api.dart'; + + +class ValuesApiGetSomeValuesResponse { + ValuesApiGetSomeValuesResponse({ + required this.headers, + required this.statusCode, + required this.reasonPhrase, + required this.userContext, + this.bodyBytesStream, + }); + + final Map headers; + final int statusCode; + final String? reasonPhrase; + final Map userContext; + /// This variable is only assigned if other response classes fail to read the response. + /// Thus, handing the responsibility of reading the response to the user. + final Stream>? bodyBytesStream; + + T split({ + required T Function(ValuesApiGetSomeValuesResponse200 response) on200, + required T Function(ValuesApiGetSomeValuesResponse400 response) on400, + required T Function(ValuesApiGetSomeValuesResponse response) other, + }) { + return switch (this) { + ValuesApiGetSomeValuesResponse200 response => on200(response), + ValuesApiGetSomeValuesResponse400 response => on400(response), + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final matchedResponse = <(PatternMatchResult, Future Function())> [ + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'200'), + () => ValuesApiGetSomeValuesResponse200.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ( + OASNetworkingUtils.matchesStatusCodePattern(response.statusCode, r'400'), + () => ValuesApiGetSomeValuesResponse400.fromResponse(response, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + return ValuesApiGetSomeValuesResponse( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + +class ValuesApiGetSomeValuesResponse200 extends ValuesApiGetSomeValuesResponse { + ValuesApiGetSomeValuesResponse200({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + T split200({ + + required T Function(ValuesApiGetSomeValuesResponse200ApplicationJson response) onApplicationJson, + + required T Function(ValuesApiGetSomeValuesResponse200 response) other, + }) { + return switch (this) { + + ValuesApiGetSomeValuesResponse200ApplicationJson response => onApplicationJson(response), + + _ => other(this), + }; + } + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final headers = response.headers; + final contentTypeRaw = headers['Content-Type']; + final contentTypeParsed = contentTypeRaw == null ? null : MediaType.parse(contentTypeRaw); + if (contentTypeParsed != null) { + final matchedResponse = <(PatternMatchResult, Future Function())>[ + ( + OASNetworkingUtils.matchesContentTypePattern(contentTypeParsed, MediaType.parse(r'application/json')), + () => ValuesApiGetSomeValuesResponse200ApplicationJson.fromResponse(response, contentType: contentTypeParsed, userContext: userContext, wireSerializationOptions: wireSerializationOptions) + ), + ].pickPrioritized(); + if (matchedResponse != null) { + return matchedResponse(); + } + } + return ValuesApiGetSomeValuesResponse200( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + + + +/// Represent the response when content-type is application/json. +class ValuesApiGetSomeValuesResponse200ApplicationJson extends ValuesApiGetSomeValuesResponse200 { + final UndefinedWrapper< + Variable +> body; + + static const bodyReflection = XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Variable.$reflection + +, +) +; + + /// The raw result of calling jsonDecode + final Object? rawJson; + + ValuesApiGetSomeValuesResponse200ApplicationJson({ + this.body = const UndefinedWrapper.undefined(), + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + this.rawJson, + }); + + static Future fromResponse(HttpResponseBase response, {required MediaType contentType, required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + final encodingRules = { + + }; + + final context = wireSerializationOptions.createSerializationContext(contentType); + + switch (contentType) { + case MediaType(type: 'application', subtype: 'json'): + final encoding = OASNetworkingUtils.getEncodingOrDefault(contentType); + final serialized = await encoding.decodeStream(response.bodyBytesStream); + final v = jsonDecode(serialized); + if (bodyReflection.canDeserializeFunction(v, context)) { + final res = bodyReflection.deserializeFunction(v, context); + return ValuesApiGetSomeValuesResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + body: UndefinedWrapper(res), + + ); + } else { + // since we consumed the stream, we need to publish our read result. + return ValuesApiGetSomeValuesResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + rawJson: v, + + ); + } + default: + } + return ValuesApiGetSomeValuesResponse200ApplicationJson( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + + ); + } +} + + + +class ValuesApiGetSomeValuesResponse400 extends ValuesApiGetSomeValuesResponse { + ValuesApiGetSomeValuesResponse400({ + required super.headers, + required super.statusCode, + required super.reasonPhrase, + required super.userContext, + super.bodyBytesStream, + }); + + + + + static Future fromResponse(HttpResponseBase response, {required Map userContext, required WireSerializationOptions wireSerializationOptions}) async { + return ValuesApiGetSomeValuesResponse400( + headers: response.headers, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + userContext: userContext, + bodyBytesStream: response.bodyBytesStream, + ); + } +} + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/__200_response.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/__200_response.dart new file mode 100644 index 000000000000..43b088e91d88 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/__200_response.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part '__200_response.reflection.dart'; + + +/// Model for testing model name starting with number +/// +/// Properties: +/// * [name] +/// * [propertyClass] +mixin $200ResponseMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get name; +UndefinedWrapper< + String +> get propertyClass; + +} + +/// Model for testing model name starting with number +/// +/// Properties: +/// * [name] +/// * [propertyClass] +class $200Response with +$OpenApiObjectMixin, + +$200ResponseMixin { + @override + UndefinedWrapper< + int +> name; + @override + UndefinedWrapper< + String +> propertyClass; + + AdditionalProperties additionalProperties; + + + + $200Response.$all({ + required this.name, + required this.propertyClass, + required this.additionalProperties, + + }); + + $200Response({ + this.name = const UndefinedWrapper + .undefined() +, + this.propertyClass = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = $200ResponseReflection.instance; + $200ResponseReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory $200Response.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + $200Response clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/__200_response.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/__200_response.reflection.dart new file mode 100644 index 000000000000..3235a0c47ef3 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/__200_response.reflection.dart @@ -0,0 +1,189 @@ +// Model reflection + +part of '__200_response.dart'; + + +//class reflection + +class $200ResponseReflection extends ModelReflection<$200Response> { + static $200ResponseReflection instanceGetter() => instance; + static const instance = $200ResponseReflection._( + modelName: r'200_response', + className: r'$200Response', + xml: XmlReflection( + xmlName: r'Name', +), + namePart: PropertyReflection<$200Response, UndefinedWrapper< + int +>>( + dartName: r'name', + nullable: false, + required: false, + oasName: r'name', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + propertyClassPart: PropertyReflection<$200Response, UndefinedWrapper< + String +>>( + dartName: r'propertyClass', + nullable: false, + required: false, + oasName: r'class', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_propertyClassGetter), + setter: FunctionWrapper2(_propertyClassSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const $200ResponseReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.namePart, + required this.propertyClassPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection<$200Response, UndefinedWrapper< + int +>> namePart; + static UndefinedWrapper< + int +> _nameGetter($200Response parent) { + return parent.name; + } + static void _nameSetter($200Response parent, UndefinedWrapper< + int +> value) { + parent.name = value; + } + + final PropertyReflection<$200Response, UndefinedWrapper< + String +>> propertyClassPart; + static UndefinedWrapper< + String +> _propertyClassGetter($200Response parent) { + return parent.propertyClass; + } + static void _propertyClassSetter($200Response parent, UndefinedWrapper< + String +> value) { + parent.propertyClass = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + namePart, +propertyClassPart, + ]; + + @override + final AdditionalPropertiesPart<$200Response, Object +?>? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter($200Response instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter($200Response instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + $200Response empty() { + return $200Response( + ); + } + + @override + bool operator ==(Object other) { + return other is $200ResponseReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/__list.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/__list.dart new file mode 100644 index 000000000000..e0c3637fcced --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/__list.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part '__list.reflection.dart'; + + +/// $ListMixin +/// +/// Properties: +/// * [$123list] +mixin $ListMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get $123list; + +} + +/// $List +/// +/// Properties: +/// * [$123list] +class $List with +$OpenApiObjectMixin, + +$ListMixin { + @override + UndefinedWrapper< + String +> $123list; + + AdditionalProperties additionalProperties; + + + + $List.$all({ + required this.$123list, + required this.additionalProperties, + + }); + + $List({ + this.$123list = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = $ListReflection.instance; + $ListReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory $List.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + $List clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/__list.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/__list.reflection.dart new file mode 100644 index 000000000000..ff17171ddf31 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/__list.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of '__list.dart'; + + +//class reflection + +class $ListReflection extends ModelReflection<$List> { + static $ListReflection instanceGetter() => instance; + static const instance = $ListReflection._( + modelName: r'List', + className: r'$List', + xml: XmlReflection( +), + $123listPart: PropertyReflection<$List, UndefinedWrapper< + String +>>( + dartName: r'$123list', + nullable: false, + required: false, + oasName: r'123-list', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_$123listGetter), + setter: FunctionWrapper2(_$123listSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const $ListReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.$123listPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection<$List, UndefinedWrapper< + String +>> $123listPart; + static UndefinedWrapper< + String +> _$123listGetter($List parent) { + return parent.$123list; + } + static void _$123listSetter($List parent, UndefinedWrapper< + String +> value) { + parent.$123list = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + $123listPart, + ]; + + @override + final AdditionalPropertiesPart<$List, Object +?>? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter($List instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter($List instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + $List empty() { + return $List( + ); + } + + @override + bool operator ==(Object other) { + return other is $ListReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/__return.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/__return.dart new file mode 100644 index 000000000000..a9edf096d7de --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/__return.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part '__return.reflection.dart'; + + +/// Model for testing reserved words +/// +/// Properties: +/// * [$return] +mixin $ReturnMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get $return; + +} + +/// Model for testing reserved words +/// +/// Properties: +/// * [$return] +class $Return with +$OpenApiObjectMixin, + +$ReturnMixin { + @override + UndefinedWrapper< + int +> $return; + + AdditionalProperties additionalProperties; + + + + $Return.$all({ + required this.$return, + required this.additionalProperties, + + }); + + $Return({ + this.$return = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = $ReturnReflection.instance; + $ReturnReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory $Return.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + $Return clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/__return.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/__return.reflection.dart new file mode 100644 index 000000000000..103ca4fe2849 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/__return.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of '__return.dart'; + + +//class reflection + +class $ReturnReflection extends ModelReflection<$Return> { + static $ReturnReflection instanceGetter() => instance; + static const instance = $ReturnReflection._( + modelName: r'Return', + className: r'$Return', + xml: XmlReflection( + xmlName: r'Return', +), + $returnPart: PropertyReflection<$Return, UndefinedWrapper< + int +>>( + dartName: r'$return', + nullable: false, + required: false, + oasName: r'return', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_$returnGetter), + setter: FunctionWrapper2(_$returnSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const $ReturnReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.$returnPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection<$Return, UndefinedWrapper< + int +>> $returnPart; + static UndefinedWrapper< + int +> _$returnGetter($Return parent) { + return parent.$return; + } + static void _$returnSetter($Return parent, UndefinedWrapper< + int +> value) { + parent.$return = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + $returnPart, + ]; + + @override + final AdditionalPropertiesPart<$Return, Object +?>? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter($Return instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter($Return instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + $Return empty() { + return $Return( + ); + } + + @override + bool operator ==(Object other) { + return other is $ReturnReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/_exports.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/_exports.dart new file mode 100644 index 000000000000..ea07dc1b97c3 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/_exports.dart @@ -0,0 +1,116 @@ +export '__200_response.dart'; +export '__list.dart'; +export '__return.dart'; +export 'additional_properties_class.dart'; +export 'all_of_model_array_any_of.dart'; +export 'all_of_model_array_any_of_all_of_attributes.dart'; +export 'all_of_model_array_any_of_all_of_attributes_c.dart'; +export 'all_of_model_array_any_of_all_of_link_list_column1.dart'; +export 'all_of_model_array_any_of_all_of_link_list_column1_value.dart'; +export 'animal.dart'; +export 'api_response.dart'; +export 'apple.dart'; +export 'apple_req.dart'; +export 'array_any_of.dart'; +export 'array_default.dart'; +export 'array_of_array_of_number_only.dart'; +export 'array_of_inline_all_of.dart'; +export 'array_of_inline_all_of_array_allof_dog_property_inner.dart'; +export 'array_of_number_only.dart'; +export 'array_one_of.dart'; +export 'array_test.dart'; +export 'banana.dart'; +export 'banana_req.dart'; +export 'basque_pig.dart'; +export 'capitalization.dart'; +export 'cat.dart'; +export 'category.dart'; +export 'class_model.dart'; +export 'client.dart'; +export 'complex_quadrilateral.dart'; +export 'danish_pig.dart'; +export 'deprecated_object.dart'; +export 'dog.dart'; +export 'drawing.dart'; +export 'enum_arrays.dart'; +export 'enum_class.dart'; +export 'enum_string_discriminator.dart'; +export 'enum_test.dart'; +export 'equilateral_triangle.dart'; +export 'fake_any_of_w_ith_same_erasure_get200_response.dart'; +export 'fake_one_of_w_ith_same_erasure_get200_response.dart'; +export 'file.dart'; +export 'file_schema_test_class.dart'; +export 'foo.dart'; +export 'foo_get_default_response.dart'; +export 'format_test.dart'; +export 'free_form_object_test_class.dart'; +export 'free_form_object_test_class_properties.dart'; +export 'fruit.dart'; +export 'fruit_req.dart'; +export 'gm_fruit.dart'; +export 'grandparent_animal.dart'; +export 'has_only_read_only.dart'; +export 'health_check_result.dart'; +export 'isosceles_triangle.dart'; +export 'mammal.dart'; +export 'map_test.dart'; +export 'mixed_properties_and_additional_properties_class.dart'; +export 'mixed_type_one_of_number.dart'; +export 'mixed_type_one_of_object.dart'; +export 'mixed_type_one_of_object_any_of.dart'; +export 'mixed_type_one_of_object_any_of1.dart'; +export 'mixed_type_one_of_object_one_of.dart'; +export 'mixed_type_one_of_object_one_of1.dart'; +export 'model_with_one_of_any_of_properties.dart'; +export 'name.dart'; +export 'new_pet.dart'; +export 'new_pet_category_inline_allof.dart'; +export 'new_pet_category_inline_allof_all_of_category_tag.dart'; +export 'nullable_class.dart'; +export 'nullable_shape.dart'; +export 'number_only.dart'; +export 'object_with_deprecated_fields.dart'; +export 'order.dart'; +export 'outer_composite.dart'; +export 'outer_enum.dart'; +export 'outer_enum_default_value.dart'; +export 'outer_enum_integer.dart'; +export 'outer_enum_integer_default_value.dart'; +export 'parent_pet.dart'; +export 'pet.dart'; +export 'pet_composition.dart'; +export 'pet_ref.dart'; +export 'pet_using_all_of.dart'; +export 'pet_with_required_tags.dart'; +export 'pets_multicontent_test_post_request.dart'; +export 'pets_multicontent_test_post_request_address.dart'; +export 'pig.dart'; +export 'property_name_collision.dart'; +export 'quadrilateral.dart'; +export 'quadrilateral_interface.dart'; +export 'read_only_first.dart'; +export 'scalar.dart'; +export 'scalar_any_of.dart'; +export 'scalene_triangle.dart'; +export 'shape.dart'; +export 'shape_interface.dart'; +export 'shape_or_null.dart'; +export 'simple_quadrilateral.dart'; +export 'special_model_name.dart'; +export 'tag.dart'; +export 'test_endpoint_parameters_request.dart'; +export 'test_enum_parameters_request.dart'; +export 'test_inline_freeform_additional_properties_request.dart'; +export 'test_json_form_data_request.dart'; +export 'triangle.dart'; +export 'triangle_interface.dart'; +export 'update_pet_with_form_request.dart'; +export 'upload_file_request.dart'; +export 'upload_file_with_required_file_request.dart'; +export 'user.dart'; +export 'value.dart'; +export 'variable.dart'; +export 'whale.dart'; +export 'xml_item.dart'; +export 'zebra.dart'; diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/additional_properties_class.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/additional_properties_class.dart new file mode 100644 index 000000000000..fd1b4d56c654 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/additional_properties_class.dart @@ -0,0 +1,230 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'additional_properties_class.reflection.dart'; + + +/// AdditionalPropertiesClassMixin +/// +/// Properties: +/// * [mapProperty] +/// * [mapOfMapProperty] +/// * [anytype1] +/// * [mapWithUndeclaredPropertiesAnytype1] +/// * [mapWithUndeclaredPropertiesAnytype2] +/// * [mapWithUndeclaredPropertiesAnytype3] +/// * [emptyMap] - an object with no declared properties and no undeclared properties, hence it's an empty map. +/// * [mapWithUndeclaredPropertiesString] +mixin AdditionalPropertiesClassMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + Map +> get mapProperty; +UndefinedWrapper< + Map +> +> get mapOfMapProperty; +UndefinedWrapper get anytype1; +UndefinedWrapper< + $FreeFormObject +> get mapWithUndeclaredPropertiesAnytype1; +UndefinedWrapper< + $FreeFormObject +> get mapWithUndeclaredPropertiesAnytype2; +UndefinedWrapper< + Map +> get mapWithUndeclaredPropertiesAnytype3; +UndefinedWrapper< + $FreeFormObject +> get emptyMap; +UndefinedWrapper< + Map +> get mapWithUndeclaredPropertiesString; + +} + +/// AdditionalPropertiesClass +/// +/// Properties: +/// * [mapProperty] +/// * [mapOfMapProperty] +/// * [anytype1] +/// * [mapWithUndeclaredPropertiesAnytype1] +/// * [mapWithUndeclaredPropertiesAnytype2] +/// * [mapWithUndeclaredPropertiesAnytype3] +/// * [emptyMap] - an object with no declared properties and no undeclared properties, hence it's an empty map. +/// * [mapWithUndeclaredPropertiesString] +class AdditionalPropertiesClass with +$OpenApiObjectMixin, + +AdditionalPropertiesClassMixin { + @override + UndefinedWrapper< + Map +> mapProperty; + @override + UndefinedWrapper< + Map +> +> mapOfMapProperty; + @override + UndefinedWrapper anytype1; + @override + UndefinedWrapper< + $FreeFormObject +> mapWithUndeclaredPropertiesAnytype1; + @override + UndefinedWrapper< + $FreeFormObject +> mapWithUndeclaredPropertiesAnytype2; + @override + UndefinedWrapper< + Map +> mapWithUndeclaredPropertiesAnytype3; + @override + UndefinedWrapper< + $FreeFormObject +> emptyMap; + @override + UndefinedWrapper< + Map +> mapWithUndeclaredPropertiesString; + + AdditionalProperties additionalProperties; + + + + AdditionalPropertiesClass.$all({ + required this.mapProperty, + required this.mapOfMapProperty, + required this.anytype1, + required this.mapWithUndeclaredPropertiesAnytype1, + required this.mapWithUndeclaredPropertiesAnytype2, + required this.mapWithUndeclaredPropertiesAnytype3, + required this.emptyMap, + required this.mapWithUndeclaredPropertiesString, + required this.additionalProperties, + + }); + + AdditionalPropertiesClass({ + this.mapProperty = const UndefinedWrapper + .undefined() +, + this.mapOfMapProperty = const UndefinedWrapper + .undefined() +, + this.anytype1 = const UndefinedWrapper + .undefined() +, + this.mapWithUndeclaredPropertiesAnytype1 = const UndefinedWrapper + .undefined() +, + this.mapWithUndeclaredPropertiesAnytype2 = const UndefinedWrapper + .undefined() +, + this.mapWithUndeclaredPropertiesAnytype3 = const UndefinedWrapper + .undefined() +, + this.emptyMap = const UndefinedWrapper + .undefined() +, + this.mapWithUndeclaredPropertiesString = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = AdditionalPropertiesClassReflection.instance; + AdditionalPropertiesClassReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory AdditionalPropertiesClass.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + AdditionalPropertiesClass clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/additional_properties_class.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/additional_properties_class.reflection.dart new file mode 100644 index 000000000000..d5270f6a0ed9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/additional_properties_class.reflection.dart @@ -0,0 +1,533 @@ +// Model reflection + +part of 'additional_properties_class.dart'; + + +//class reflection + +class AdditionalPropertiesClassReflection extends ModelReflection { + static AdditionalPropertiesClassReflection instanceGetter() => instance; + static const instance = AdditionalPropertiesClassReflection._( + modelName: r'AdditionalPropertiesClass', + className: r'AdditionalPropertiesClass', + xml: XmlReflection( +), + mapPropertyPart: PropertyReflection +>>( + dartName: r'mapProperty', + nullable: false, + required: false, + oasName: r'map_property', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mapPropertyGetter), + setter: FunctionWrapper2(_mapPropertySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +), + ), + mapOfMapPropertyPart: PropertyReflection +> +>>( + dartName: r'mapOfMapProperty', + nullable: false, + required: false, + oasName: r'map_of_map_property', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mapOfMapPropertyGetter), + setter: FunctionWrapper2(_mapOfMapPropertySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +) +, +) +), + ), + anytype1Part: PropertyReflection>( + dartName: r'anytype1', + nullable: true, + required: false, + oasName: r'anytype_1', + oasType: r'Object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_anytype1Getter), + setter: FunctionWrapper2(_anytype1Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +), + ), + mapWithUndeclaredPropertiesAnytype1Part: PropertyReflection>( + dartName: r'mapWithUndeclaredPropertiesAnytype1', + nullable: false, + required: false, + oasName: r'map_with_undeclared_properties_anytype_1', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mapWithUndeclaredPropertiesAnytype1Getter), + setter: FunctionWrapper2(_mapWithUndeclaredPropertiesAnytype1Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.for$FreeFormObject + +, +) +), + ), + mapWithUndeclaredPropertiesAnytype2Part: PropertyReflection>( + dartName: r'mapWithUndeclaredPropertiesAnytype2', + nullable: false, + required: false, + oasName: r'map_with_undeclared_properties_anytype_2', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mapWithUndeclaredPropertiesAnytype2Getter), + setter: FunctionWrapper2(_mapWithUndeclaredPropertiesAnytype2Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.for$FreeFormObject + +, +) +), + ), + mapWithUndeclaredPropertiesAnytype3Part: PropertyReflection +>>( + dartName: r'mapWithUndeclaredPropertiesAnytype3', + nullable: false, + required: false, + oasName: r'map_with_undeclared_properties_anytype_3', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mapWithUndeclaredPropertiesAnytype3Getter), + setter: FunctionWrapper2(_mapWithUndeclaredPropertiesAnytype3Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +) +, +) +), + ), + emptyMapPart: PropertyReflection>( + dartName: r'emptyMap', + nullable: false, + required: false, + oasName: r'empty_map', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_emptyMapGetter), + setter: FunctionWrapper2(_emptyMapSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.for$FreeFormObject + +, +) +), + ), + mapWithUndeclaredPropertiesStringPart: PropertyReflection +>>( + dartName: r'mapWithUndeclaredPropertiesString', + nullable: false, + required: false, + oasName: r'map_with_undeclared_properties_string', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mapWithUndeclaredPropertiesStringGetter), + setter: FunctionWrapper2(_mapWithUndeclaredPropertiesStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const AdditionalPropertiesClassReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.mapPropertyPart, + required this.mapOfMapPropertyPart, + required this.anytype1Part, + required this.mapWithUndeclaredPropertiesAnytype1Part, + required this.mapWithUndeclaredPropertiesAnytype2Part, + required this.mapWithUndeclaredPropertiesAnytype3Part, + required this.emptyMapPart, + required this.mapWithUndeclaredPropertiesStringPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection +>> mapPropertyPart; + static UndefinedWrapper< + Map +> _mapPropertyGetter(AdditionalPropertiesClass parent) { + return parent.mapProperty; + } + static void _mapPropertySetter(AdditionalPropertiesClass parent, UndefinedWrapper< + Map +> value) { + parent.mapProperty = value; + } + + final PropertyReflection +> +>> mapOfMapPropertyPart; + static UndefinedWrapper< + Map +> +> _mapOfMapPropertyGetter(AdditionalPropertiesClass parent) { + return parent.mapOfMapProperty; + } + static void _mapOfMapPropertySetter(AdditionalPropertiesClass parent, UndefinedWrapper< + Map +> +> value) { + parent.mapOfMapProperty = value; + } + + final PropertyReflection> anytype1Part; + static UndefinedWrapper _anytype1Getter(AdditionalPropertiesClass parent) { + return parent.anytype1; + } + static void _anytype1Setter(AdditionalPropertiesClass parent, UndefinedWrapper value) { + parent.anytype1 = value; + } + + final PropertyReflection> mapWithUndeclaredPropertiesAnytype1Part; + static UndefinedWrapper< + $FreeFormObject +> _mapWithUndeclaredPropertiesAnytype1Getter(AdditionalPropertiesClass parent) { + return parent.mapWithUndeclaredPropertiesAnytype1; + } + static void _mapWithUndeclaredPropertiesAnytype1Setter(AdditionalPropertiesClass parent, UndefinedWrapper< + $FreeFormObject +> value) { + parent.mapWithUndeclaredPropertiesAnytype1 = value; + } + + final PropertyReflection> mapWithUndeclaredPropertiesAnytype2Part; + static UndefinedWrapper< + $FreeFormObject +> _mapWithUndeclaredPropertiesAnytype2Getter(AdditionalPropertiesClass parent) { + return parent.mapWithUndeclaredPropertiesAnytype2; + } + static void _mapWithUndeclaredPropertiesAnytype2Setter(AdditionalPropertiesClass parent, UndefinedWrapper< + $FreeFormObject +> value) { + parent.mapWithUndeclaredPropertiesAnytype2 = value; + } + + final PropertyReflection +>> mapWithUndeclaredPropertiesAnytype3Part; + static UndefinedWrapper< + Map +> _mapWithUndeclaredPropertiesAnytype3Getter(AdditionalPropertiesClass parent) { + return parent.mapWithUndeclaredPropertiesAnytype3; + } + static void _mapWithUndeclaredPropertiesAnytype3Setter(AdditionalPropertiesClass parent, UndefinedWrapper< + Map +> value) { + parent.mapWithUndeclaredPropertiesAnytype3 = value; + } + + final PropertyReflection> emptyMapPart; + static UndefinedWrapper< + $FreeFormObject +> _emptyMapGetter(AdditionalPropertiesClass parent) { + return parent.emptyMap; + } + static void _emptyMapSetter(AdditionalPropertiesClass parent, UndefinedWrapper< + $FreeFormObject +> value) { + parent.emptyMap = value; + } + + final PropertyReflection +>> mapWithUndeclaredPropertiesStringPart; + static UndefinedWrapper< + Map +> _mapWithUndeclaredPropertiesStringGetter(AdditionalPropertiesClass parent) { + return parent.mapWithUndeclaredPropertiesString; + } + static void _mapWithUndeclaredPropertiesStringSetter(AdditionalPropertiesClass parent, UndefinedWrapper< + Map +> value) { + parent.mapWithUndeclaredPropertiesString = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + mapPropertyPart, +mapOfMapPropertyPart, +anytype1Part, +mapWithUndeclaredPropertiesAnytype1Part, +mapWithUndeclaredPropertiesAnytype2Part, +mapWithUndeclaredPropertiesAnytype3Part, +emptyMapPart, +mapWithUndeclaredPropertiesStringPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(AdditionalPropertiesClass instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(AdditionalPropertiesClass instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + AdditionalPropertiesClass empty() { + return AdditionalPropertiesClass( + ); + } + + @override + bool operator ==(Object other) { + return other is AdditionalPropertiesClassReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of.dart new file mode 100644 index 000000000000..bea2c890d874 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of.dart @@ -0,0 +1,119 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'all_of_model_array_any_of.reflection.dart'; + + +/// AllOfModelArrayAnyOfMixin +/// +/// Properties: +/// * [linkListColumn1] +/// * [attributes] +mixin AllOfModelArrayAnyOfMixin on + CategoryMixin, $OpenApiObjectMixin { + UndefinedWrapper< + AllOfModelArrayAnyOfAllOfLinkListColumn1 +> get linkListColumn1; +UndefinedWrapper< + AllOfModelArrayAnyOfAllOfAttributes +> get attributes; + +} + +/// AllOfModelArrayAnyOf +/// +/// Properties: +/// * [name] +/// * [attributes] +/// * [id] +/// * [linkListColumn1] +class AllOfModelArrayAnyOf with +$OpenApiObjectMixin, +CategoryMixin, +AllOfModelArrayAnyOfMixin { + @override + + String + name; + @override + UndefinedWrapper< + AllOfModelArrayAnyOfAllOfAttributes +> attributes; + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + AllOfModelArrayAnyOfAllOfLinkListColumn1 +> linkListColumn1; + + AdditionalProperties additionalProperties; + + + + AllOfModelArrayAnyOf.$all({ + required this.name, + required this.attributes, + required this.id, + required this.linkListColumn1, + required this.additionalProperties, + + }); + + AllOfModelArrayAnyOf({ + this.name = + + 'default-name' + +, + this.attributes = const UndefinedWrapper + .undefined() +, + this.id = const UndefinedWrapper + .undefined() +, + this.linkListColumn1 = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = AllOfModelArrayAnyOfReflection.instance; + AllOfModelArrayAnyOfReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory AllOfModelArrayAnyOf.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + AllOfModelArrayAnyOf clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of.reflection.dart new file mode 100644 index 000000000000..08653613c680 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of.reflection.dart @@ -0,0 +1,293 @@ +// Model reflection + +part of 'all_of_model_array_any_of.dart'; + + +//class reflection + +class AllOfModelArrayAnyOfReflection extends ModelReflection { + static AllOfModelArrayAnyOfReflection instanceGetter() => instance; + static const instance = AllOfModelArrayAnyOfReflection._( + modelName: r'AllOfModelArrayAnyOf', + className: r'AllOfModelArrayAnyOf', + xml: XmlReflection( +), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + attributesPart: PropertyReflection>( + dartName: r'attributes', + nullable: false, + required: false, + oasName: r'attributes', + oasType: r'AllOfModelArrayAnyOfAllOfAttributes', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_attributesGetter), + setter: FunctionWrapper2(_attributesSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + AllOfModelArrayAnyOfAllOfAttributes.$reflection + +, +) +), + ), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + linkListColumn1Part: PropertyReflection>( + dartName: r'linkListColumn1', + nullable: false, + required: false, + oasName: r'linkListColumn1', + oasType: r'AllOfModelArrayAnyOfAllOfLinkListColumn1', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_linkListColumn1Getter), + setter: FunctionWrapper2(_linkListColumn1Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + AllOfModelArrayAnyOfAllOfLinkListColumn1.$reflection + +, +) +), + ), + allOfCategoryPart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: CategoryReflection.instance, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const AllOfModelArrayAnyOfReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.namePart, + required this.attributesPart, + required this.idPart, + required this.linkListColumn1Part, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfCategoryPart, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection namePart; + static + String + _nameGetter(AllOfModelArrayAnyOf parent) { + return parent.name; + } + static void _nameSetter(AllOfModelArrayAnyOf parent, + String + value) { + parent.name = value; + } + + final PropertyReflection> attributesPart; + static UndefinedWrapper< + AllOfModelArrayAnyOfAllOfAttributes +> _attributesGetter(AllOfModelArrayAnyOf parent) { + return parent.attributes; + } + static void _attributesSetter(AllOfModelArrayAnyOf parent, UndefinedWrapper< + AllOfModelArrayAnyOfAllOfAttributes +> value) { + parent.attributes = value; + } + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(AllOfModelArrayAnyOf parent) { + return parent.id; + } + static void _idSetter(AllOfModelArrayAnyOf parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> linkListColumn1Part; + static UndefinedWrapper< + AllOfModelArrayAnyOfAllOfLinkListColumn1 +> _linkListColumn1Getter(AllOfModelArrayAnyOf parent) { + return parent.linkListColumn1; + } + static void _linkListColumn1Setter(AllOfModelArrayAnyOf parent, UndefinedWrapper< + AllOfModelArrayAnyOfAllOfLinkListColumn1 +> value) { + parent.linkListColumn1 = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + namePart, +attributesPart, +idPart, +linkListColumn1Part, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(AllOfModelArrayAnyOf instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(AllOfModelArrayAnyOf instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + final AllOfReflection allOfCategoryPart; + + + + @override + List> get allOfs => [ + allOfCategoryPart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + AllOfModelArrayAnyOf empty() { + return AllOfModelArrayAnyOf( + name: namePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is AllOfModelArrayAnyOfReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes.dart new file mode 100644 index 000000000000..f655f50fa89a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'all_of_model_array_any_of_all_of_attributes.reflection.dart'; + + +/// AllOfModelArrayAnyOfAllOfAttributesMixin +/// +/// Properties: +/// * [C] +mixin AllOfModelArrayAnyOfAllOfAttributesMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + AllOfModelArrayAnyOfAllOfAttributesC +> get C; + +} + +/// AllOfModelArrayAnyOfAllOfAttributes +/// +/// Properties: +/// * [C] +class AllOfModelArrayAnyOfAllOfAttributes with +$OpenApiObjectMixin, + +AllOfModelArrayAnyOfAllOfAttributesMixin { + @override + UndefinedWrapper< + AllOfModelArrayAnyOfAllOfAttributesC +> C; + + AdditionalProperties additionalProperties; + + + + AllOfModelArrayAnyOfAllOfAttributes.$all({ + required this.C, + required this.additionalProperties, + + }); + + AllOfModelArrayAnyOfAllOfAttributes({ + this.C = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = AllOfModelArrayAnyOfAllOfAttributesReflection.instance; + AllOfModelArrayAnyOfAllOfAttributesReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory AllOfModelArrayAnyOfAllOfAttributes.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + AllOfModelArrayAnyOfAllOfAttributes clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes.reflection.dart new file mode 100644 index 000000000000..c23b1bd656e2 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'all_of_model_array_any_of_all_of_attributes.dart'; + + +//class reflection + +class AllOfModelArrayAnyOfAllOfAttributesReflection extends ModelReflection { + static AllOfModelArrayAnyOfAllOfAttributesReflection instanceGetter() => instance; + static const instance = AllOfModelArrayAnyOfAllOfAttributesReflection._( + modelName: r'AllOfModelArrayAnyOf_allOf_attributes', + className: r'AllOfModelArrayAnyOfAllOfAttributes', + xml: XmlReflection( +), + CPart: PropertyReflection>( + dartName: r'C', + nullable: false, + required: false, + oasName: r'C', + oasType: r'AllOfModelArrayAnyOfAllOfAttributesC', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_CGetter), + setter: FunctionWrapper2(_CSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + AllOfModelArrayAnyOfAllOfAttributesC.$reflection + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const AllOfModelArrayAnyOfAllOfAttributesReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.CPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> CPart; + static UndefinedWrapper< + AllOfModelArrayAnyOfAllOfAttributesC +> _CGetter(AllOfModelArrayAnyOfAllOfAttributes parent) { + return parent.C; + } + static void _CSetter(AllOfModelArrayAnyOfAllOfAttributes parent, UndefinedWrapper< + AllOfModelArrayAnyOfAllOfAttributesC +> value) { + parent.C = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + CPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(AllOfModelArrayAnyOfAllOfAttributes instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(AllOfModelArrayAnyOfAllOfAttributes instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + AllOfModelArrayAnyOfAllOfAttributes empty() { + return AllOfModelArrayAnyOfAllOfAttributes( + ); + } + + @override + bool operator ==(Object other) { + return other is AllOfModelArrayAnyOfAllOfAttributesReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes_c.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes_c.dart new file mode 100644 index 000000000000..d86a02c6ba08 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes_c.dart @@ -0,0 +1,92 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'all_of_model_array_any_of_all_of_attributes_c.reflection.dart'; + + +/// AllOfModelArrayAnyOfAllOfAttributesCMixin +/// +/// Properties: +mixin AllOfModelArrayAnyOfAllOfAttributesCMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + Pet +> get oneOf0; + UndefinedWrapper< + Order +> get oneOf1; +} + +/// AllOfModelArrayAnyOfAllOfAttributesC +/// +/// Properties: +class AllOfModelArrayAnyOfAllOfAttributesC with +$OpenApiObjectMixin, + +AllOfModelArrayAnyOfAllOfAttributesCMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + Pet +> oneOf0; + + @override + UndefinedWrapper< + Order +> oneOf1; + + + AllOfModelArrayAnyOfAllOfAttributesC.$all({ + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + AllOfModelArrayAnyOfAllOfAttributesC({ + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = AllOfModelArrayAnyOfAllOfAttributesCReflection.instance; + AllOfModelArrayAnyOfAllOfAttributesCReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory AllOfModelArrayAnyOfAllOfAttributesC.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + AllOfModelArrayAnyOfAllOfAttributesC clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes_c.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes_c.reflection.dart new file mode 100644 index 000000000000..36dd9dceff68 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_attributes_c.reflection.dart @@ -0,0 +1,264 @@ +// Model reflection + +part of 'all_of_model_array_any_of_all_of_attributes_c.dart'; + + +//class reflection + +class AllOfModelArrayAnyOfAllOfAttributesCReflection extends ModelReflection { + static AllOfModelArrayAnyOfAllOfAttributesCReflection instanceGetter() => instance; + static const instance = AllOfModelArrayAnyOfAllOfAttributesCReflection._( + modelName: r'AllOfModelArrayAnyOf_allOf_attributes_C', + className: r'AllOfModelArrayAnyOfAllOfAttributesC', + xml: XmlReflection( +), + + + oneOf0Part: AllOfModelArrayAnyOfAllOfAttributesCOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: AllOfModelArrayAnyOfAllOfAttributesCOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const AllOfModelArrayAnyOfAllOfAttributesCReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(AllOfModelArrayAnyOfAllOfAttributesC instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(AllOfModelArrayAnyOfAllOfAttributesC instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final AllOfModelArrayAnyOfAllOfAttributesCOneOf0Part oneOf0Part; + + final AllOfModelArrayAnyOfAllOfAttributesCOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + AllOfModelArrayAnyOfAllOfAttributesC empty() { + return AllOfModelArrayAnyOfAllOfAttributesC( + ); + } + + @override + bool operator ==(Object other) { + return other is AllOfModelArrayAnyOfAllOfAttributesCReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class AllOfModelArrayAnyOfAllOfAttributesCOneOf0Part extends OneOfReflection { + + const AllOfModelArrayAnyOfAllOfAttributesCOneOf0Part({ + required AllOfModelArrayAnyOfAllOfAttributesCReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, AllOfModelArrayAnyOfAllOfAttributesC> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Pet +> _getter(AllOfModelArrayAnyOfAllOfAttributesC src) { + return src.oneOf0; +} +static void _setter(AllOfModelArrayAnyOfAllOfAttributesC src, UndefinedWrapper< + Pet +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + Pet +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Pet', +), + + + + + + Pet.$reflection + + + ), +); + + UndefinedWrapper< + Pet +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class AllOfModelArrayAnyOfAllOfAttributesCOneOf1Part extends OneOfReflection { + + const AllOfModelArrayAnyOfAllOfAttributesCOneOf1Part({ + required AllOfModelArrayAnyOfAllOfAttributesCReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, AllOfModelArrayAnyOfAllOfAttributesC> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Order +> _getter(AllOfModelArrayAnyOfAllOfAttributesC src) { + return src.oneOf1; +} +static void _setter(AllOfModelArrayAnyOfAllOfAttributesC src, UndefinedWrapper< + Order +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + Order +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Order', +), + + + + + + Order.$reflection + + + ), +); + + UndefinedWrapper< + Order +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1.dart new file mode 100644 index 000000000000..6dd354748a62 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1.dart @@ -0,0 +1,88 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'all_of_model_array_any_of_all_of_link_list_column1.reflection.dart'; + + +/// AllOfModelArrayAnyOfAllOfLinkListColumn1Mixin +/// +/// Properties: +/// * [value] +mixin AllOfModelArrayAnyOfAllOfLinkListColumn1Mixin on + $OpenApiObjectMixin { + + List< + + AllOfModelArrayAnyOfAllOfLinkListColumn1Value +> + get value; + +} + +/// AllOfModelArrayAnyOfAllOfLinkListColumn1 +/// +/// Properties: +/// * [value] +class AllOfModelArrayAnyOfAllOfLinkListColumn1 with +$OpenApiObjectMixin, + +AllOfModelArrayAnyOfAllOfLinkListColumn1Mixin { + @override + + List< + + AllOfModelArrayAnyOfAllOfLinkListColumn1Value +> + value; + + AdditionalProperties additionalProperties; + + + + AllOfModelArrayAnyOfAllOfLinkListColumn1.$all({ + required this.value, + required this.additionalProperties, + + }); + + AllOfModelArrayAnyOfAllOfLinkListColumn1({ + required this.value , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = AllOfModelArrayAnyOfAllOfLinkListColumn1Reflection.instance; + AllOfModelArrayAnyOfAllOfLinkListColumn1Reflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory AllOfModelArrayAnyOfAllOfLinkListColumn1.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + AllOfModelArrayAnyOfAllOfLinkListColumn1 clone() { + return $reflection.clone(this); + } +} + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1.reflection.dart new file mode 100644 index 000000000000..f2bb4b4e1a6e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1.reflection.dart @@ -0,0 +1,163 @@ +// Model reflection + +part of 'all_of_model_array_any_of_all_of_link_list_column1.dart'; + + +//class reflection + +class AllOfModelArrayAnyOfAllOfLinkListColumn1Reflection extends ModelReflection { + static AllOfModelArrayAnyOfAllOfLinkListColumn1Reflection instanceGetter() => instance; + static const instance = AllOfModelArrayAnyOfAllOfLinkListColumn1Reflection._( + modelName: r'AllOfModelArrayAnyOf_allOf_linkListColumn1', + className: r'AllOfModelArrayAnyOfAllOfLinkListColumn1', + xml: XmlReflection( +), + valuePart: PropertyReflection +>( + dartName: r'value', + nullable: false, + required: true, + oasName: r'value', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_valueGetter), + setter: FunctionWrapper2(_valueSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + AllOfModelArrayAnyOfAllOfLinkListColumn1Value.$reflection + +, +) +) +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const AllOfModelArrayAnyOfAllOfLinkListColumn1Reflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.valuePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection +> valuePart; + static + List< + + AllOfModelArrayAnyOfAllOfLinkListColumn1Value +> + _valueGetter(AllOfModelArrayAnyOfAllOfLinkListColumn1 parent) { + return parent.value; + } + static void _valueSetter(AllOfModelArrayAnyOfAllOfLinkListColumn1 parent, + List< + + AllOfModelArrayAnyOfAllOfLinkListColumn1Value +> + value) { + parent.value = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + valuePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(AllOfModelArrayAnyOfAllOfLinkListColumn1 instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(AllOfModelArrayAnyOfAllOfLinkListColumn1 instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + AllOfModelArrayAnyOfAllOfLinkListColumn1 empty() { + return AllOfModelArrayAnyOfAllOfLinkListColumn1( + value: valuePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is AllOfModelArrayAnyOfAllOfLinkListColumn1Reflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1_value.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1_value.dart new file mode 100644 index 000000000000..e80461e87fff --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1_value.dart @@ -0,0 +1,89 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'all_of_model_array_any_of_all_of_link_list_column1_value.reflection.dart'; + + +/// AllOfModelArrayAnyOfAllOfLinkListColumn1ValueMixin +/// +/// Properties: +mixin AllOfModelArrayAnyOfAllOfLinkListColumn1ValueMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + User +> get anyOf0; + UndefinedWrapper< + Tag +> get anyOf1; +} + +/// AllOfModelArrayAnyOfAllOfLinkListColumn1Value +/// +/// Properties: +class AllOfModelArrayAnyOfAllOfLinkListColumn1Value with +$OpenApiObjectMixin, + +AllOfModelArrayAnyOfAllOfLinkListColumn1ValueMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + User +> anyOf0; + + @override + UndefinedWrapper< + Tag +> anyOf1; + + + AllOfModelArrayAnyOfAllOfLinkListColumn1Value.$all({ + required this.additionalProperties, + + required this.anyOf0, + required this.anyOf1, + }); + + AllOfModelArrayAnyOfAllOfLinkListColumn1Value({ + AdditionalProperties? additionalProperties, + + this.anyOf0 = const UndefinedWrapper.undefined(), + + this.anyOf1 = const UndefinedWrapper.undefined(), + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection.instance; + AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory AllOfModelArrayAnyOfAllOfLinkListColumn1Value.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + AllOfModelArrayAnyOfAllOfLinkListColumn1Value clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1_value.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1_value.reflection.dart new file mode 100644 index 000000000000..837855a307f5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/all_of_model_array_any_of_all_of_link_list_column1_value.reflection.dart @@ -0,0 +1,246 @@ +// Model reflection + +part of 'all_of_model_array_any_of_all_of_link_list_column1_value.dart'; + + +//class reflection + +class AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection extends ModelReflection { + static AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection instanceGetter() => instance; + static const instance = AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection._( + modelName: r'AllOfModelArrayAnyOf_allOf_linkListColumn1_value', + className: r'AllOfModelArrayAnyOfAllOfLinkListColumn1Value', + xml: XmlReflection( +), + + + anyOf0Part: AllOfModelArrayAnyOfAllOfLinkListColumn1ValueAnyOf0Part( + parentReflectionGetter: instanceGetter, + ), + + anyOf1Part: AllOfModelArrayAnyOfAllOfLinkListColumn1ValueAnyOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.anyOf0Part, + + required this.anyOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(AllOfModelArrayAnyOfAllOfLinkListColumn1Value instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(AllOfModelArrayAnyOfAllOfLinkListColumn1Value instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final AllOfModelArrayAnyOfAllOfLinkListColumn1ValueAnyOf0Part anyOf0Part; + + final AllOfModelArrayAnyOfAllOfLinkListColumn1ValueAnyOf1Part anyOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + anyOf0Part,anyOf1Part, + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + AllOfModelArrayAnyOfAllOfLinkListColumn1Value empty() { + return AllOfModelArrayAnyOfAllOfLinkListColumn1Value( + ); + } + + @override + bool operator ==(Object other) { + return other is AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + +class AllOfModelArrayAnyOfAllOfLinkListColumn1ValueAnyOf0Part extends AnyOfReflection { + + const AllOfModelArrayAnyOfAllOfLinkListColumn1ValueAnyOf0Part({ + required AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, AllOfModelArrayAnyOfAllOfLinkListColumn1Value> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + User +> _getter(AllOfModelArrayAnyOfAllOfLinkListColumn1Value src) { + return src.anyOf0; +} +static void _setter(AllOfModelArrayAnyOfAllOfLinkListColumn1Value src, UndefinedWrapper< + User +> value) { + src.anyOf0 = value; +} + +@override +UndefinedWrapperReflection< + User +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + User.$reflection + + + ), +); + + UndefinedWrapper< + User +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} +class AllOfModelArrayAnyOfAllOfLinkListColumn1ValueAnyOf1Part extends AnyOfReflection { + + const AllOfModelArrayAnyOfAllOfLinkListColumn1ValueAnyOf1Part({ + required AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, AllOfModelArrayAnyOfAllOfLinkListColumn1Value> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Tag +> _getter(AllOfModelArrayAnyOfAllOfLinkListColumn1Value src) { + return src.anyOf1; +} +static void _setter(AllOfModelArrayAnyOfAllOfLinkListColumn1Value src, UndefinedWrapper< + Tag +> value) { + src.anyOf1 = value; +} + +@override +UndefinedWrapperReflection< + Tag +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Tag', +), + + + + + + Tag.$reflection + + + ), +); + + UndefinedWrapper< + Tag +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/animal.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/animal.dart new file mode 100644 index 000000000000..81941b347a2a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/animal.dart @@ -0,0 +1,100 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'animal.reflection.dart'; + + +/// AnimalMixin +/// +/// Properties: +/// * [className] +/// * [color] +mixin AnimalMixin on + $OpenApiObjectMixin { + + String + get className; +UndefinedWrapper< + String +> get color; + +} + +/// Animal +/// +/// Properties: +/// * [className] +/// * [color] +class Animal with +$OpenApiObjectMixin, + +AnimalMixin { + @override + + String + className; + @override + UndefinedWrapper< + String +> color; + + AdditionalProperties additionalProperties; + + + + Animal.$all({ + required this.className, + required this.color, + required this.additionalProperties, + + }); + + Animal({ + required this.className , + this.color = const UndefinedWrapper + ( + + 'red' + ) + +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = AnimalReflection.instance; + AnimalReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Animal.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Animal clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/animal.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/animal.reflection.dart new file mode 100644 index 000000000000..2b45ff0d802b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/animal.reflection.dart @@ -0,0 +1,194 @@ +// Model reflection + +part of 'animal.dart'; + + +//class reflection + +class AnimalReflection extends ModelReflection { + static AnimalReflection instanceGetter() => instance; + static const instance = AnimalReflection._( + modelName: r'Animal', + className: r'Animal', + xml: XmlReflection( +), + classNamePart: PropertyReflection( + dartName: r'className', + nullable: false, + required: true, + oasName: r'className', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_classNameGetter), + setter: FunctionWrapper2(_classNameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + colorPart: PropertyReflection>( + dartName: r'color', + nullable: false, + required: false, + oasName: r'color', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_colorGetter), + setter: FunctionWrapper2(_colorSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + discriminatorKey: r'className', + discriminatorImplicitMappings: const { + }, + discriminatorMappings: const { + }, + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const AnimalReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.classNamePart, + required this.colorPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection classNamePart; + static + String + _classNameGetter(Animal parent) { + return parent.className; + } + static void _classNameSetter(Animal parent, + String + value) { + parent.className = value; + } + + final PropertyReflection> colorPart; + static UndefinedWrapper< + String +> _colorGetter(Animal parent) { + return parent.color; + } + static void _colorSetter(Animal parent, UndefinedWrapper< + String +> value) { + parent.color = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + classNamePart, +colorPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Animal instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Animal instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Animal empty() { + return Animal( + className: classNamePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is AnimalReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/api_response.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/api_response.dart new file mode 100644 index 000000000000..8c12d75b68b8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/api_response.dart @@ -0,0 +1,114 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'api_response.reflection.dart'; + + +/// ApiResponseMixin +/// +/// Properties: +/// * [code] +/// * [type] +/// * [message] +mixin ApiResponseMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get code; +UndefinedWrapper< + String +> get type; +UndefinedWrapper< + String +> get message; + +} + +/// ApiResponse +/// +/// Properties: +/// * [code] +/// * [type] +/// * [message] +class ApiResponse with +$OpenApiObjectMixin, + +ApiResponseMixin { + @override + UndefinedWrapper< + int +> code; + @override + UndefinedWrapper< + String +> type; + @override + UndefinedWrapper< + String +> message; + + AdditionalProperties additionalProperties; + + + + ApiResponse.$all({ + required this.code, + required this.type, + required this.message, + required this.additionalProperties, + + }); + + ApiResponse({ + this.code = const UndefinedWrapper + .undefined() +, + this.type = const UndefinedWrapper + .undefined() +, + this.message = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ApiResponseReflection.instance; + ApiResponseReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ApiResponse.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ApiResponse clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/api_response.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/api_response.reflection.dart new file mode 100644 index 000000000000..9dd6754e8855 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/api_response.reflection.dart @@ -0,0 +1,233 @@ +// Model reflection + +part of 'api_response.dart'; + + +//class reflection + +class ApiResponseReflection extends ModelReflection { + static ApiResponseReflection instanceGetter() => instance; + static const instance = ApiResponseReflection._( + modelName: r'ApiResponse', + className: r'ApiResponse', + xml: XmlReflection( +), + codePart: PropertyReflection>( + dartName: r'code', + nullable: false, + required: false, + oasName: r'code', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_codeGetter), + setter: FunctionWrapper2(_codeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + typePart: PropertyReflection>( + dartName: r'type', + nullable: false, + required: false, + oasName: r'type', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_typeGetter), + setter: FunctionWrapper2(_typeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + messagePart: PropertyReflection>( + dartName: r'message', + nullable: false, + required: false, + oasName: r'message', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_messageGetter), + setter: FunctionWrapper2(_messageSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ApiResponseReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.codePart, + required this.typePart, + required this.messagePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> codePart; + static UndefinedWrapper< + int +> _codeGetter(ApiResponse parent) { + return parent.code; + } + static void _codeSetter(ApiResponse parent, UndefinedWrapper< + int +> value) { + parent.code = value; + } + + final PropertyReflection> typePart; + static UndefinedWrapper< + String +> _typeGetter(ApiResponse parent) { + return parent.type; + } + static void _typeSetter(ApiResponse parent, UndefinedWrapper< + String +> value) { + parent.type = value; + } + + final PropertyReflection> messagePart; + static UndefinedWrapper< + String +> _messageGetter(ApiResponse parent) { + return parent.message; + } + static void _messageSetter(ApiResponse parent, UndefinedWrapper< + String +> value) { + parent.message = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + codePart, +typePart, +messagePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ApiResponse instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ApiResponse instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ApiResponse empty() { + return ApiResponse( + ); + } + + @override + bool operator ==(Object other) { + return other is ApiResponseReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/apple.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/apple.dart new file mode 100644 index 000000000000..ebe4c47125a7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/apple.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'apple.reflection.dart'; + + +/// AppleMixin +/// +/// Properties: +/// * [cultivar] +/// * [origin] +mixin AppleMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get cultivar; +UndefinedWrapper< + String +> get origin; + +} + +/// Apple +/// +/// Properties: +/// * [cultivar] +/// * [origin] +class Apple with +$OpenApiObjectMixin, + +AppleMixin { + @override + UndefinedWrapper< + String +> cultivar; + @override + UndefinedWrapper< + String +> origin; + + AdditionalProperties additionalProperties; + + + + Apple.$all({ + required this.cultivar, + required this.origin, + required this.additionalProperties, + + }); + + Apple({ + this.cultivar = const UndefinedWrapper + .undefined() +, + this.origin = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = AppleReflection.instance; + AppleReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Apple.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Apple clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/apple.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/apple.reflection.dart new file mode 100644 index 000000000000..0e1284b65427 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/apple.reflection.dart @@ -0,0 +1,188 @@ +// Model reflection + +part of 'apple.dart'; + + +//class reflection + +class AppleReflection extends ModelReflection { + static AppleReflection instanceGetter() => instance; + static const instance = AppleReflection._( + modelName: r'apple', + className: r'Apple', + xml: XmlReflection( +), + cultivarPart: PropertyReflection>( + dartName: r'cultivar', + nullable: false, + required: false, + oasName: r'cultivar', + oasType: r'string', + pattern: r'/^[a-zA-Z\\s]*$/', + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_cultivarGetter), + setter: FunctionWrapper2(_cultivarSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + originPart: PropertyReflection>( + dartName: r'origin', + nullable: false, + required: false, + oasName: r'origin', + oasType: r'string', + pattern: r'/^[A-Z\\s]*$/i', + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_originGetter), + setter: FunctionWrapper2(_originSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const AppleReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.cultivarPart, + required this.originPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> cultivarPart; + static UndefinedWrapper< + String +> _cultivarGetter(Apple parent) { + return parent.cultivar; + } + static void _cultivarSetter(Apple parent, UndefinedWrapper< + String +> value) { + parent.cultivar = value; + } + + final PropertyReflection> originPart; + static UndefinedWrapper< + String +> _originGetter(Apple parent) { + return parent.origin; + } + static void _originSetter(Apple parent, UndefinedWrapper< + String +> value) { + parent.origin = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + cultivarPart, +originPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Apple instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Apple instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Apple empty() { + return Apple( + ); + } + + @override + bool operator ==(Object other) { + return other is AppleReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/apple_req.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/apple_req.dart new file mode 100644 index 000000000000..d7ff66c0837e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/apple_req.dart @@ -0,0 +1,94 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'apple_req.reflection.dart'; + + +/// AppleReqMixin +/// +/// Properties: +/// * [cultivar] +/// * [mealy] +mixin AppleReqMixin on + $OpenApiObjectMixin { + + String + get cultivar; +UndefinedWrapper< + bool +> get mealy; + +} + +/// AppleReq +/// +/// Properties: +/// * [cultivar] +/// * [mealy] +class AppleReq with +$OpenApiObjectMixin, + +AppleReqMixin { + @override + + String + cultivar; + @override + UndefinedWrapper< + bool +> mealy; + + + + + + AppleReq.$all({ + required this.cultivar, + required this.mealy, + + + }); + + AppleReq({ + required this.cultivar , + this.mealy = const UndefinedWrapper + .undefined() +, + + + }); + + static const $reflection = AppleReqReflection.instance; + AppleReqReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory AppleReq.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + AppleReq clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/apple_req.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/apple_req.reflection.dart new file mode 100644 index 000000000000..f53b0db3e9d1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/apple_req.reflection.dart @@ -0,0 +1,164 @@ +// Model reflection + +part of 'apple_req.dart'; + + +//class reflection + +class AppleReqReflection extends ModelReflection { + static AppleReqReflection instanceGetter() => instance; + static const instance = AppleReqReflection._( + modelName: r'appleReq', + className: r'AppleReq', + xml: XmlReflection( +), + cultivarPart: PropertyReflection( + dartName: r'cultivar', + nullable: false, + required: true, + oasName: r'cultivar', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_cultivarGetter), + setter: FunctionWrapper2(_cultivarSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + mealyPart: PropertyReflection>( + dartName: r'mealy', + nullable: false, + required: false, + oasName: r'mealy', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mealyGetter), + setter: FunctionWrapper2(_mealySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + + + ); + const AppleReqReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.cultivarPart, + required this.mealyPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + }); + + final PropertyReflection cultivarPart; + static + String + _cultivarGetter(AppleReq parent) { + return parent.cultivar; + } + static void _cultivarSetter(AppleReq parent, + String + value) { + parent.cultivar = value; + } + + final PropertyReflection> mealyPart; + static UndefinedWrapper< + bool +> _mealyGetter(AppleReq parent) { + return parent.mealy; + } + static void _mealySetter(AppleReq parent, UndefinedWrapper< + bool +> value) { + parent.mealy = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + cultivarPart, +mealyPart, + ]; + + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + AppleReq empty() { + return AppleReq( + cultivar: cultivarPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is AppleReqReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_any_of.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_any_of.dart new file mode 100644 index 000000000000..4a97bff121bf --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_any_of.dart @@ -0,0 +1,91 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'array_any_of.reflection.dart'; + + +/// ArrayAnyOfMixin +mixin ArrayAnyOfMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + int +> get anyOf0; + UndefinedWrapper< + List< + + String +> +> get anyOf1; +} + +/// ArrayAnyOf +class ArrayAnyOf with +$OpenApiObjectMixin, + +ArrayAnyOfMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + int +> anyOf0; + + @override + UndefinedWrapper< + List< + + String +> +> anyOf1; + + + ArrayAnyOf.$all({ + required this.additionalProperties, + + required this.anyOf0, + required this.anyOf1, + }); + + ArrayAnyOf({ + AdditionalProperties? additionalProperties, + + this.anyOf0 = const UndefinedWrapper.undefined(), + + this.anyOf1 = const UndefinedWrapper.undefined(), + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ArrayAnyOfReflection.instance; + ArrayAnyOfReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory ArrayAnyOf.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ArrayAnyOf clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_any_of.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_any_of.reflection.dart new file mode 100644 index 000000000000..1321b3111f9b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_any_of.reflection.dart @@ -0,0 +1,272 @@ +// Model reflection + +part of 'array_any_of.dart'; + + +//class reflection + +class ArrayAnyOfReflection extends ModelReflection { + static ArrayAnyOfReflection instanceGetter() => instance; + static const instance = ArrayAnyOfReflection._( + modelName: r'ArrayAnyOf', + className: r'ArrayAnyOf', + xml: XmlReflection( +), + + + anyOf0Part: ArrayAnyOfAnyOf0Part( + parentReflectionGetter: instanceGetter, + ), + + anyOf1Part: ArrayAnyOfAnyOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ArrayAnyOfReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.anyOf0Part, + + required this.anyOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ArrayAnyOf instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ArrayAnyOf instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final ArrayAnyOfAnyOf0Part anyOf0Part; + + final ArrayAnyOfAnyOf1Part anyOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + anyOf0Part,anyOf1Part, + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ArrayAnyOf empty() { + return ArrayAnyOf( + ); + } + + @override + bool operator ==(Object other) { + return other is ArrayAnyOfReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + +class ArrayAnyOfAnyOf0Part extends AnyOfReflection { + + const ArrayAnyOfAnyOf0Part({ + required ArrayAnyOfReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, ArrayAnyOf> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + int +> _getter(ArrayAnyOf src) { + return src.anyOf0; +} +static void _setter(ArrayAnyOf src, UndefinedWrapper< + int +> value) { + src.anyOf0 = value; +} + +@override +UndefinedWrapperReflection< + int +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + + + ), +); + + UndefinedWrapper< + int +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} +class ArrayAnyOfAnyOf1Part extends AnyOfReflection +> { + + const ArrayAnyOfAnyOf1Part({ + required ArrayAnyOfReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1 +>, ArrayAnyOf> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2 +>> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + List< + + String +> +> _getter(ArrayAnyOf src) { + return src.anyOf1; +} +static void _setter(ArrayAnyOf src, UndefinedWrapper< + List< + + String +> +> value) { + src.anyOf1 = value; +} + +@override +UndefinedWrapperReflection< + List< + + String +> +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) + + ), +); + + UndefinedWrapper< + List< + + String +> +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_default.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_default.dart new file mode 100644 index 000000000000..1527f1770dc8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_default.dart @@ -0,0 +1,118 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'array_default.reflection.dart'; + + +/// ArrayDefaultMixin +/// +/// Properties: +/// * [withDefaultEmptyBracket] +/// * [withoutDefault] +mixin ArrayDefaultMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + List< + + String +> +> get withDefaultEmptyBracket; +UndefinedWrapper< + List< + + String +> +> get withoutDefault; + +} + +/// ArrayDefault +/// +/// Properties: +/// * [withDefaultEmptyBracket] +/// * [withoutDefault] +class ArrayDefault with +$OpenApiObjectMixin, + +ArrayDefaultMixin { + @override + UndefinedWrapper< + List< + + String +> +> withDefaultEmptyBracket; + @override + UndefinedWrapper< + List< + + String +> +> withoutDefault; + + AdditionalProperties additionalProperties; + + + + ArrayDefault.$all({ + required this.withDefaultEmptyBracket, + required this.withoutDefault, + required this.additionalProperties, + + }); + + ArrayDefault({ + this.withDefaultEmptyBracket = const UndefinedWrapper + ( + + [] + ) + +, + this.withoutDefault = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ArrayDefaultReflection.instance; + ArrayDefaultReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ArrayDefault.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ArrayDefault clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_default.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_default.reflection.dart new file mode 100644 index 000000000000..808222d60f94 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_default.reflection.dart @@ -0,0 +1,226 @@ +// Model reflection + +part of 'array_default.dart'; + + +//class reflection + +class ArrayDefaultReflection extends ModelReflection { + static ArrayDefaultReflection instanceGetter() => instance; + static const instance = ArrayDefaultReflection._( + modelName: r'ArrayDefault', + className: r'ArrayDefault', + xml: XmlReflection( +), + withDefaultEmptyBracketPart: PropertyReflection +>>( + dartName: r'withDefaultEmptyBracket', + nullable: false, + required: false, + oasName: r'WithDefaultEmptyBracket', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_withDefaultEmptyBracketGetter), + setter: FunctionWrapper2(_withDefaultEmptyBracketSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +), + ), + withoutDefaultPart: PropertyReflection +>>( + dartName: r'withoutDefault', + nullable: false, + required: false, + oasName: r'WithoutDefault', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_withoutDefaultGetter), + setter: FunctionWrapper2(_withoutDefaultSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ArrayDefaultReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.withDefaultEmptyBracketPart, + required this.withoutDefaultPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection +>> withDefaultEmptyBracketPart; + static UndefinedWrapper< + List< + + String +> +> _withDefaultEmptyBracketGetter(ArrayDefault parent) { + return parent.withDefaultEmptyBracket; + } + static void _withDefaultEmptyBracketSetter(ArrayDefault parent, UndefinedWrapper< + List< + + String +> +> value) { + parent.withDefaultEmptyBracket = value; + } + + final PropertyReflection +>> withoutDefaultPart; + static UndefinedWrapper< + List< + + String +> +> _withoutDefaultGetter(ArrayDefault parent) { + return parent.withoutDefault; + } + static void _withoutDefaultSetter(ArrayDefault parent, UndefinedWrapper< + List< + + String +> +> value) { + parent.withoutDefault = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + withDefaultEmptyBracketPart, +withoutDefaultPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ArrayDefault instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ArrayDefault instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ArrayDefault empty() { + return ArrayDefault( + ); + } + + @override + bool operator ==(Object other) { + return other is ArrayDefaultReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_array_of_number_only.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_array_of_number_only.dart new file mode 100644 index 000000000000..5f18f2e2ff4e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_array_of_number_only.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'array_of_array_of_number_only.reflection.dart'; + + +/// ArrayOfArrayOfNumberOnlyMixin +/// +/// Properties: +/// * [arrayArrayNumber] +mixin ArrayOfArrayOfNumberOnlyMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + List< + + List< + + num +> +> +> get arrayArrayNumber; + +} + +/// ArrayOfArrayOfNumberOnly +/// +/// Properties: +/// * [arrayArrayNumber] +class ArrayOfArrayOfNumberOnly with +$OpenApiObjectMixin, + +ArrayOfArrayOfNumberOnlyMixin { + @override + UndefinedWrapper< + List< + + List< + + num +> +> +> arrayArrayNumber; + + AdditionalProperties additionalProperties; + + + + ArrayOfArrayOfNumberOnly.$all({ + required this.arrayArrayNumber, + required this.additionalProperties, + + }); + + ArrayOfArrayOfNumberOnly({ + this.arrayArrayNumber = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ArrayOfArrayOfNumberOnlyReflection.instance; + ArrayOfArrayOfNumberOnlyReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ArrayOfArrayOfNumberOnly.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ArrayOfArrayOfNumberOnly clone() { + return $reflection.clone(this); + } +} + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_array_of_number_only.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_array_of_number_only.reflection.dart new file mode 100644 index 000000000000..144357947c7a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_array_of_number_only.reflection.dart @@ -0,0 +1,181 @@ +// Model reflection + +part of 'array_of_array_of_number_only.dart'; + + +//class reflection + +class ArrayOfArrayOfNumberOnlyReflection extends ModelReflection { + static ArrayOfArrayOfNumberOnlyReflection instanceGetter() => instance; + static const instance = ArrayOfArrayOfNumberOnlyReflection._( + modelName: r'ArrayOfArrayOfNumberOnly', + className: r'ArrayOfArrayOfNumberOnly', + xml: XmlReflection( +), + arrayArrayNumberPart: PropertyReflection +> +>>( + dartName: r'arrayArrayNumber', + nullable: false, + required: false, + oasName: r'ArrayArrayNumber', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayArrayNumberGetter), + setter: FunctionWrapper2(_arrayArrayNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +) +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ArrayOfArrayOfNumberOnlyReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.arrayArrayNumberPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection +> +>> arrayArrayNumberPart; + static UndefinedWrapper< + List< + + List< + + num +> +> +> _arrayArrayNumberGetter(ArrayOfArrayOfNumberOnly parent) { + return parent.arrayArrayNumber; + } + static void _arrayArrayNumberSetter(ArrayOfArrayOfNumberOnly parent, UndefinedWrapper< + List< + + List< + + num +> +> +> value) { + parent.arrayArrayNumber = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + arrayArrayNumberPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ArrayOfArrayOfNumberOnly instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ArrayOfArrayOfNumberOnly instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ArrayOfArrayOfNumberOnly empty() { + return ArrayOfArrayOfNumberOnly( + ); + } + + @override + bool operator ==(Object other) { + return other is ArrayOfArrayOfNumberOnlyReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of.dart new file mode 100644 index 000000000000..f8ecbed46d1e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of.dart @@ -0,0 +1,120 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'array_of_inline_all_of.reflection.dart'; + + +/// ArrayOfInlineAllOfMixin +/// +/// Properties: +/// * [id] +/// * [name] +/// * [arrayAllofDogProperty] +mixin ArrayOfInlineAllOfMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; + + String + get name; +UndefinedWrapper< + List< + + ArrayOfInlineAllOfArrayAllofDogPropertyInner +> +> get arrayAllofDogProperty; + +} + +/// ArrayOfInlineAllOf +/// +/// Properties: +/// * [id] +/// * [name] +/// * [arrayAllofDogProperty] +class ArrayOfInlineAllOf with +$OpenApiObjectMixin, + +ArrayOfInlineAllOfMixin { + @override + UndefinedWrapper< + int +> id; + @override + + String + name; + @override + UndefinedWrapper< + List< + + ArrayOfInlineAllOfArrayAllofDogPropertyInner +> +> arrayAllofDogProperty; + + AdditionalProperties additionalProperties; + + + + ArrayOfInlineAllOf.$all({ + required this.id, + required this.name, + required this.arrayAllofDogProperty, + required this.additionalProperties, + + }); + + ArrayOfInlineAllOf({ + this.id = const UndefinedWrapper + .undefined() +, +required this.name , + this.arrayAllofDogProperty = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ArrayOfInlineAllOfReflection.instance; + ArrayOfInlineAllOfReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ArrayOfInlineAllOf.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ArrayOfInlineAllOf clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of.reflection.dart new file mode 100644 index 000000000000..50488380e248 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of.reflection.dart @@ -0,0 +1,253 @@ +// Model reflection + +part of 'array_of_inline_all_of.dart'; + + +//class reflection + +class ArrayOfInlineAllOfReflection extends ModelReflection { + static ArrayOfInlineAllOfReflection instanceGetter() => instance; + static const instance = ArrayOfInlineAllOfReflection._( + modelName: r'ArrayOfInlineAllOf', + className: r'ArrayOfInlineAllOf', + xml: XmlReflection( +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + arrayAllofDogPropertyPart: PropertyReflection +>>( + dartName: r'arrayAllofDogProperty', + nullable: false, + required: false, + oasName: r'array_allof_dog_property', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayAllofDogPropertyGetter), + setter: FunctionWrapper2(_arrayAllofDogPropertySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ArrayOfInlineAllOfArrayAllofDogPropertyInner.$reflection + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ArrayOfInlineAllOfReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.namePart, + required this.arrayAllofDogPropertyPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(ArrayOfInlineAllOf parent) { + return parent.id; + } + static void _idSetter(ArrayOfInlineAllOf parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection namePart; + static + String + _nameGetter(ArrayOfInlineAllOf parent) { + return parent.name; + } + static void _nameSetter(ArrayOfInlineAllOf parent, + String + value) { + parent.name = value; + } + + final PropertyReflection +>> arrayAllofDogPropertyPart; + static UndefinedWrapper< + List< + + ArrayOfInlineAllOfArrayAllofDogPropertyInner +> +> _arrayAllofDogPropertyGetter(ArrayOfInlineAllOf parent) { + return parent.arrayAllofDogProperty; + } + static void _arrayAllofDogPropertySetter(ArrayOfInlineAllOf parent, UndefinedWrapper< + List< + + ArrayOfInlineAllOfArrayAllofDogPropertyInner +> +> value) { + parent.arrayAllofDogProperty = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +namePart, +arrayAllofDogPropertyPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ArrayOfInlineAllOf instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ArrayOfInlineAllOf instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ArrayOfInlineAllOf empty() { + return ArrayOfInlineAllOf( + name: namePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is ArrayOfInlineAllOfReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of_array_allof_dog_property_inner.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of_array_allof_dog_property_inner.dart new file mode 100644 index 000000000000..d919132fedfd --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of_array_allof_dog_property_inner.dart @@ -0,0 +1,99 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'array_of_inline_all_of_array_allof_dog_property_inner.reflection.dart'; + + +/// ArrayOfInlineAllOfArrayAllofDogPropertyInnerMixin +/// +/// Properties: +/// * [breed] +/// * [color] +mixin ArrayOfInlineAllOfArrayAllofDogPropertyInnerMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get breed; +UndefinedWrapper< + String +> get color; + +} + +/// ArrayOfInlineAllOfArrayAllofDogPropertyInner +/// +/// Properties: +/// * [breed] +/// * [color] +class ArrayOfInlineAllOfArrayAllofDogPropertyInner with +$OpenApiObjectMixin, + +ArrayOfInlineAllOfArrayAllofDogPropertyInnerMixin { + @override + UndefinedWrapper< + String +> breed; + @override + UndefinedWrapper< + String +> color; + + AdditionalProperties additionalProperties; + + + + ArrayOfInlineAllOfArrayAllofDogPropertyInner.$all({ + required this.breed, + required this.color, + required this.additionalProperties, + + }); + + ArrayOfInlineAllOfArrayAllofDogPropertyInner({ + this.breed = const UndefinedWrapper + .undefined() +, + this.color = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ArrayOfInlineAllOfArrayAllofDogPropertyInnerReflection.instance; + ArrayOfInlineAllOfArrayAllofDogPropertyInnerReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory ArrayOfInlineAllOfArrayAllofDogPropertyInner.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ArrayOfInlineAllOfArrayAllofDogPropertyInner clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of_array_allof_dog_property_inner.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of_array_allof_dog_property_inner.reflection.dart new file mode 100644 index 000000000000..fab42e58b237 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_inline_all_of_array_allof_dog_property_inner.reflection.dart @@ -0,0 +1,196 @@ +// Model reflection + +part of 'array_of_inline_all_of_array_allof_dog_property_inner.dart'; + + +//class reflection + +class ArrayOfInlineAllOfArrayAllofDogPropertyInnerReflection extends ModelReflection { + static ArrayOfInlineAllOfArrayAllofDogPropertyInnerReflection instanceGetter() => instance; + static const instance = ArrayOfInlineAllOfArrayAllofDogPropertyInnerReflection._( + modelName: r'ArrayOfInlineAllOf_array_allof_dog_property_inner', + className: r'ArrayOfInlineAllOfArrayAllofDogPropertyInner', + xml: XmlReflection( +), + breedPart: PropertyReflection>( + dartName: r'breed', + nullable: false, + required: false, + oasName: r'breed', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_breedGetter), + setter: FunctionWrapper2(_breedSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + colorPart: PropertyReflection>( + dartName: r'color', + nullable: false, + required: false, + oasName: r'color', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_colorGetter), + setter: FunctionWrapper2(_colorSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ArrayOfInlineAllOfArrayAllofDogPropertyInnerReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.breedPart, + required this.colorPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> breedPart; + static UndefinedWrapper< + String +> _breedGetter(ArrayOfInlineAllOfArrayAllofDogPropertyInner parent) { + return parent.breed; + } + static void _breedSetter(ArrayOfInlineAllOfArrayAllofDogPropertyInner parent, UndefinedWrapper< + String +> value) { + parent.breed = value; + } + + final PropertyReflection> colorPart; + static UndefinedWrapper< + String +> _colorGetter(ArrayOfInlineAllOfArrayAllofDogPropertyInner parent) { + return parent.color; + } + static void _colorSetter(ArrayOfInlineAllOfArrayAllofDogPropertyInner parent, UndefinedWrapper< + String +> value) { + parent.color = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + breedPart, +colorPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ArrayOfInlineAllOfArrayAllofDogPropertyInner instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ArrayOfInlineAllOfArrayAllofDogPropertyInner instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ArrayOfInlineAllOfArrayAllofDogPropertyInner empty() { + return ArrayOfInlineAllOfArrayAllofDogPropertyInner( + ); + } + + @override + bool operator ==(Object other) { + return other is ArrayOfInlineAllOfArrayAllofDogPropertyInnerReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_number_only.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_number_only.dart new file mode 100644 index 000000000000..2bfa3f195345 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_number_only.dart @@ -0,0 +1,90 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'array_of_number_only.reflection.dart'; + + +/// ArrayOfNumberOnlyMixin +/// +/// Properties: +/// * [arrayNumber] +mixin ArrayOfNumberOnlyMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + List< + + num +> +> get arrayNumber; + +} + +/// ArrayOfNumberOnly +/// +/// Properties: +/// * [arrayNumber] +class ArrayOfNumberOnly with +$OpenApiObjectMixin, + +ArrayOfNumberOnlyMixin { + @override + UndefinedWrapper< + List< + + num +> +> arrayNumber; + + AdditionalProperties additionalProperties; + + + + ArrayOfNumberOnly.$all({ + required this.arrayNumber, + required this.additionalProperties, + + }); + + ArrayOfNumberOnly({ + this.arrayNumber = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ArrayOfNumberOnlyReflection.instance; + ArrayOfNumberOnlyReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ArrayOfNumberOnly.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ArrayOfNumberOnly clone() { + return $reflection.clone(this); + } +} + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_number_only.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_number_only.reflection.dart new file mode 100644 index 000000000000..e5f2a6db77eb --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_of_number_only.reflection.dart @@ -0,0 +1,162 @@ +// Model reflection + +part of 'array_of_number_only.dart'; + + +//class reflection + +class ArrayOfNumberOnlyReflection extends ModelReflection { + static ArrayOfNumberOnlyReflection instanceGetter() => instance; + static const instance = ArrayOfNumberOnlyReflection._( + modelName: r'ArrayOfNumberOnly', + className: r'ArrayOfNumberOnly', + xml: XmlReflection( +), + arrayNumberPart: PropertyReflection +>>( + dartName: r'arrayNumber', + nullable: false, + required: false, + oasName: r'ArrayNumber', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayNumberGetter), + setter: FunctionWrapper2(_arrayNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ArrayOfNumberOnlyReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.arrayNumberPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection +>> arrayNumberPart; + static UndefinedWrapper< + List< + + num +> +> _arrayNumberGetter(ArrayOfNumberOnly parent) { + return parent.arrayNumber; + } + static void _arrayNumberSetter(ArrayOfNumberOnly parent, UndefinedWrapper< + List< + + num +> +> value) { + parent.arrayNumber = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + arrayNumberPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ArrayOfNumberOnly instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ArrayOfNumberOnly instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ArrayOfNumberOnly empty() { + return ArrayOfNumberOnly( + ); + } + + @override + bool operator ==(Object other) { + return other is ArrayOfNumberOnlyReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_one_of.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_one_of.dart new file mode 100644 index 000000000000..0328d23fbbab --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_one_of.dart @@ -0,0 +1,94 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'array_one_of.reflection.dart'; + + +/// ArrayOneOfMixin +mixin ArrayOneOfMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + int +> get oneOf0; + UndefinedWrapper< + List< + + String +> +> get oneOf1; +} + +/// ArrayOneOf +class ArrayOneOf with +$OpenApiObjectMixin, + +ArrayOneOfMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + int +> oneOf0; + + @override + UndefinedWrapper< + List< + + String +> +> oneOf1; + + + ArrayOneOf.$all({ + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + ArrayOneOf({ + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ArrayOneOfReflection.instance; + ArrayOneOfReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory ArrayOneOf.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ArrayOneOf clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_one_of.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_one_of.reflection.dart new file mode 100644 index 000000000000..86b13e303b6e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_one_of.reflection.dart @@ -0,0 +1,290 @@ +// Model reflection + +part of 'array_one_of.dart'; + + +//class reflection + +class ArrayOneOfReflection extends ModelReflection { + static ArrayOneOfReflection instanceGetter() => instance; + static const instance = ArrayOneOfReflection._( + modelName: r'ArrayOneOf', + className: r'ArrayOneOf', + xml: XmlReflection( +), + + + oneOf0Part: ArrayOneOfOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: ArrayOneOfOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ArrayOneOfReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ArrayOneOf instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ArrayOneOf instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final ArrayOneOfOneOf0Part oneOf0Part; + + final ArrayOneOfOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ArrayOneOf empty() { + return ArrayOneOf( + ); + } + + @override + bool operator ==(Object other) { + return other is ArrayOneOfReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class ArrayOneOfOneOf0Part extends OneOfReflection { + + const ArrayOneOfOneOf0Part({ + required ArrayOneOfReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, ArrayOneOf> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + int +> _getter(ArrayOneOf src) { + return src.oneOf0; +} +static void _setter(ArrayOneOf src, UndefinedWrapper< + int +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + int +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + + + ), +); + + UndefinedWrapper< + int +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class ArrayOneOfOneOf1Part extends OneOfReflection +> { + + const ArrayOneOfOneOf1Part({ + required ArrayOneOfReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1 +>, ArrayOneOf> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2 +>> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + List< + + String +> +> _getter(ArrayOneOf src) { + return src.oneOf1; +} +static void _setter(ArrayOneOf src, UndefinedWrapper< + List< + + String +> +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + List< + + String +> +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) + + ), +); + + UndefinedWrapper< + List< + + String +> +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_test.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_test.dart new file mode 100644 index 000000000000..f4b0f33f3fcf --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_test.dart @@ -0,0 +1,154 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'array_test.reflection.dart'; + + +/// ArrayTestMixin +/// +/// Properties: +/// * [arrayOfString] +/// * [arrayArrayOfInteger] +/// * [arrayArrayOfModel] +mixin ArrayTestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + List< + + String +> +> get arrayOfString; +UndefinedWrapper< + List< + + List< + + int +> +> +> get arrayArrayOfInteger; +UndefinedWrapper< + List< + + List< + + ReadOnlyFirst +> +> +> get arrayArrayOfModel; + +} + +/// ArrayTest +/// +/// Properties: +/// * [arrayOfString] +/// * [arrayArrayOfInteger] +/// * [arrayArrayOfModel] +class ArrayTest with +$OpenApiObjectMixin, + +ArrayTestMixin { + @override + UndefinedWrapper< + List< + + String +> +> arrayOfString; + @override + UndefinedWrapper< + List< + + List< + + int +> +> +> arrayArrayOfInteger; + @override + UndefinedWrapper< + List< + + List< + + ReadOnlyFirst +> +> +> arrayArrayOfModel; + + AdditionalProperties additionalProperties; + + + + ArrayTest.$all({ + required this.arrayOfString, + required this.arrayArrayOfInteger, + required this.arrayArrayOfModel, + required this.additionalProperties, + + }); + + ArrayTest({ + this.arrayOfString = const UndefinedWrapper + .undefined() +, + this.arrayArrayOfInteger = const UndefinedWrapper + .undefined() +, + this.arrayArrayOfModel = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ArrayTestReflection.instance; + ArrayTestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ArrayTest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ArrayTest clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/array_test.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_test.reflection.dart new file mode 100644 index 000000000000..f2c4ca778cb0 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/array_test.reflection.dart @@ -0,0 +1,328 @@ +// Model reflection + +part of 'array_test.dart'; + + +//class reflection + +class ArrayTestReflection extends ModelReflection { + static ArrayTestReflection instanceGetter() => instance; + static const instance = ArrayTestReflection._( + modelName: r'ArrayTest', + className: r'ArrayTest', + xml: XmlReflection( +), + arrayOfStringPart: PropertyReflection +>>( + dartName: r'arrayOfString', + nullable: false, + required: false, + oasName: r'array_of_string', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayOfStringGetter), + setter: FunctionWrapper2(_arrayOfStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +), + ), + arrayArrayOfIntegerPart: PropertyReflection +> +>>( + dartName: r'arrayArrayOfInteger', + nullable: false, + required: false, + oasName: r'array_array_of_integer', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayArrayOfIntegerGetter), + setter: FunctionWrapper2(_arrayArrayOfIntegerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +) +, +) +), + ), + arrayArrayOfModelPart: PropertyReflection +> +>>( + dartName: r'arrayArrayOfModel', + nullable: false, + required: false, + oasName: r'array_array_of_model', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayArrayOfModelGetter), + setter: FunctionWrapper2(_arrayArrayOfModelSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ReadOnlyFirst.$reflection + +, +) +) +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ArrayTestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.arrayOfStringPart, + required this.arrayArrayOfIntegerPart, + required this.arrayArrayOfModelPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection +>> arrayOfStringPart; + static UndefinedWrapper< + List< + + String +> +> _arrayOfStringGetter(ArrayTest parent) { + return parent.arrayOfString; + } + static void _arrayOfStringSetter(ArrayTest parent, UndefinedWrapper< + List< + + String +> +> value) { + parent.arrayOfString = value; + } + + final PropertyReflection +> +>> arrayArrayOfIntegerPart; + static UndefinedWrapper< + List< + + List< + + int +> +> +> _arrayArrayOfIntegerGetter(ArrayTest parent) { + return parent.arrayArrayOfInteger; + } + static void _arrayArrayOfIntegerSetter(ArrayTest parent, UndefinedWrapper< + List< + + List< + + int +> +> +> value) { + parent.arrayArrayOfInteger = value; + } + + final PropertyReflection +> +>> arrayArrayOfModelPart; + static UndefinedWrapper< + List< + + List< + + ReadOnlyFirst +> +> +> _arrayArrayOfModelGetter(ArrayTest parent) { + return parent.arrayArrayOfModel; + } + static void _arrayArrayOfModelSetter(ArrayTest parent, UndefinedWrapper< + List< + + List< + + ReadOnlyFirst +> +> +> value) { + parent.arrayArrayOfModel = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + arrayOfStringPart, +arrayArrayOfIntegerPart, +arrayArrayOfModelPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ArrayTest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ArrayTest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ArrayTest empty() { + return ArrayTest( + ); + } + + @override + bool operator ==(Object other) { + return other is ArrayTestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/banana.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/banana.dart new file mode 100644 index 000000000000..8608f82de476 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/banana.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'banana.reflection.dart'; + + +/// BananaMixin +/// +/// Properties: +/// * [lengthCm] +mixin BananaMixin on + $OpenApiObjectMixin { + + num + get lengthCm; + +} + +/// Banana +/// +/// Properties: +/// * [lengthCm] +class Banana with +$OpenApiObjectMixin, + +BananaMixin { + @override + + num + lengthCm; + + AdditionalProperties additionalProperties; + + + + Banana.$all({ + required this.lengthCm, + required this.additionalProperties, + + }); + + Banana({ + required this.lengthCm , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = BananaReflection.instance; + BananaReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Banana.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Banana clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/banana.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/banana.reflection.dart new file mode 100644 index 000000000000..dc5650225fdd --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/banana.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'banana.dart'; + + +//class reflection + +class BananaReflection extends ModelReflection { + static BananaReflection instanceGetter() => instance; + static const instance = BananaReflection._( + modelName: r'banana', + className: r'Banana', + xml: XmlReflection( +), + lengthCmPart: PropertyReflection( + dartName: r'lengthCm', + nullable: false, + required: true, + oasName: r'lengthCm', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_lengthCmGetter), + setter: FunctionWrapper2(_lengthCmSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const BananaReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.lengthCmPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection lengthCmPart; + static + num + _lengthCmGetter(Banana parent) { + return parent.lengthCm; + } + static void _lengthCmSetter(Banana parent, + num + value) { + parent.lengthCm = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + lengthCmPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Banana instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Banana instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Banana empty() { + return Banana( + lengthCm: lengthCmPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is BananaReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/banana_req.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/banana_req.dart new file mode 100644 index 000000000000..a14bcbdee50e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/banana_req.dart @@ -0,0 +1,94 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'banana_req.reflection.dart'; + + +/// BananaReqMixin +/// +/// Properties: +/// * [lengthCm] +/// * [sweet] +mixin BananaReqMixin on + $OpenApiObjectMixin { + + num + get lengthCm; +UndefinedWrapper< + bool +> get sweet; + +} + +/// BananaReq +/// +/// Properties: +/// * [lengthCm] +/// * [sweet] +class BananaReq with +$OpenApiObjectMixin, + +BananaReqMixin { + @override + + num + lengthCm; + @override + UndefinedWrapper< + bool +> sweet; + + + + + + BananaReq.$all({ + required this.lengthCm, + required this.sweet, + + + }); + + BananaReq({ + required this.lengthCm , + this.sweet = const UndefinedWrapper + .undefined() +, + + + }); + + static const $reflection = BananaReqReflection.instance; + BananaReqReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory BananaReq.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + BananaReq clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/banana_req.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/banana_req.reflection.dart new file mode 100644 index 000000000000..d4b6e6767150 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/banana_req.reflection.dart @@ -0,0 +1,164 @@ +// Model reflection + +part of 'banana_req.dart'; + + +//class reflection + +class BananaReqReflection extends ModelReflection { + static BananaReqReflection instanceGetter() => instance; + static const instance = BananaReqReflection._( + modelName: r'bananaReq', + className: r'BananaReq', + xml: XmlReflection( +), + lengthCmPart: PropertyReflection( + dartName: r'lengthCm', + nullable: false, + required: true, + oasName: r'lengthCm', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_lengthCmGetter), + setter: FunctionWrapper2(_lengthCmSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +, + ), + sweetPart: PropertyReflection>( + dartName: r'sweet', + nullable: false, + required: false, + oasName: r'sweet', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_sweetGetter), + setter: FunctionWrapper2(_sweetSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + + + ); + const BananaReqReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.lengthCmPart, + required this.sweetPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + }); + + final PropertyReflection lengthCmPart; + static + num + _lengthCmGetter(BananaReq parent) { + return parent.lengthCm; + } + static void _lengthCmSetter(BananaReq parent, + num + value) { + parent.lengthCm = value; + } + + final PropertyReflection> sweetPart; + static UndefinedWrapper< + bool +> _sweetGetter(BananaReq parent) { + return parent.sweet; + } + static void _sweetSetter(BananaReq parent, UndefinedWrapper< + bool +> value) { + parent.sweet = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + lengthCmPart, +sweetPart, + ]; + + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + BananaReq empty() { + return BananaReq( + lengthCm: lengthCmPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is BananaReqReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/basque_pig.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/basque_pig.dart new file mode 100644 index 000000000000..b3f06b8fc71a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/basque_pig.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'basque_pig.reflection.dart'; + + +/// BasquePigMixin +/// +/// Properties: +/// * [className] +mixin BasquePigMixin on + $OpenApiObjectMixin { + + String + get className; + +} + +/// BasquePig +/// +/// Properties: +/// * [className] +class BasquePig with +$OpenApiObjectMixin, + +BasquePigMixin { + @override + + String + className; + + AdditionalProperties additionalProperties; + + + + BasquePig.$all({ + required this.className, + required this.additionalProperties, + + }); + + BasquePig({ + required this.className , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = BasquePigReflection.instance; + BasquePigReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory BasquePig.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + BasquePig clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/basque_pig.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/basque_pig.reflection.dart new file mode 100644 index 000000000000..22abf428d790 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/basque_pig.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'basque_pig.dart'; + + +//class reflection + +class BasquePigReflection extends ModelReflection { + static BasquePigReflection instanceGetter() => instance; + static const instance = BasquePigReflection._( + modelName: r'BasquePig', + className: r'BasquePig', + xml: XmlReflection( +), + classNamePart: PropertyReflection( + dartName: r'className', + nullable: false, + required: true, + oasName: r'className', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_classNameGetter), + setter: FunctionWrapper2(_classNameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const BasquePigReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.classNamePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection classNamePart; + static + String + _classNameGetter(BasquePig parent) { + return parent.className; + } + static void _classNameSetter(BasquePig parent, + String + value) { + parent.className = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + classNamePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(BasquePig instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(BasquePig instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + BasquePig empty() { + return BasquePig( + className: classNamePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is BasquePigReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/capitalization.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/capitalization.dart new file mode 100644 index 000000000000..2436a25b1ab2 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/capitalization.dart @@ -0,0 +1,162 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'capitalization.reflection.dart'; + + +/// CapitalizationMixin +/// +/// Properties: +/// * [smallCamel] +/// * [capitalCamel] +/// * [smallSnake] +/// * [capitalSnake] +/// * [scAETHFlowPoints] +/// * [ATT_NAME] - Name of the pet +mixin CapitalizationMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get smallCamel; +UndefinedWrapper< + String +> get capitalCamel; +UndefinedWrapper< + String +> get smallSnake; +UndefinedWrapper< + String +> get capitalSnake; +UndefinedWrapper< + String +> get scAETHFlowPoints; +UndefinedWrapper< + String +> get ATT_NAME; + +} + +/// Capitalization +/// +/// Properties: +/// * [smallCamel] +/// * [capitalCamel] +/// * [smallSnake] +/// * [capitalSnake] +/// * [scAETHFlowPoints] +/// * [ATT_NAME] - Name of the pet +class Capitalization with +$OpenApiObjectMixin, + +CapitalizationMixin { + @override + UndefinedWrapper< + String +> smallCamel; + @override + UndefinedWrapper< + String +> capitalCamel; + @override + UndefinedWrapper< + String +> smallSnake; + @override + UndefinedWrapper< + String +> capitalSnake; + @override + UndefinedWrapper< + String +> scAETHFlowPoints; + @override + UndefinedWrapper< + String +> ATT_NAME; + + AdditionalProperties additionalProperties; + + + + Capitalization.$all({ + required this.smallCamel, + required this.capitalCamel, + required this.smallSnake, + required this.capitalSnake, + required this.scAETHFlowPoints, + required this.ATT_NAME, + required this.additionalProperties, + + }); + + Capitalization({ + this.smallCamel = const UndefinedWrapper + .undefined() +, + this.capitalCamel = const UndefinedWrapper + .undefined() +, + this.smallSnake = const UndefinedWrapper + .undefined() +, + this.capitalSnake = const UndefinedWrapper + .undefined() +, + this.scAETHFlowPoints = const UndefinedWrapper + .undefined() +, + this.ATT_NAME = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = CapitalizationReflection.instance; + CapitalizationReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Capitalization.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Capitalization clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/capitalization.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/capitalization.reflection.dart new file mode 100644 index 000000000000..f410a02927fe --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/capitalization.reflection.dart @@ -0,0 +1,368 @@ +// Model reflection + +part of 'capitalization.dart'; + + +//class reflection + +class CapitalizationReflection extends ModelReflection { + static CapitalizationReflection instanceGetter() => instance; + static const instance = CapitalizationReflection._( + modelName: r'Capitalization', + className: r'Capitalization', + xml: XmlReflection( +), + smallCamelPart: PropertyReflection>( + dartName: r'smallCamel', + nullable: false, + required: false, + oasName: r'smallCamel', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_smallCamelGetter), + setter: FunctionWrapper2(_smallCamelSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + capitalCamelPart: PropertyReflection>( + dartName: r'capitalCamel', + nullable: false, + required: false, + oasName: r'CapitalCamel', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_capitalCamelGetter), + setter: FunctionWrapper2(_capitalCamelSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + smallSnakePart: PropertyReflection>( + dartName: r'smallSnake', + nullable: false, + required: false, + oasName: r'small_Snake', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_smallSnakeGetter), + setter: FunctionWrapper2(_smallSnakeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + capitalSnakePart: PropertyReflection>( + dartName: r'capitalSnake', + nullable: false, + required: false, + oasName: r'Capital_Snake', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_capitalSnakeGetter), + setter: FunctionWrapper2(_capitalSnakeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + scAETHFlowPointsPart: PropertyReflection>( + dartName: r'scAETHFlowPoints', + nullable: false, + required: false, + oasName: r'SCA_ETH_Flow_Points', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_scAETHFlowPointsGetter), + setter: FunctionWrapper2(_scAETHFlowPointsSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + ATT_NAMEPart: PropertyReflection>( + dartName: r'ATT_NAME', + nullable: false, + required: false, + oasName: r'ATT_NAME', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_ATT_NAMEGetter), + setter: FunctionWrapper2(_ATT_NAMESetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const CapitalizationReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.smallCamelPart, + required this.capitalCamelPart, + required this.smallSnakePart, + required this.capitalSnakePart, + required this.scAETHFlowPointsPart, + required this.ATT_NAMEPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> smallCamelPart; + static UndefinedWrapper< + String +> _smallCamelGetter(Capitalization parent) { + return parent.smallCamel; + } + static void _smallCamelSetter(Capitalization parent, UndefinedWrapper< + String +> value) { + parent.smallCamel = value; + } + + final PropertyReflection> capitalCamelPart; + static UndefinedWrapper< + String +> _capitalCamelGetter(Capitalization parent) { + return parent.capitalCamel; + } + static void _capitalCamelSetter(Capitalization parent, UndefinedWrapper< + String +> value) { + parent.capitalCamel = value; + } + + final PropertyReflection> smallSnakePart; + static UndefinedWrapper< + String +> _smallSnakeGetter(Capitalization parent) { + return parent.smallSnake; + } + static void _smallSnakeSetter(Capitalization parent, UndefinedWrapper< + String +> value) { + parent.smallSnake = value; + } + + final PropertyReflection> capitalSnakePart; + static UndefinedWrapper< + String +> _capitalSnakeGetter(Capitalization parent) { + return parent.capitalSnake; + } + static void _capitalSnakeSetter(Capitalization parent, UndefinedWrapper< + String +> value) { + parent.capitalSnake = value; + } + + final PropertyReflection> scAETHFlowPointsPart; + static UndefinedWrapper< + String +> _scAETHFlowPointsGetter(Capitalization parent) { + return parent.scAETHFlowPoints; + } + static void _scAETHFlowPointsSetter(Capitalization parent, UndefinedWrapper< + String +> value) { + parent.scAETHFlowPoints = value; + } + + final PropertyReflection> ATT_NAMEPart; + static UndefinedWrapper< + String +> _ATT_NAMEGetter(Capitalization parent) { + return parent.ATT_NAME; + } + static void _ATT_NAMESetter(Capitalization parent, UndefinedWrapper< + String +> value) { + parent.ATT_NAME = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + smallCamelPart, +capitalCamelPart, +smallSnakePart, +capitalSnakePart, +scAETHFlowPointsPart, +ATT_NAMEPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Capitalization instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Capitalization instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Capitalization empty() { + return Capitalization( + ); + } + + @override + bool operator ==(Object other) { + return other is CapitalizationReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/cat.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/cat.dart new file mode 100644 index 000000000000..020d2f37b555 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/cat.dart @@ -0,0 +1,103 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'cat.reflection.dart'; + + +/// CatMixin +/// +/// Properties: +/// * [declawed] +mixin CatMixin on + AnimalMixin, $OpenApiObjectMixin { + UndefinedWrapper< + bool +> get declawed; + +} + +/// Cat +/// +/// Properties: +/// * [color] +/// * [declawed] +/// * [className] +class Cat with +$OpenApiObjectMixin, +AnimalMixin, +CatMixin { + @override + UndefinedWrapper< + String +> color; + @override + UndefinedWrapper< + bool +> declawed; + @override + + String + className; + + AdditionalProperties additionalProperties; + + + + Cat.$all({ + required this.color, + required this.declawed, + required this.className, + required this.additionalProperties, + + }); + + Cat({ + this.color = const UndefinedWrapper + ( + + 'red' + ) + +, + this.declawed = const UndefinedWrapper + .undefined() +, +required this.className , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = CatReflection.instance; + CatReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory Cat.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Cat clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/cat.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/cat.reflection.dart new file mode 100644 index 000000000000..e1e250d79721 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/cat.reflection.dart @@ -0,0 +1,254 @@ +// Model reflection + +part of 'cat.dart'; + + +//class reflection + +class CatReflection extends ModelReflection { + static CatReflection instanceGetter() => instance; + static const instance = CatReflection._( + modelName: r'Cat', + className: r'Cat', + xml: XmlReflection( +), + colorPart: PropertyReflection>( + dartName: r'color', + nullable: false, + required: false, + oasName: r'color', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_colorGetter), + setter: FunctionWrapper2(_colorSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + declawedPart: PropertyReflection>( + dartName: r'declawed', + nullable: false, + required: false, + oasName: r'declawed', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_declawedGetter), + setter: FunctionWrapper2(_declawedSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + classNamePart: PropertyReflection( + dartName: r'className', + nullable: false, + required: true, + oasName: r'className', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_classNameGetter), + setter: FunctionWrapper2(_classNameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + discriminatorKey: r'className', + discriminatorImplicitMappings: const { + r'Animal': AnimalReflection.instance, + }, + discriminatorMappings: const { + }, + allOfAnimalPart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: AnimalReflection.instance, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const CatReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.colorPart, + required this.declawedPart, + required this.classNamePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfAnimalPart, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> colorPart; + static UndefinedWrapper< + String +> _colorGetter(Cat parent) { + return parent.color; + } + static void _colorSetter(Cat parent, UndefinedWrapper< + String +> value) { + parent.color = value; + } + + final PropertyReflection> declawedPart; + static UndefinedWrapper< + bool +> _declawedGetter(Cat parent) { + return parent.declawed; + } + static void _declawedSetter(Cat parent, UndefinedWrapper< + bool +> value) { + parent.declawed = value; + } + + final PropertyReflection classNamePart; + static + String + _classNameGetter(Cat parent) { + return parent.className; + } + static void _classNameSetter(Cat parent, + String + value) { + parent.className = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + colorPart, +declawedPart, +classNamePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Cat instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Cat instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + final AllOfReflection allOfAnimalPart; + + + + @override + List> get allOfs => [ + allOfAnimalPart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Cat empty() { + return Cat( + className: classNamePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is CatReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/category.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/category.dart new file mode 100644 index 000000000000..cb3632c2f3a0 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/category.dart @@ -0,0 +1,100 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'category.reflection.dart'; + + +/// CategoryMixin +/// +/// Properties: +/// * [id] +/// * [name] +mixin CategoryMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; + + String + get name; + +} + +/// Category +/// +/// Properties: +/// * [id] +/// * [name] +class Category with +$OpenApiObjectMixin, + +CategoryMixin { + @override + UndefinedWrapper< + int +> id; + @override + + String + name; + + AdditionalProperties additionalProperties; + + + + Category.$all({ + required this.id, + required this.name, + required this.additionalProperties, + + }); + + Category({ + this.id = const UndefinedWrapper + .undefined() +, + this.name = + + 'default-name' + +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = CategoryReflection.instance; + CategoryReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Category.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Category clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/category.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/category.reflection.dart new file mode 100644 index 000000000000..fcfc3ee8d655 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/category.reflection.dart @@ -0,0 +1,190 @@ +// Model reflection + +part of 'category.dart'; + + +//class reflection + +class CategoryReflection extends ModelReflection { + static CategoryReflection instanceGetter() => instance; + static const instance = CategoryReflection._( + modelName: r'Category', + className: r'Category', + xml: XmlReflection( + xmlName: r'Category', +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const CategoryReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.namePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(Category parent) { + return parent.id; + } + static void _idSetter(Category parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection namePart; + static + String + _nameGetter(Category parent) { + return parent.name; + } + static void _nameSetter(Category parent, + String + value) { + parent.name = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +namePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Category instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Category instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Category empty() { + return Category( + name: namePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is CategoryReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/class_model.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/class_model.dart new file mode 100644 index 000000000000..b2dce0bf674b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/class_model.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'class_model.reflection.dart'; + + +/// Model for testing model with \"_class\" property +/// +/// Properties: +/// * [propertyClass] +mixin ClassModelMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get propertyClass; + +} + +/// Model for testing model with \"_class\" property +/// +/// Properties: +/// * [propertyClass] +class ClassModel with +$OpenApiObjectMixin, + +ClassModelMixin { + @override + UndefinedWrapper< + String +> propertyClass; + + AdditionalProperties additionalProperties; + + + + ClassModel.$all({ + required this.propertyClass, + required this.additionalProperties, + + }); + + ClassModel({ + this.propertyClass = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ClassModelReflection.instance; + ClassModelReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ClassModel.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ClassModel clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/class_model.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/class_model.reflection.dart new file mode 100644 index 000000000000..1de291db7835 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/class_model.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'class_model.dart'; + + +//class reflection + +class ClassModelReflection extends ModelReflection { + static ClassModelReflection instanceGetter() => instance; + static const instance = ClassModelReflection._( + modelName: r'ClassModel', + className: r'ClassModel', + xml: XmlReflection( +), + propertyClassPart: PropertyReflection>( + dartName: r'propertyClass', + nullable: false, + required: false, + oasName: r'_class', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_propertyClassGetter), + setter: FunctionWrapper2(_propertyClassSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ClassModelReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.propertyClassPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> propertyClassPart; + static UndefinedWrapper< + String +> _propertyClassGetter(ClassModel parent) { + return parent.propertyClass; + } + static void _propertyClassSetter(ClassModel parent, UndefinedWrapper< + String +> value) { + parent.propertyClass = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + propertyClassPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ClassModel instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ClassModel instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ClassModel empty() { + return ClassModel( + ); + } + + @override + bool operator ==(Object other) { + return other is ClassModelReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/client.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/client.dart new file mode 100644 index 000000000000..d80fdd6c31de --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/client.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'client.reflection.dart'; + + +/// ClientMixin +/// +/// Properties: +/// * [client] +mixin ClientMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get client; + +} + +/// Client +/// +/// Properties: +/// * [client] +class Client with +$OpenApiObjectMixin, + +ClientMixin { + @override + UndefinedWrapper< + String +> client; + + AdditionalProperties additionalProperties; + + + + Client.$all({ + required this.client, + required this.additionalProperties, + + }); + + Client({ + this.client = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ClientReflection.instance; + ClientReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Client.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Client clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/client.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/client.reflection.dart new file mode 100644 index 000000000000..b3908d7e6ef0 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/client.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'client.dart'; + + +//class reflection + +class ClientReflection extends ModelReflection { + static ClientReflection instanceGetter() => instance; + static const instance = ClientReflection._( + modelName: r'Client', + className: r'Client', + xml: XmlReflection( +), + clientPart: PropertyReflection>( + dartName: r'client', + nullable: false, + required: false, + oasName: r'client', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_clientGetter), + setter: FunctionWrapper2(_clientSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ClientReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.clientPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> clientPart; + static UndefinedWrapper< + String +> _clientGetter(Client parent) { + return parent.client; + } + static void _clientSetter(Client parent, UndefinedWrapper< + String +> value) { + parent.client = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + clientPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Client instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Client instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Client empty() { + return Client( + ); + } + + @override + bool operator ==(Object other) { + return other is ClientReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/complex_quadrilateral.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/complex_quadrilateral.dart new file mode 100644 index 000000000000..955a8a183e15 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/complex_quadrilateral.dart @@ -0,0 +1,81 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'complex_quadrilateral.reflection.dart'; + + +/// ComplexQuadrilateralMixin +/// +/// Properties: +mixin ComplexQuadrilateralMixin on + QuadrilateralInterfaceMixin, ShapeInterfaceMixin, $OpenApiObjectMixin { + +} + +/// ComplexQuadrilateral +/// +/// Properties: +/// * [quadrilateralType] +/// * [shapeType] +class ComplexQuadrilateral with +$OpenApiObjectMixin, +QuadrilateralInterfaceMixin,ShapeInterfaceMixin, +ComplexQuadrilateralMixin { + @override + + String + quadrilateralType; + @override + + String + shapeType; + + AdditionalProperties additionalProperties; + + + + ComplexQuadrilateral.$all({ + required this.quadrilateralType, + required this.shapeType, + required this.additionalProperties, + + }); + + ComplexQuadrilateral({ + required this.quadrilateralType , +required this.shapeType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ComplexQuadrilateralReflection.instance; + ComplexQuadrilateralReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory ComplexQuadrilateral.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ComplexQuadrilateral clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/complex_quadrilateral.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/complex_quadrilateral.reflection.dart new file mode 100644 index 000000000000..9299e21a9282 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/complex_quadrilateral.reflection.dart @@ -0,0 +1,210 @@ +// Model reflection + +part of 'complex_quadrilateral.dart'; + + +//class reflection + +class ComplexQuadrilateralReflection extends ModelReflection { + static ComplexQuadrilateralReflection instanceGetter() => instance; + static const instance = ComplexQuadrilateralReflection._( + modelName: r'ComplexQuadrilateral', + className: r'ComplexQuadrilateral', + xml: XmlReflection( +), + quadrilateralTypePart: PropertyReflection( + dartName: r'quadrilateralType', + nullable: false, + required: true, + oasName: r'quadrilateralType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_quadrilateralTypeGetter), + setter: FunctionWrapper2(_quadrilateralTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + shapeTypePart: PropertyReflection( + dartName: r'shapeType', + nullable: false, + required: true, + oasName: r'shapeType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_shapeTypeGetter), + setter: FunctionWrapper2(_shapeTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + allOfQuadrilateralInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: QuadrilateralInterfaceReflection.instance, + ), +allOfShapeInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: ShapeInterfaceReflection.instance, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ComplexQuadrilateralReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.quadrilateralTypePart, + required this.shapeTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfQuadrilateralInterfacePart, +required this.allOfShapeInterfacePart, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection quadrilateralTypePart; + static + String + _quadrilateralTypeGetter(ComplexQuadrilateral parent) { + return parent.quadrilateralType; + } + static void _quadrilateralTypeSetter(ComplexQuadrilateral parent, + String + value) { + parent.quadrilateralType = value; + } + + final PropertyReflection shapeTypePart; + static + String + _shapeTypeGetter(ComplexQuadrilateral parent) { + return parent.shapeType; + } + static void _shapeTypeSetter(ComplexQuadrilateral parent, + String + value) { + parent.shapeType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + quadrilateralTypePart, +shapeTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ComplexQuadrilateral instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ComplexQuadrilateral instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + final AllOfReflection allOfQuadrilateralInterfacePart; +final AllOfReflection allOfShapeInterfacePart; + + + + @override + List> get allOfs => [ + allOfQuadrilateralInterfacePart,allOfShapeInterfacePart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ComplexQuadrilateral empty() { + return ComplexQuadrilateral( + quadrilateralType: quadrilateralTypePart.reflection.emptyFunction(), + shapeType: shapeTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is ComplexQuadrilateralReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/danish_pig.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/danish_pig.dart new file mode 100644 index 000000000000..8760898100fe --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/danish_pig.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'danish_pig.reflection.dart'; + + +/// DanishPigMixin +/// +/// Properties: +/// * [className] +mixin DanishPigMixin on + $OpenApiObjectMixin { + + String + get className; + +} + +/// DanishPig +/// +/// Properties: +/// * [className] +class DanishPig with +$OpenApiObjectMixin, + +DanishPigMixin { + @override + + String + className; + + AdditionalProperties additionalProperties; + + + + DanishPig.$all({ + required this.className, + required this.additionalProperties, + + }); + + DanishPig({ + required this.className , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = DanishPigReflection.instance; + DanishPigReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory DanishPig.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + DanishPig clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/danish_pig.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/danish_pig.reflection.dart new file mode 100644 index 000000000000..c62c272e47b9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/danish_pig.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'danish_pig.dart'; + + +//class reflection + +class DanishPigReflection extends ModelReflection { + static DanishPigReflection instanceGetter() => instance; + static const instance = DanishPigReflection._( + modelName: r'DanishPig', + className: r'DanishPig', + xml: XmlReflection( +), + classNamePart: PropertyReflection( + dartName: r'className', + nullable: false, + required: true, + oasName: r'className', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_classNameGetter), + setter: FunctionWrapper2(_classNameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const DanishPigReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.classNamePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection classNamePart; + static + String + _classNameGetter(DanishPig parent) { + return parent.className; + } + static void _classNameSetter(DanishPig parent, + String + value) { + parent.className = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + classNamePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(DanishPig instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(DanishPig instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + DanishPig empty() { + return DanishPig( + className: classNamePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is DanishPigReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/deprecated_object.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/deprecated_object.dart new file mode 100644 index 000000000000..578196a445e8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/deprecated_object.dart @@ -0,0 +1,84 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'deprecated_object.reflection.dart'; + + +/// DeprecatedObjectMixin +/// +/// Properties: +/// * [name] +@Deprecated('DeprecatedObjectMixin has been deprecated') +mixin DeprecatedObjectMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get name; + +} + +/// DeprecatedObject +/// +/// Properties: +/// * [name] +@Deprecated('DeprecatedObjectMixin has been deprecated') +class DeprecatedObject with +$OpenApiObjectMixin, + +DeprecatedObjectMixin { + @override + UndefinedWrapper< + String +> name; + + AdditionalProperties additionalProperties; + + + + DeprecatedObject.$all({ + required this.name, + required this.additionalProperties, + + }); + + DeprecatedObject({ + this.name = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = DeprecatedObjectReflection.instance; + DeprecatedObjectReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory DeprecatedObject.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + DeprecatedObject clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/deprecated_object.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/deprecated_object.reflection.dart new file mode 100644 index 000000000000..599d18ce8755 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/deprecated_object.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'deprecated_object.dart'; + + +//class reflection + +class DeprecatedObjectReflection extends ModelReflection { + static DeprecatedObjectReflection instanceGetter() => instance; + static const instance = DeprecatedObjectReflection._( + modelName: r'DeprecatedObject', + className: r'DeprecatedObject', + xml: XmlReflection( +), + namePart: PropertyReflection>( + dartName: r'name', + nullable: false, + required: false, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const DeprecatedObjectReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.namePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> namePart; + static UndefinedWrapper< + String +> _nameGetter(DeprecatedObject parent) { + return parent.name; + } + static void _nameSetter(DeprecatedObject parent, UndefinedWrapper< + String +> value) { + parent.name = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + namePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(DeprecatedObject instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(DeprecatedObject instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + DeprecatedObject empty() { + return DeprecatedObject( + ); + } + + @override + bool operator ==(Object other) { + return other is DeprecatedObjectReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/dog.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/dog.dart new file mode 100644 index 000000000000..252aba9bdf34 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/dog.dart @@ -0,0 +1,103 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'dog.reflection.dart'; + + +/// DogMixin +/// +/// Properties: +/// * [breed] +mixin DogMixin on + AnimalMixin, $OpenApiObjectMixin { + UndefinedWrapper< + String +> get breed; + +} + +/// Dog +/// +/// Properties: +/// * [color] +/// * [breed] +/// * [className] +class Dog with +$OpenApiObjectMixin, +AnimalMixin, +DogMixin { + @override + UndefinedWrapper< + String +> color; + @override + UndefinedWrapper< + String +> breed; + @override + + String + className; + + AdditionalProperties additionalProperties; + + + + Dog.$all({ + required this.color, + required this.breed, + required this.className, + required this.additionalProperties, + + }); + + Dog({ + this.color = const UndefinedWrapper + ( + + 'red' + ) + +, + this.breed = const UndefinedWrapper + .undefined() +, +required this.className , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = DogReflection.instance; + DogReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory Dog.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Dog clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/dog.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/dog.reflection.dart new file mode 100644 index 000000000000..caf2bbd97595 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/dog.reflection.dart @@ -0,0 +1,254 @@ +// Model reflection + +part of 'dog.dart'; + + +//class reflection + +class DogReflection extends ModelReflection { + static DogReflection instanceGetter() => instance; + static const instance = DogReflection._( + modelName: r'Dog', + className: r'Dog', + xml: XmlReflection( +), + colorPart: PropertyReflection>( + dartName: r'color', + nullable: false, + required: false, + oasName: r'color', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_colorGetter), + setter: FunctionWrapper2(_colorSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + breedPart: PropertyReflection>( + dartName: r'breed', + nullable: false, + required: false, + oasName: r'breed', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_breedGetter), + setter: FunctionWrapper2(_breedSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + classNamePart: PropertyReflection( + dartName: r'className', + nullable: false, + required: true, + oasName: r'className', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_classNameGetter), + setter: FunctionWrapper2(_classNameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + discriminatorKey: r'className', + discriminatorImplicitMappings: const { + r'Animal': AnimalReflection.instance, + }, + discriminatorMappings: const { + }, + allOfAnimalPart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: AnimalReflection.instance, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const DogReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.colorPart, + required this.breedPart, + required this.classNamePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfAnimalPart, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> colorPart; + static UndefinedWrapper< + String +> _colorGetter(Dog parent) { + return parent.color; + } + static void _colorSetter(Dog parent, UndefinedWrapper< + String +> value) { + parent.color = value; + } + + final PropertyReflection> breedPart; + static UndefinedWrapper< + String +> _breedGetter(Dog parent) { + return parent.breed; + } + static void _breedSetter(Dog parent, UndefinedWrapper< + String +> value) { + parent.breed = value; + } + + final PropertyReflection classNamePart; + static + String + _classNameGetter(Dog parent) { + return parent.className; + } + static void _classNameSetter(Dog parent, + String + value) { + parent.className = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + colorPart, +breedPart, +classNamePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Dog instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Dog instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + final AllOfReflection allOfAnimalPart; + + + + @override + List> get allOfs => [ + allOfAnimalPart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Dog empty() { + return Dog( + className: classNamePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is DogReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/drawing.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/drawing.dart new file mode 100644 index 000000000000..8a641aec82f4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/drawing.dart @@ -0,0 +1,140 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'drawing.reflection.dart'; + + +/// DrawingMixin +/// +/// Properties: +/// * [mainShape] +/// * [shapeOrNull] +/// * [nullableShape] +/// * [shapes] +mixin DrawingMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + Shape +> get mainShape; +UndefinedWrapper< + ShapeOrNull +> get shapeOrNull; +UndefinedWrapper< + NullableShape +?> get nullableShape; +UndefinedWrapper< + List< + + Shape +> +> get shapes; + +} + +/// Drawing +/// +/// Properties: +/// * [mainShape] +/// * [shapeOrNull] +/// * [nullableShape] +/// * [shapes] +class Drawing with +$OpenApiObjectMixin, + +DrawingMixin { + @override + UndefinedWrapper< + Shape +> mainShape; + @override + UndefinedWrapper< + ShapeOrNull +> shapeOrNull; + @override + UndefinedWrapper< + NullableShape +?> nullableShape; + @override + UndefinedWrapper< + List< + + Shape +> +> shapes; + + AdditionalProperties< + Fruit +> additionalProperties; + + + + Drawing.$all({ + required this.mainShape, + required this.shapeOrNull, + required this.nullableShape, + required this.shapes, + required this.additionalProperties, + + }); + + Drawing({ + this.mainShape = const UndefinedWrapper + .undefined() +, + this.shapeOrNull = const UndefinedWrapper + .undefined() +, + this.nullableShape = const UndefinedWrapper + .undefined() +, + this.shapes = const UndefinedWrapper + .undefined() +, + AdditionalProperties< + Fruit +>? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = DrawingReflection.instance; + DrawingReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Drawing.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Drawing clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/drawing.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/drawing.reflection.dart new file mode 100644 index 000000000000..b3f992ca8c87 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/drawing.reflection.dart @@ -0,0 +1,306 @@ +// Model reflection + +part of 'drawing.dart'; + + +//class reflection + +class DrawingReflection extends ModelReflection { + static DrawingReflection instanceGetter() => instance; + static const instance = DrawingReflection._( + modelName: r'Drawing', + className: r'Drawing', + xml: XmlReflection( +), + mainShapePart: PropertyReflection>( + dartName: r'mainShape', + nullable: false, + required: false, + oasName: r'mainShape', + oasType: r'Shape', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mainShapeGetter), + setter: FunctionWrapper2(_mainShapeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Shape.$reflection + +, +) +), + ), + shapeOrNullPart: PropertyReflection>( + dartName: r'shapeOrNull', + nullable: false, + required: false, + oasName: r'shapeOrNull', + oasType: r'ShapeOrNull', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_shapeOrNullGetter), + setter: FunctionWrapper2(_shapeOrNullSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ShapeOrNull.$reflection + +, +) +), + ), + nullableShapePart: PropertyReflection>( + dartName: r'nullableShape', + nullable: true, + required: false, + oasName: r'nullableShape', + oasType: r'NullableShape', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nullableShapeGetter), + setter: FunctionWrapper2(_nullableShapeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + NullableShape.$reflection + +), +) +), + ), + shapesPart: PropertyReflection +>>( + dartName: r'shapes', + nullable: false, + required: false, + oasName: r'shapes', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_shapesGetter), + setter: FunctionWrapper2(_shapesSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Shape.$reflection + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Fruit.$reflection + +, +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const DrawingReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.mainShapePart, + required this.shapeOrNullPart, + required this.nullableShapePart, + required this.shapesPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> mainShapePart; + static UndefinedWrapper< + Shape +> _mainShapeGetter(Drawing parent) { + return parent.mainShape; + } + static void _mainShapeSetter(Drawing parent, UndefinedWrapper< + Shape +> value) { + parent.mainShape = value; + } + + final PropertyReflection> shapeOrNullPart; + static UndefinedWrapper< + ShapeOrNull +> _shapeOrNullGetter(Drawing parent) { + return parent.shapeOrNull; + } + static void _shapeOrNullSetter(Drawing parent, UndefinedWrapper< + ShapeOrNull +> value) { + parent.shapeOrNull = value; + } + + final PropertyReflection> nullableShapePart; + static UndefinedWrapper< + NullableShape +?> _nullableShapeGetter(Drawing parent) { + return parent.nullableShape; + } + static void _nullableShapeSetter(Drawing parent, UndefinedWrapper< + NullableShape +?> value) { + parent.nullableShape = value; + } + + final PropertyReflection +>> shapesPart; + static UndefinedWrapper< + List< + + Shape +> +> _shapesGetter(Drawing parent) { + return parent.shapes; + } + static void _shapesSetter(Drawing parent, UndefinedWrapper< + List< + + Shape +> +> value) { + parent.shapes = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + mainShapePart, +shapeOrNullPart, +nullableShapePart, +shapesPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties< + Fruit +> _AdditionalPropertiesGetter(Drawing instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Drawing instance, AdditionalProperties< + Fruit +> additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Drawing empty() { + return Drawing( + ); + } + + @override + bool operator ==(Object other) { + return other is DrawingReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_arrays.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_arrays.dart new file mode 100644 index 000000000000..6b066ba84fbc --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_arrays.dart @@ -0,0 +1,196 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'enum_arrays.reflection.dart'; + + +/// EnumArraysMixin +/// +/// Properties: +/// * [justSymbol] +/// * [arrayEnum] +mixin EnumArraysMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + EnumArraysJustSymbolEnum +> get justSymbol; +UndefinedWrapper< + List< + + EnumArraysArrayEnumEnum +> +> get arrayEnum; + +} + +/// EnumArrays +/// +/// Properties: +/// * [justSymbol] +/// * [arrayEnum] +class EnumArrays with +$OpenApiObjectMixin, + +EnumArraysMixin { + @override + UndefinedWrapper< + EnumArraysJustSymbolEnum +> justSymbol; + @override + UndefinedWrapper< + List< + + EnumArraysArrayEnumEnum +> +> arrayEnum; + + AdditionalProperties additionalProperties; + + + + EnumArrays.$all({ + required this.justSymbol, + required this.arrayEnum, + required this.additionalProperties, + + }); + + EnumArrays({ + this.justSymbol = const UndefinedWrapper + .undefined() +, + this.arrayEnum = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = EnumArraysReflection.instance; + EnumArraysReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory EnumArrays.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + EnumArrays clone() { + return $reflection.clone(this); + } +} + + +extension type const EnumArraysJustSymbolEnum._(String value) implements String { + const EnumArraysJustSymbolEnum.greaterThanEqual() : this._(r'>='); + const EnumArraysJustSymbolEnum.value() : this._(r'$'); + + /// Creates a [EnumArraysJustSymbolEnum] enum from a value and safely checking if it exists. + factory EnumArraysJustSymbolEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'greaterThanEqual', oasValue: r'>=', value: EnumArraysJustSymbolEnum.greaterThanEqual()), + + EnumMemberReflection(dartName: r'value', oasValue: r'$', value: EnumArraysJustSymbolEnum.value()), + + ], + ); + + factory EnumArraysJustSymbolEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumArraysJustSymbolEnum] enum from a value without checking if it exists. + const EnumArraysJustSymbolEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumArraysJustSymbolEnum.greaterThanEqual(), + EnumArraysJustSymbolEnum.value(), + + ]; +} + + +extension type const EnumArraysArrayEnumEnum._(String value) implements String { + const EnumArraysArrayEnumEnum.fish() : this._(r'fish'); + const EnumArraysArrayEnumEnum.crab() : this._(r'crab'); + + /// Creates a [EnumArraysArrayEnumEnum] enum from a value and safely checking if it exists. + factory EnumArraysArrayEnumEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'fish', oasValue: r'fish', value: EnumArraysArrayEnumEnum.fish()), + + EnumMemberReflection(dartName: r'crab', oasValue: r'crab', value: EnumArraysArrayEnumEnum.crab()), + + ], + ); + + factory EnumArraysArrayEnumEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumArraysArrayEnumEnum] enum from a value without checking if it exists. + const EnumArraysArrayEnumEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumArraysArrayEnumEnum.fish(), + EnumArraysArrayEnumEnum.crab(), + + ]; +} + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_arrays.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_arrays.reflection.dart new file mode 100644 index 000000000000..42eb9d59d3b3 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_arrays.reflection.dart @@ -0,0 +1,201 @@ +// Model reflection + +part of 'enum_arrays.dart'; + + +//class reflection + +class EnumArraysReflection extends ModelReflection { + static EnumArraysReflection instanceGetter() => instance; + static const instance = EnumArraysReflection._( + modelName: r'EnumArrays', + className: r'EnumArrays', + xml: XmlReflection( +), + justSymbolPart: PropertyReflection>( + dartName: r'justSymbol', + nullable: false, + required: false, + oasName: r'just_symbol', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_justSymbolGetter), + setter: FunctionWrapper2(_justSymbolSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumArraysJustSymbolEnum.$reflection + + +, +) +), + ), + arrayEnumPart: PropertyReflection +>>( + dartName: r'arrayEnum', + nullable: false, + required: false, + oasName: r'array_enum', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayEnumGetter), + setter: FunctionWrapper2(_arrayEnumSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumArraysArrayEnumEnum.$reflection + + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const EnumArraysReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.justSymbolPart, + required this.arrayEnumPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> justSymbolPart; + static UndefinedWrapper< + EnumArraysJustSymbolEnum +> _justSymbolGetter(EnumArrays parent) { + return parent.justSymbol; + } + static void _justSymbolSetter(EnumArrays parent, UndefinedWrapper< + EnumArraysJustSymbolEnum +> value) { + parent.justSymbol = value; + } + + final PropertyReflection +>> arrayEnumPart; + static UndefinedWrapper< + List< + + EnumArraysArrayEnumEnum +> +> _arrayEnumGetter(EnumArrays parent) { + return parent.arrayEnum; + } + static void _arrayEnumSetter(EnumArrays parent, UndefinedWrapper< + List< + + EnumArraysArrayEnumEnum +> +> value) { + parent.arrayEnum = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + justSymbolPart, +arrayEnumPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(EnumArrays instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(EnumArrays instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + EnumArrays empty() { + return EnumArrays( + ); + } + + @override + bool operator ==(Object other) { + return other is EnumArraysReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_class.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_class.dart new file mode 100644 index 000000000000..72a40ae91305 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_class.dart @@ -0,0 +1,60 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'enum_class.reflection.dart'; + + +//enum def + +extension type const EnumClass._(String value) implements String { + const EnumClass.abc() : this._(r'_abc'); + const EnumClass.efg() : this._(r'-efg'); + const EnumClass.xyz() : this._(r'(xyz)'); + + /// Creates a [EnumClass] enum from a value and safely checking if it exists. + factory EnumClass.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'abc', oasValue: r'_abc', value: EnumClass.abc()), + + EnumMemberReflection(dartName: r'efg', oasValue: r'-efg', value: EnumClass.efg()), + + EnumMemberReflection(dartName: r'xyz', oasValue: r'(xyz)', value: EnumClass.xyz()), + + ], + ); + + factory EnumClass.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumClass] enum from a value without checking if it exists. + const EnumClass.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumClass.abc(), + EnumClass.efg(), + EnumClass.xyz(), + + ]; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_class.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_class.reflection.dart new file mode 100644 index 000000000000..c07718577e59 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_class.reflection.dart @@ -0,0 +1,6 @@ +// Model reflection + +part of 'enum_class.dart'; + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_string_discriminator.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_string_discriminator.dart new file mode 100644 index 000000000000..2644a6d44b16 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_string_discriminator.dart @@ -0,0 +1,127 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'enum_string_discriminator.reflection.dart'; + + +/// An object to test discriminator of enum string +/// +/// Properties: +/// * [enumStrType] - enum string type +mixin EnumStringDiscriminatorMixin on + $OpenApiObjectMixin { + + EnumStringDiscriminatorEnumStrTypeEnum + get enumStrType; + +} + +/// An object to test discriminator of enum string +/// +/// Properties: +/// * [enumStrType] - enum string type +class EnumStringDiscriminator with +$OpenApiObjectMixin, + +EnumStringDiscriminatorMixin { + @override + + EnumStringDiscriminatorEnumStrTypeEnum + enumStrType; + + AdditionalProperties additionalProperties; + + + + EnumStringDiscriminator.$all({ + required this.enumStrType, + required this.additionalProperties, + + }); + + EnumStringDiscriminator({ + required this.enumStrType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = EnumStringDiscriminatorReflection.instance; + EnumStringDiscriminatorReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory EnumStringDiscriminator.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + EnumStringDiscriminator clone() { + return $reflection.clone(this); + } +} + + +extension type const EnumStringDiscriminatorEnumStrTypeEnum._(String value) implements String { + /// enum string type + const EnumStringDiscriminatorEnumStrTypeEnum.typeA() : this._(r'type_a'); + /// enum string type + const EnumStringDiscriminatorEnumStrTypeEnum.typeB() : this._(r'type_b'); + + /// Creates a [EnumStringDiscriminatorEnumStrTypeEnum] enum from a value and safely checking if it exists. + factory EnumStringDiscriminatorEnumStrTypeEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'typeA', oasValue: r'type_a', value: EnumStringDiscriminatorEnumStrTypeEnum.typeA()), + + EnumMemberReflection(dartName: r'typeB', oasValue: r'type_b', value: EnumStringDiscriminatorEnumStrTypeEnum.typeB()), + + ], + ); + + factory EnumStringDiscriminatorEnumStrTypeEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumStringDiscriminatorEnumStrTypeEnum] enum from a value without checking if it exists. + const EnumStringDiscriminatorEnumStrTypeEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumStringDiscriminatorEnumStrTypeEnum.typeA(), + EnumStringDiscriminatorEnumStrTypeEnum.typeB(), + + ]; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_string_discriminator.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_string_discriminator.reflection.dart new file mode 100644 index 000000000000..7cb60524aabc --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_string_discriminator.reflection.dart @@ -0,0 +1,146 @@ +// Model reflection + +part of 'enum_string_discriminator.dart'; + + +//class reflection + +class EnumStringDiscriminatorReflection extends ModelReflection { + static EnumStringDiscriminatorReflection instanceGetter() => instance; + static const instance = EnumStringDiscriminatorReflection._( + modelName: r'EnumStringDiscriminator', + className: r'EnumStringDiscriminator', + xml: XmlReflection( +), + enumStrTypePart: PropertyReflection( + dartName: r'enumStrType', + nullable: false, + required: true, + oasName: r'enum_str_type', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_enumStrTypeGetter), + setter: FunctionWrapper2(_enumStrTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumStringDiscriminatorEnumStrTypeEnum.$reflection + + +, +) +, + ), + discriminatorKey: r'enum_str_type', + discriminatorImplicitMappings: const { + }, + discriminatorMappings: const { + }, + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const EnumStringDiscriminatorReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.enumStrTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection enumStrTypePart; + static + EnumStringDiscriminatorEnumStrTypeEnum + _enumStrTypeGetter(EnumStringDiscriminator parent) { + return parent.enumStrType; + } + static void _enumStrTypeSetter(EnumStringDiscriminator parent, + EnumStringDiscriminatorEnumStrTypeEnum + value) { + parent.enumStrType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + enumStrTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(EnumStringDiscriminator instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(EnumStringDiscriminator instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + EnumStringDiscriminator empty() { + return EnumStringDiscriminator( + enumStrType: enumStrTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is EnumStringDiscriminatorReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_test.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_test.dart new file mode 100644 index 000000000000..125407f9544c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_test.dart @@ -0,0 +1,441 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'enum_test.reflection.dart'; + + +/// EnumTestMixin +/// +/// Properties: +/// * [enumString] +/// * [enumStringRequired] +/// * [enumInteger] +/// * [enumIntegerOnly] +/// * [enumNumber] +/// * [outerEnum] +/// * [outerEnumInteger] +/// * [outerEnumDefaultValue] +/// * [outerEnumIntegerDefaultValue] +mixin EnumTestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + EnumTestEnumStringEnum +> get enumString; + + EnumTestEnumStringRequiredEnum + get enumStringRequired; +UndefinedWrapper< + EnumTestEnumIntegerEnum +> get enumInteger; +UndefinedWrapper< + EnumTestEnumIntegerOnlyEnum +> get enumIntegerOnly; +UndefinedWrapper< + EnumTestEnumNumberEnum +> get enumNumber; +UndefinedWrapper< + OuterEnum +?> get outerEnum; +UndefinedWrapper< + OuterEnumInteger +> get outerEnumInteger; +UndefinedWrapper< + OuterEnumDefaultValue +> get outerEnumDefaultValue; +UndefinedWrapper< + OuterEnumIntegerDefaultValue +> get outerEnumIntegerDefaultValue; + +} + +/// EnumTest +/// +/// Properties: +/// * [enumString] +/// * [enumStringRequired] +/// * [enumInteger] +/// * [enumIntegerOnly] +/// * [enumNumber] +/// * [outerEnum] +/// * [outerEnumInteger] +/// * [outerEnumDefaultValue] +/// * [outerEnumIntegerDefaultValue] +class EnumTest with +$OpenApiObjectMixin, + +EnumTestMixin { + @override + UndefinedWrapper< + EnumTestEnumStringEnum +> enumString; + @override + + EnumTestEnumStringRequiredEnum + enumStringRequired; + @override + UndefinedWrapper< + EnumTestEnumIntegerEnum +> enumInteger; + @override + UndefinedWrapper< + EnumTestEnumIntegerOnlyEnum +> enumIntegerOnly; + @override + UndefinedWrapper< + EnumTestEnumNumberEnum +> enumNumber; + @override + UndefinedWrapper< + OuterEnum +?> outerEnum; + @override + UndefinedWrapper< + OuterEnumInteger +> outerEnumInteger; + @override + UndefinedWrapper< + OuterEnumDefaultValue +> outerEnumDefaultValue; + @override + UndefinedWrapper< + OuterEnumIntegerDefaultValue +> outerEnumIntegerDefaultValue; + + AdditionalProperties additionalProperties; + + + + EnumTest.$all({ + required this.enumString, + required this.enumStringRequired, + required this.enumInteger, + required this.enumIntegerOnly, + required this.enumNumber, + required this.outerEnum, + required this.outerEnumInteger, + required this.outerEnumDefaultValue, + required this.outerEnumIntegerDefaultValue, + required this.additionalProperties, + + }); + + EnumTest({ + this.enumString = const UndefinedWrapper + .undefined() +, +required this.enumStringRequired , + this.enumInteger = const UndefinedWrapper + .undefined() +, + this.enumIntegerOnly = const UndefinedWrapper + .undefined() +, + this.enumNumber = const UndefinedWrapper + .undefined() +, + this.outerEnum = const UndefinedWrapper + .undefined() +, + this.outerEnumInteger = const UndefinedWrapper + .undefined() +, + this.outerEnumDefaultValue = const UndefinedWrapper + .undefined() +, + this.outerEnumIntegerDefaultValue = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = EnumTestReflection.instance; + EnumTestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory EnumTest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + EnumTest clone() { + return $reflection.clone(this); + } +} + + +extension type const EnumTestEnumStringEnum._(String value) implements String { + const EnumTestEnumStringEnum.UPPER() : this._(r'UPPER'); + const EnumTestEnumStringEnum.lower() : this._(r'lower'); + const EnumTestEnumStringEnum.empty() : this._(r''); + + /// Creates a [EnumTestEnumStringEnum] enum from a value and safely checking if it exists. + factory EnumTestEnumStringEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'UPPER', oasValue: r'UPPER', value: EnumTestEnumStringEnum.UPPER()), + + EnumMemberReflection(dartName: r'lower', oasValue: r'lower', value: EnumTestEnumStringEnum.lower()), + + EnumMemberReflection(dartName: r'empty', oasValue: r'', value: EnumTestEnumStringEnum.empty()), + + ], + ); + + factory EnumTestEnumStringEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumTestEnumStringEnum] enum from a value without checking if it exists. + const EnumTestEnumStringEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumTestEnumStringEnum.UPPER(), + EnumTestEnumStringEnum.lower(), + EnumTestEnumStringEnum.empty(), + + ]; +} + + +extension type const EnumTestEnumStringRequiredEnum._(String value) implements String { + const EnumTestEnumStringRequiredEnum.UPPER() : this._(r'UPPER'); + const EnumTestEnumStringRequiredEnum.lower() : this._(r'lower'); + const EnumTestEnumStringRequiredEnum.empty() : this._(r''); + + /// Creates a [EnumTestEnumStringRequiredEnum] enum from a value and safely checking if it exists. + factory EnumTestEnumStringRequiredEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'UPPER', oasValue: r'UPPER', value: EnumTestEnumStringRequiredEnum.UPPER()), + + EnumMemberReflection(dartName: r'lower', oasValue: r'lower', value: EnumTestEnumStringRequiredEnum.lower()), + + EnumMemberReflection(dartName: r'empty', oasValue: r'', value: EnumTestEnumStringRequiredEnum.empty()), + + ], + ); + + factory EnumTestEnumStringRequiredEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumTestEnumStringRequiredEnum] enum from a value without checking if it exists. + const EnumTestEnumStringRequiredEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumTestEnumStringRequiredEnum.UPPER(), + EnumTestEnumStringRequiredEnum.lower(), + EnumTestEnumStringRequiredEnum.empty(), + + ]; +} + + +extension type const EnumTestEnumIntegerEnum._(int value) implements int { + const EnumTestEnumIntegerEnum.number1() : this._(1); + const EnumTestEnumIntegerEnum.numberNegative1() : this._(-1); + + /// Creates a [EnumTestEnumIntegerEnum] enum from a value and safely checking if it exists. + factory EnumTestEnumIntegerEnum.$safe(int value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forint, + members: [ + + EnumMemberReflection(dartName: r'number1', oasValue: 1, value: EnumTestEnumIntegerEnum.number1()), + + EnumMemberReflection(dartName: r'numberNegative1', oasValue: -1, value: EnumTestEnumIntegerEnum.numberNegative1()), + + ], + ); + + factory EnumTestEnumIntegerEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumTestEnumIntegerEnum] enum from a value without checking if it exists. + const EnumTestEnumIntegerEnum.$unsafe(int value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumTestEnumIntegerEnum.number1(), + EnumTestEnumIntegerEnum.numberNegative1(), + + ]; +} + + +extension type const EnumTestEnumIntegerOnlyEnum._(int value) implements int { + const EnumTestEnumIntegerOnlyEnum.number2() : this._(2); + const EnumTestEnumIntegerOnlyEnum.numberNegative2() : this._(-2); + + /// Creates a [EnumTestEnumIntegerOnlyEnum] enum from a value and safely checking if it exists. + factory EnumTestEnumIntegerOnlyEnum.$safe(int value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forint, + members: [ + + EnumMemberReflection(dartName: r'number2', oasValue: 2, value: EnumTestEnumIntegerOnlyEnum.number2()), + + EnumMemberReflection(dartName: r'numberNegative2', oasValue: -2, value: EnumTestEnumIntegerOnlyEnum.numberNegative2()), + + ], + ); + + factory EnumTestEnumIntegerOnlyEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumTestEnumIntegerOnlyEnum] enum from a value without checking if it exists. + const EnumTestEnumIntegerOnlyEnum.$unsafe(int value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumTestEnumIntegerOnlyEnum.number2(), + EnumTestEnumIntegerOnlyEnum.numberNegative2(), + + ]; +} + + +extension type const EnumTestEnumNumberEnum._(double value) implements double { + const EnumTestEnumNumberEnum.number11() : this._(1.1); + const EnumTestEnumNumberEnum.numberNegative12() : this._(-1.2); + + /// Creates a [EnumTestEnumNumberEnum] enum from a value and safely checking if it exists. + factory EnumTestEnumNumberEnum.$safe(double value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.fordouble, + members: [ + + EnumMemberReflection(dartName: r'number11', oasValue: 1.1, value: EnumTestEnumNumberEnum.number11()), + + EnumMemberReflection(dartName: r'numberNegative12', oasValue: -1.2, value: EnumTestEnumNumberEnum.numberNegative12()), + + ], + ); + + factory EnumTestEnumNumberEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [EnumTestEnumNumberEnum] enum from a value without checking if it exists. + const EnumTestEnumNumberEnum.$unsafe(double value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + EnumTestEnumNumberEnum.number11(), + EnumTestEnumNumberEnum.numberNegative12(), + + ]; +} + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_test.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_test.reflection.dart new file mode 100644 index 000000000000..495d2b6b5fd5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/enum_test.reflection.dart @@ -0,0 +1,485 @@ +// Model reflection + +part of 'enum_test.dart'; + + +//class reflection + +class EnumTestReflection extends ModelReflection { + static EnumTestReflection instanceGetter() => instance; + static const instance = EnumTestReflection._( + modelName: r'Enum_Test', + className: r'EnumTest', + xml: XmlReflection( +), + enumStringPart: PropertyReflection>( + dartName: r'enumString', + nullable: false, + required: false, + oasName: r'enum_string', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_enumStringGetter), + setter: FunctionWrapper2(_enumStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumTestEnumStringEnum.$reflection + + +, +) +), + ), + enumStringRequiredPart: PropertyReflection( + dartName: r'enumStringRequired', + nullable: false, + required: true, + oasName: r'enum_string_required', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_enumStringRequiredGetter), + setter: FunctionWrapper2(_enumStringRequiredSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumTestEnumStringRequiredEnum.$reflection + + +, +) +, + ), + enumIntegerPart: PropertyReflection>( + dartName: r'enumInteger', + nullable: false, + required: false, + oasName: r'enum_integer', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_enumIntegerGetter), + setter: FunctionWrapper2(_enumIntegerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumTestEnumIntegerEnum.$reflection + + +, +) +), + ), + enumIntegerOnlyPart: PropertyReflection>( + dartName: r'enumIntegerOnly', + nullable: false, + required: false, + oasName: r'enum_integer_only', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_enumIntegerOnlyGetter), + setter: FunctionWrapper2(_enumIntegerOnlySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumTestEnumIntegerOnlyEnum.$reflection + + +, +) +), + ), + enumNumberPart: PropertyReflection>( + dartName: r'enumNumber', + nullable: false, + required: false, + oasName: r'enum_number', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_enumNumberGetter), + setter: FunctionWrapper2(_enumNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumTestEnumNumberEnum.$reflection + + +, +) +), + ), + outerEnumPart: PropertyReflection>( + dartName: r'outerEnum', + nullable: true, + required: false, + oasName: r'outerEnum', + oasType: r'OuterEnum', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_outerEnumGetter), + setter: FunctionWrapper2(_outerEnumSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + OuterEnum.$reflection + +), +) +), + ), + outerEnumIntegerPart: PropertyReflection>( + dartName: r'outerEnumInteger', + nullable: false, + required: false, + oasName: r'outerEnumInteger', + oasType: r'OuterEnumInteger', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_outerEnumIntegerGetter), + setter: FunctionWrapper2(_outerEnumIntegerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + OuterEnumInteger.$reflection + +, +) +), + ), + outerEnumDefaultValuePart: PropertyReflection>( + dartName: r'outerEnumDefaultValue', + nullable: false, + required: false, + oasName: r'outerEnumDefaultValue', + oasType: r'OuterEnumDefaultValue', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_outerEnumDefaultValueGetter), + setter: FunctionWrapper2(_outerEnumDefaultValueSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + OuterEnumDefaultValue.$reflection + +, +) +), + ), + outerEnumIntegerDefaultValuePart: PropertyReflection>( + dartName: r'outerEnumIntegerDefaultValue', + nullable: false, + required: false, + oasName: r'outerEnumIntegerDefaultValue', + oasType: r'OuterEnumIntegerDefaultValue', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_outerEnumIntegerDefaultValueGetter), + setter: FunctionWrapper2(_outerEnumIntegerDefaultValueSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + OuterEnumIntegerDefaultValue.$reflection + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const EnumTestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.enumStringPart, + required this.enumStringRequiredPart, + required this.enumIntegerPart, + required this.enumIntegerOnlyPart, + required this.enumNumberPart, + required this.outerEnumPart, + required this.outerEnumIntegerPart, + required this.outerEnumDefaultValuePart, + required this.outerEnumIntegerDefaultValuePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> enumStringPart; + static UndefinedWrapper< + EnumTestEnumStringEnum +> _enumStringGetter(EnumTest parent) { + return parent.enumString; + } + static void _enumStringSetter(EnumTest parent, UndefinedWrapper< + EnumTestEnumStringEnum +> value) { + parent.enumString = value; + } + + final PropertyReflection enumStringRequiredPart; + static + EnumTestEnumStringRequiredEnum + _enumStringRequiredGetter(EnumTest parent) { + return parent.enumStringRequired; + } + static void _enumStringRequiredSetter(EnumTest parent, + EnumTestEnumStringRequiredEnum + value) { + parent.enumStringRequired = value; + } + + final PropertyReflection> enumIntegerPart; + static UndefinedWrapper< + EnumTestEnumIntegerEnum +> _enumIntegerGetter(EnumTest parent) { + return parent.enumInteger; + } + static void _enumIntegerSetter(EnumTest parent, UndefinedWrapper< + EnumTestEnumIntegerEnum +> value) { + parent.enumInteger = value; + } + + final PropertyReflection> enumIntegerOnlyPart; + static UndefinedWrapper< + EnumTestEnumIntegerOnlyEnum +> _enumIntegerOnlyGetter(EnumTest parent) { + return parent.enumIntegerOnly; + } + static void _enumIntegerOnlySetter(EnumTest parent, UndefinedWrapper< + EnumTestEnumIntegerOnlyEnum +> value) { + parent.enumIntegerOnly = value; + } + + final PropertyReflection> enumNumberPart; + static UndefinedWrapper< + EnumTestEnumNumberEnum +> _enumNumberGetter(EnumTest parent) { + return parent.enumNumber; + } + static void _enumNumberSetter(EnumTest parent, UndefinedWrapper< + EnumTestEnumNumberEnum +> value) { + parent.enumNumber = value; + } + + final PropertyReflection> outerEnumPart; + static UndefinedWrapper< + OuterEnum +?> _outerEnumGetter(EnumTest parent) { + return parent.outerEnum; + } + static void _outerEnumSetter(EnumTest parent, UndefinedWrapper< + OuterEnum +?> value) { + parent.outerEnum = value; + } + + final PropertyReflection> outerEnumIntegerPart; + static UndefinedWrapper< + OuterEnumInteger +> _outerEnumIntegerGetter(EnumTest parent) { + return parent.outerEnumInteger; + } + static void _outerEnumIntegerSetter(EnumTest parent, UndefinedWrapper< + OuterEnumInteger +> value) { + parent.outerEnumInteger = value; + } + + final PropertyReflection> outerEnumDefaultValuePart; + static UndefinedWrapper< + OuterEnumDefaultValue +> _outerEnumDefaultValueGetter(EnumTest parent) { + return parent.outerEnumDefaultValue; + } + static void _outerEnumDefaultValueSetter(EnumTest parent, UndefinedWrapper< + OuterEnumDefaultValue +> value) { + parent.outerEnumDefaultValue = value; + } + + final PropertyReflection> outerEnumIntegerDefaultValuePart; + static UndefinedWrapper< + OuterEnumIntegerDefaultValue +> _outerEnumIntegerDefaultValueGetter(EnumTest parent) { + return parent.outerEnumIntegerDefaultValue; + } + static void _outerEnumIntegerDefaultValueSetter(EnumTest parent, UndefinedWrapper< + OuterEnumIntegerDefaultValue +> value) { + parent.outerEnumIntegerDefaultValue = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + enumStringPart, +enumStringRequiredPart, +enumIntegerPart, +enumIntegerOnlyPart, +enumNumberPart, +outerEnumPart, +outerEnumIntegerPart, +outerEnumDefaultValuePart, +outerEnumIntegerDefaultValuePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(EnumTest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(EnumTest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + EnumTest empty() { + return EnumTest( + enumStringRequired: enumStringRequiredPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is EnumTestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/equilateral_triangle.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/equilateral_triangle.dart new file mode 100644 index 000000000000..de9e775e703d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/equilateral_triangle.dart @@ -0,0 +1,81 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'equilateral_triangle.reflection.dart'; + + +/// EquilateralTriangleMixin +/// +/// Properties: +mixin EquilateralTriangleMixin on + ShapeInterfaceMixin, TriangleInterfaceMixin, $OpenApiObjectMixin { + +} + +/// EquilateralTriangle +/// +/// Properties: +/// * [shapeType] +/// * [triangleType] +class EquilateralTriangle with +$OpenApiObjectMixin, +ShapeInterfaceMixin,TriangleInterfaceMixin, +EquilateralTriangleMixin { + @override + + String + shapeType; + @override + + String + triangleType; + + AdditionalProperties additionalProperties; + + + + EquilateralTriangle.$all({ + required this.shapeType, + required this.triangleType, + required this.additionalProperties, + + }); + + EquilateralTriangle({ + required this.shapeType , +required this.triangleType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = EquilateralTriangleReflection.instance; + EquilateralTriangleReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory EquilateralTriangle.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + EquilateralTriangle clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/equilateral_triangle.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/equilateral_triangle.reflection.dart new file mode 100644 index 000000000000..5307fcb89e4c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/equilateral_triangle.reflection.dart @@ -0,0 +1,210 @@ +// Model reflection + +part of 'equilateral_triangle.dart'; + + +//class reflection + +class EquilateralTriangleReflection extends ModelReflection { + static EquilateralTriangleReflection instanceGetter() => instance; + static const instance = EquilateralTriangleReflection._( + modelName: r'EquilateralTriangle', + className: r'EquilateralTriangle', + xml: XmlReflection( +), + shapeTypePart: PropertyReflection( + dartName: r'shapeType', + nullable: false, + required: true, + oasName: r'shapeType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_shapeTypeGetter), + setter: FunctionWrapper2(_shapeTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + triangleTypePart: PropertyReflection( + dartName: r'triangleType', + nullable: false, + required: true, + oasName: r'triangleType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_triangleTypeGetter), + setter: FunctionWrapper2(_triangleTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + allOfShapeInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: ShapeInterfaceReflection.instance, + ), +allOfTriangleInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: TriangleInterfaceReflection.instance, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const EquilateralTriangleReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.shapeTypePart, + required this.triangleTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfShapeInterfacePart, +required this.allOfTriangleInterfacePart, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection shapeTypePart; + static + String + _shapeTypeGetter(EquilateralTriangle parent) { + return parent.shapeType; + } + static void _shapeTypeSetter(EquilateralTriangle parent, + String + value) { + parent.shapeType = value; + } + + final PropertyReflection triangleTypePart; + static + String + _triangleTypeGetter(EquilateralTriangle parent) { + return parent.triangleType; + } + static void _triangleTypeSetter(EquilateralTriangle parent, + String + value) { + parent.triangleType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + shapeTypePart, +triangleTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(EquilateralTriangle instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(EquilateralTriangle instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + final AllOfReflection allOfShapeInterfacePart; +final AllOfReflection allOfTriangleInterfacePart; + + + + @override + List> get allOfs => [ + allOfShapeInterfacePart,allOfTriangleInterfacePart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + EquilateralTriangle empty() { + return EquilateralTriangle( + shapeType: shapeTypePart.reflection.emptyFunction(), + triangleType: triangleTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is EquilateralTriangleReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_any_of_w_ith_same_erasure_get200_response.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_any_of_w_ith_same_erasure_get200_response.dart new file mode 100644 index 000000000000..48e85a197b15 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_any_of_w_ith_same_erasure_get200_response.dart @@ -0,0 +1,97 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'fake_any_of_w_ith_same_erasure_get200_response.reflection.dart'; + + +/// FakeAnyOfWIthSameErasureGet200ResponseMixin +mixin FakeAnyOfWIthSameErasureGet200ResponseMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + List< + + String +> +> get anyOf0; + UndefinedWrapper< + List< + + int +> +> get anyOf1; +} + +/// FakeAnyOfWIthSameErasureGet200Response +class FakeAnyOfWIthSameErasureGet200Response with +$OpenApiObjectMixin, + +FakeAnyOfWIthSameErasureGet200ResponseMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + List< + + String +> +> anyOf0; + + @override + UndefinedWrapper< + List< + + int +> +> anyOf1; + + + FakeAnyOfWIthSameErasureGet200Response.$all({ + required this.additionalProperties, + + required this.anyOf0, + required this.anyOf1, + }); + + FakeAnyOfWIthSameErasureGet200Response({ + AdditionalProperties? additionalProperties, + + this.anyOf0 = const UndefinedWrapper.undefined(), + + this.anyOf1 = const UndefinedWrapper.undefined(), + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = FakeAnyOfWIthSameErasureGet200ResponseReflection.instance; + FakeAnyOfWIthSameErasureGet200ResponseReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory FakeAnyOfWIthSameErasureGet200Response.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + FakeAnyOfWIthSameErasureGet200Response clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_any_of_w_ith_same_erasure_get200_response.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_any_of_w_ith_same_erasure_get200_response.reflection.dart new file mode 100644 index 000000000000..2f13eb69c9cc --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_any_of_w_ith_same_erasure_get200_response.reflection.dart @@ -0,0 +1,300 @@ +// Model reflection + +part of 'fake_any_of_w_ith_same_erasure_get200_response.dart'; + + +//class reflection + +class FakeAnyOfWIthSameErasureGet200ResponseReflection extends ModelReflection { + static FakeAnyOfWIthSameErasureGet200ResponseReflection instanceGetter() => instance; + static const instance = FakeAnyOfWIthSameErasureGet200ResponseReflection._( + modelName: r'_fake_anyOfWIthSameErasure_get_200_response', + className: r'FakeAnyOfWIthSameErasureGet200Response', + xml: XmlReflection( +), + + + anyOf0Part: FakeAnyOfWIthSameErasureGet200ResponseAnyOf0Part( + parentReflectionGetter: instanceGetter, + ), + + anyOf1Part: FakeAnyOfWIthSameErasureGet200ResponseAnyOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const FakeAnyOfWIthSameErasureGet200ResponseReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.anyOf0Part, + + required this.anyOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(FakeAnyOfWIthSameErasureGet200Response instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(FakeAnyOfWIthSameErasureGet200Response instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final FakeAnyOfWIthSameErasureGet200ResponseAnyOf0Part anyOf0Part; + + final FakeAnyOfWIthSameErasureGet200ResponseAnyOf1Part anyOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + anyOf0Part,anyOf1Part, + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + FakeAnyOfWIthSameErasureGet200Response empty() { + return FakeAnyOfWIthSameErasureGet200Response( + ); + } + + @override + bool operator ==(Object other) { + return other is FakeAnyOfWIthSameErasureGet200ResponseReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + +class FakeAnyOfWIthSameErasureGet200ResponseAnyOf0Part extends AnyOfReflection +> { + + const FakeAnyOfWIthSameErasureGet200ResponseAnyOf0Part({ + required FakeAnyOfWIthSameErasureGet200ResponseReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1 +>, FakeAnyOfWIthSameErasureGet200Response> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2 +>> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + List< + + String +> +> _getter(FakeAnyOfWIthSameErasureGet200Response src) { + return src.anyOf0; +} +static void _setter(FakeAnyOfWIthSameErasureGet200Response src, UndefinedWrapper< + List< + + String +> +> value) { + src.anyOf0 = value; +} + +@override +UndefinedWrapperReflection< + List< + + String +> +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) + + ), +); + + UndefinedWrapper< + List< + + String +> +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} +class FakeAnyOfWIthSameErasureGet200ResponseAnyOf1Part extends AnyOfReflection +> { + + const FakeAnyOfWIthSameErasureGet200ResponseAnyOf1Part({ + required FakeAnyOfWIthSameErasureGet200ResponseReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1 +>, FakeAnyOfWIthSameErasureGet200Response> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2 +>> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + List< + + int +> +> _getter(FakeAnyOfWIthSameErasureGet200Response src) { + return src.anyOf1; +} +static void _setter(FakeAnyOfWIthSameErasureGet200Response src, UndefinedWrapper< + List< + + int +> +> value) { + src.anyOf1 = value; +} + +@override +UndefinedWrapperReflection< + List< + + int +> +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +) + + ), +); + + UndefinedWrapper< + List< + + int +> +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_one_of_w_ith_same_erasure_get200_response.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_one_of_w_ith_same_erasure_get200_response.dart new file mode 100644 index 000000000000..2dd873721862 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_one_of_w_ith_same_erasure_get200_response.dart @@ -0,0 +1,100 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'fake_one_of_w_ith_same_erasure_get200_response.reflection.dart'; + + +/// FakeOneOfWIthSameErasureGet200ResponseMixin +mixin FakeOneOfWIthSameErasureGet200ResponseMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + List< + + String +> +> get oneOf0; + UndefinedWrapper< + List< + + int +> +> get oneOf1; +} + +/// FakeOneOfWIthSameErasureGet200Response +class FakeOneOfWIthSameErasureGet200Response with +$OpenApiObjectMixin, + +FakeOneOfWIthSameErasureGet200ResponseMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + List< + + String +> +> oneOf0; + + @override + UndefinedWrapper< + List< + + int +> +> oneOf1; + + + FakeOneOfWIthSameErasureGet200Response.$all({ + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + FakeOneOfWIthSameErasureGet200Response({ + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = FakeOneOfWIthSameErasureGet200ResponseReflection.instance; + FakeOneOfWIthSameErasureGet200ResponseReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory FakeOneOfWIthSameErasureGet200Response.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + FakeOneOfWIthSameErasureGet200Response clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_one_of_w_ith_same_erasure_get200_response.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_one_of_w_ith_same_erasure_get200_response.reflection.dart new file mode 100644 index 000000000000..368b902fd0f8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/fake_one_of_w_ith_same_erasure_get200_response.reflection.dart @@ -0,0 +1,318 @@ +// Model reflection + +part of 'fake_one_of_w_ith_same_erasure_get200_response.dart'; + + +//class reflection + +class FakeOneOfWIthSameErasureGet200ResponseReflection extends ModelReflection { + static FakeOneOfWIthSameErasureGet200ResponseReflection instanceGetter() => instance; + static const instance = FakeOneOfWIthSameErasureGet200ResponseReflection._( + modelName: r'_fake_oneOfWIthSameErasure_get_200_response', + className: r'FakeOneOfWIthSameErasureGet200Response', + xml: XmlReflection( +), + + + oneOf0Part: FakeOneOfWIthSameErasureGet200ResponseOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: FakeOneOfWIthSameErasureGet200ResponseOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const FakeOneOfWIthSameErasureGet200ResponseReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(FakeOneOfWIthSameErasureGet200Response instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(FakeOneOfWIthSameErasureGet200Response instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final FakeOneOfWIthSameErasureGet200ResponseOneOf0Part oneOf0Part; + + final FakeOneOfWIthSameErasureGet200ResponseOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + FakeOneOfWIthSameErasureGet200Response empty() { + return FakeOneOfWIthSameErasureGet200Response( + ); + } + + @override + bool operator ==(Object other) { + return other is FakeOneOfWIthSameErasureGet200ResponseReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class FakeOneOfWIthSameErasureGet200ResponseOneOf0Part extends OneOfReflection +> { + + const FakeOneOfWIthSameErasureGet200ResponseOneOf0Part({ + required FakeOneOfWIthSameErasureGet200ResponseReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1 +>, FakeOneOfWIthSameErasureGet200Response> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2 +>> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + List< + + String +> +> _getter(FakeOneOfWIthSameErasureGet200Response src) { + return src.oneOf0; +} +static void _setter(FakeOneOfWIthSameErasureGet200Response src, UndefinedWrapper< + List< + + String +> +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + List< + + String +> +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) + + ), +); + + UndefinedWrapper< + List< + + String +> +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class FakeOneOfWIthSameErasureGet200ResponseOneOf1Part extends OneOfReflection +> { + + const FakeOneOfWIthSameErasureGet200ResponseOneOf1Part({ + required FakeOneOfWIthSameErasureGet200ResponseReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1 +>, FakeOneOfWIthSameErasureGet200Response> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2 +>> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + List< + + int +> +> _getter(FakeOneOfWIthSameErasureGet200Response src) { + return src.oneOf1; +} +static void _setter(FakeOneOfWIthSameErasureGet200Response src, UndefinedWrapper< + List< + + int +> +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + List< + + int +> +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +) + + ), +); + + UndefinedWrapper< + List< + + int +> +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/file.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/file.dart new file mode 100644 index 000000000000..630ab8d55f64 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/file.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'file.reflection.dart'; + + +/// Must be named `File` for test. +/// +/// Properties: +/// * [sourceURI] - Test capitalization +mixin FileMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get sourceURI; + +} + +/// Must be named `File` for test. +/// +/// Properties: +/// * [sourceURI] - Test capitalization +class File with +$OpenApiObjectMixin, + +FileMixin { + @override + UndefinedWrapper< + String +> sourceURI; + + AdditionalProperties additionalProperties; + + + + File.$all({ + required this.sourceURI, + required this.additionalProperties, + + }); + + File({ + this.sourceURI = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = FileReflection.instance; + FileReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory File.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + File clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/file.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/file.reflection.dart new file mode 100644 index 000000000000..2cea6a79f122 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/file.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'file.dart'; + + +//class reflection + +class FileReflection extends ModelReflection { + static FileReflection instanceGetter() => instance; + static const instance = FileReflection._( + modelName: r'File', + className: r'File', + xml: XmlReflection( +), + sourceURIPart: PropertyReflection>( + dartName: r'sourceURI', + nullable: false, + required: false, + oasName: r'sourceURI', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_sourceURIGetter), + setter: FunctionWrapper2(_sourceURISetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const FileReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.sourceURIPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> sourceURIPart; + static UndefinedWrapper< + String +> _sourceURIGetter(File parent) { + return parent.sourceURI; + } + static void _sourceURISetter(File parent, UndefinedWrapper< + String +> value) { + parent.sourceURI = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + sourceURIPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(File instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(File instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + File empty() { + return File( + ); + } + + @override + bool operator ==(Object other) { + return other is FileReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/file_schema_test_class.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/file_schema_test_class.dart new file mode 100644 index 000000000000..90d0661b2192 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/file_schema_test_class.dart @@ -0,0 +1,106 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'file_schema_test_class.reflection.dart'; + + +/// FileSchemaTestClassMixin +/// +/// Properties: +/// * [file] +/// * [files] +mixin FileSchemaTestClassMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + File +> get file; +UndefinedWrapper< + List< + + File +> +> get files; + +} + +/// FileSchemaTestClass +/// +/// Properties: +/// * [file] +/// * [files] +class FileSchemaTestClass with +$OpenApiObjectMixin, + +FileSchemaTestClassMixin { + @override + UndefinedWrapper< + File +> file; + @override + UndefinedWrapper< + List< + + File +> +> files; + + AdditionalProperties additionalProperties; + + + + FileSchemaTestClass.$all({ + required this.file, + required this.files, + required this.additionalProperties, + + }); + + FileSchemaTestClass({ + this.file = const UndefinedWrapper + .undefined() +, + this.files = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = FileSchemaTestClassReflection.instance; + FileSchemaTestClassReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory FileSchemaTestClass.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + FileSchemaTestClass clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/file_schema_test_class.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/file_schema_test_class.reflection.dart new file mode 100644 index 000000000000..c8471dde5a88 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/file_schema_test_class.reflection.dart @@ -0,0 +1,207 @@ +// Model reflection + +part of 'file_schema_test_class.dart'; + + +//class reflection + +class FileSchemaTestClassReflection extends ModelReflection { + static FileSchemaTestClassReflection instanceGetter() => instance; + static const instance = FileSchemaTestClassReflection._( + modelName: r'FileSchemaTestClass', + className: r'FileSchemaTestClass', + xml: XmlReflection( +), + filePart: PropertyReflection>( + dartName: r'file', + nullable: false, + required: false, + oasName: r'file', + oasType: r'File', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_fileGetter), + setter: FunctionWrapper2(_fileSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + File.$reflection + +, +) +), + ), + filesPart: PropertyReflection +>>( + dartName: r'files', + nullable: false, + required: false, + oasName: r'files', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_filesGetter), + setter: FunctionWrapper2(_filesSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + File.$reflection + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const FileSchemaTestClassReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.filePart, + required this.filesPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> filePart; + static UndefinedWrapper< + File +> _fileGetter(FileSchemaTestClass parent) { + return parent.file; + } + static void _fileSetter(FileSchemaTestClass parent, UndefinedWrapper< + File +> value) { + parent.file = value; + } + + final PropertyReflection +>> filesPart; + static UndefinedWrapper< + List< + + File +> +> _filesGetter(FileSchemaTestClass parent) { + return parent.files; + } + static void _filesSetter(FileSchemaTestClass parent, UndefinedWrapper< + List< + + File +> +> value) { + parent.files = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + filePart, +filesPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(FileSchemaTestClass instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(FileSchemaTestClass instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + FileSchemaTestClass empty() { + return FileSchemaTestClass( + ); + } + + @override + bool operator ==(Object other) { + return other is FileSchemaTestClassReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/foo.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/foo.dart new file mode 100644 index 000000000000..306d0b4f770e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/foo.dart @@ -0,0 +1,86 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'foo.reflection.dart'; + + +/// FooMixin +/// +/// Properties: +/// * [bar] +mixin FooMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get bar; + +} + +/// Foo +/// +/// Properties: +/// * [bar] +class Foo with +$OpenApiObjectMixin, + +FooMixin { + @override + UndefinedWrapper< + String +> bar; + + AdditionalProperties additionalProperties; + + + + Foo.$all({ + required this.bar, + required this.additionalProperties, + + }); + + Foo({ + this.bar = const UndefinedWrapper + ( + + 'bar' + ) + +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = FooReflection.instance; + FooReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Foo.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Foo clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/foo.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/foo.reflection.dart new file mode 100644 index 000000000000..ecbb3188b73b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/foo.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'foo.dart'; + + +//class reflection + +class FooReflection extends ModelReflection { + static FooReflection instanceGetter() => instance; + static const instance = FooReflection._( + modelName: r'Foo', + className: r'Foo', + xml: XmlReflection( +), + barPart: PropertyReflection>( + dartName: r'bar', + nullable: false, + required: false, + oasName: r'bar', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_barGetter), + setter: FunctionWrapper2(_barSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const FooReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.barPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> barPart; + static UndefinedWrapper< + String +> _barGetter(Foo parent) { + return parent.bar; + } + static void _barSetter(Foo parent, UndefinedWrapper< + String +> value) { + parent.bar = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + barPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Foo instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Foo instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Foo empty() { + return Foo( + ); + } + + @override + bool operator ==(Object other) { + return other is FooReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/foo_get_default_response.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/foo_get_default_response.dart new file mode 100644 index 000000000000..b05ce84f2a0e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/foo_get_default_response.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'foo_get_default_response.reflection.dart'; + + +/// FooGetDefaultResponseMixin +/// +/// Properties: +/// * [string] +mixin FooGetDefaultResponseMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + Foo +> get string; + +} + +/// FooGetDefaultResponse +/// +/// Properties: +/// * [string] +class FooGetDefaultResponse with +$OpenApiObjectMixin, + +FooGetDefaultResponseMixin { + @override + UndefinedWrapper< + Foo +> string; + + AdditionalProperties additionalProperties; + + + + FooGetDefaultResponse.$all({ + required this.string, + required this.additionalProperties, + + }); + + FooGetDefaultResponse({ + this.string = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = FooGetDefaultResponseReflection.instance; + FooGetDefaultResponseReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory FooGetDefaultResponse.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + FooGetDefaultResponse clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/foo_get_default_response.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/foo_get_default_response.reflection.dart new file mode 100644 index 000000000000..50ea63713933 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/foo_get_default_response.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'foo_get_default_response.dart'; + + +//class reflection + +class FooGetDefaultResponseReflection extends ModelReflection { + static FooGetDefaultResponseReflection instanceGetter() => instance; + static const instance = FooGetDefaultResponseReflection._( + modelName: r'_foo_get_default_response', + className: r'FooGetDefaultResponse', + xml: XmlReflection( +), + stringPart: PropertyReflection>( + dartName: r'string', + nullable: false, + required: false, + oasName: r'string', + oasType: r'Foo', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_stringGetter), + setter: FunctionWrapper2(_stringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Foo.$reflection + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const FooGetDefaultResponseReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.stringPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> stringPart; + static UndefinedWrapper< + Foo +> _stringGetter(FooGetDefaultResponse parent) { + return parent.string; + } + static void _stringSetter(FooGetDefaultResponse parent, UndefinedWrapper< + Foo +> value) { + parent.string = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + stringPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(FooGetDefaultResponse instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(FooGetDefaultResponse instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + FooGetDefaultResponse empty() { + return FooGetDefaultResponse( + ); + } + + @override + bool operator ==(Object other) { + return other is FooGetDefaultResponseReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/format_test.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/format_test.dart new file mode 100644 index 000000000000..02f529af3401 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/format_test.dart @@ -0,0 +1,334 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'format_test.reflection.dart'; + + +/// FormatTestMixin +/// +/// Properties: +/// * [integer] +/// * [int32] +/// * [int64] +/// * [number] +/// * [float] +/// * [$double] +/// * [decimal] +/// * [string] +/// * [byte] +/// * [binary] +/// * [date] +/// * [dateTime] +/// * [uuid] +/// * [uuidWithDefault] +/// * [password] +/// * [patternWithDigits] - A string that is a 10 digit number. Can have leading zeros. +/// * [patternWithDigitsAndDelimiter] - A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. +mixin FormatTestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get integer; +UndefinedWrapper< + int +> get int32; +UndefinedWrapper< + int +> get int64; + + num + get number; +UndefinedWrapper< + double +> get float; +UndefinedWrapper< + double +> get $double; +UndefinedWrapper< + double +> get decimal; +UndefinedWrapper< + String +> get string; + + Uint8List + get byte; +UndefinedWrapper< + XFile +> get binary; + + DateTime + get date; +UndefinedWrapper< + DateTime +> get dateTime; +UndefinedWrapper< + String +> get uuid; +UndefinedWrapper< + String +> get uuidWithDefault; + + String + get password; +UndefinedWrapper< + String +> get patternWithDigits; +UndefinedWrapper< + String +> get patternWithDigitsAndDelimiter; + +} + +/// FormatTest +/// +/// Properties: +/// * [integer] +/// * [int32] +/// * [int64] +/// * [number] +/// * [float] +/// * [$double] +/// * [decimal] +/// * [string] +/// * [byte] +/// * [binary] +/// * [date] +/// * [dateTime] +/// * [uuid] +/// * [uuidWithDefault] +/// * [password] +/// * [patternWithDigits] - A string that is a 10 digit number. Can have leading zeros. +/// * [patternWithDigitsAndDelimiter] - A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. +class FormatTest with +$OpenApiObjectMixin, + +FormatTestMixin { + @override + UndefinedWrapper< + int +> integer; + @override + UndefinedWrapper< + int +> int32; + @override + UndefinedWrapper< + int +> int64; + @override + + num + number; + @override + UndefinedWrapper< + double +> float; + @override + UndefinedWrapper< + double +> $double; + @override + UndefinedWrapper< + double +> decimal; + @override + UndefinedWrapper< + String +> string; + @override + + Uint8List + byte; + @override + UndefinedWrapper< + XFile +> binary; + @override + + DateTime + date; + @override + UndefinedWrapper< + DateTime +> dateTime; + @override + UndefinedWrapper< + String +> uuid; + @override + UndefinedWrapper< + String +> uuidWithDefault; + @override + + String + password; + @override + UndefinedWrapper< + String +> patternWithDigits; + @override + UndefinedWrapper< + String +> patternWithDigitsAndDelimiter; + + AdditionalProperties additionalProperties; + + + + FormatTest.$all({ + required this.integer, + required this.int32, + required this.int64, + required this.number, + required this.float, + required this.$double, + required this.decimal, + required this.string, + required this.byte, + required this.binary, + required this.date, + required this.dateTime, + required this.uuid, + required this.uuidWithDefault, + required this.password, + required this.patternWithDigits, + required this.patternWithDigitsAndDelimiter, + required this.additionalProperties, + + }); + + FormatTest({ + this.integer = const UndefinedWrapper + .undefined() +, + this.int32 = const UndefinedWrapper + .undefined() +, + this.int64 = const UndefinedWrapper + .undefined() +, +required this.number , + this.float = const UndefinedWrapper + .undefined() +, + this.$double = const UndefinedWrapper + .undefined() +, + this.decimal = const UndefinedWrapper + .undefined() +, + this.string = const UndefinedWrapper + .undefined() +, +required this.byte , + this.binary = const UndefinedWrapper + .undefined() +, +required this.date , + this.dateTime = const UndefinedWrapper + .undefined() +, + this.uuid = const UndefinedWrapper + .undefined() +, + this.uuidWithDefault = const UndefinedWrapper + ( + + '11111111-206d-4f12-9f12-3d1e525a8e84' + ) + +, +required this.password , + this.patternWithDigits = const UndefinedWrapper + .undefined() +, + this.patternWithDigitsAndDelimiter = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = FormatTestReflection.instance; + FormatTestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory FormatTest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + FormatTest clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/format_test.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/format_test.reflection.dart new file mode 100644 index 000000000000..b55d25e636ce --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/format_test.reflection.dart @@ -0,0 +1,867 @@ +// Model reflection + +part of 'format_test.dart'; + + +//class reflection + +class FormatTestReflection extends ModelReflection { + static FormatTestReflection instanceGetter() => instance; + static const instance = FormatTestReflection._( + modelName: r'format_test', + className: r'FormatTest', + xml: XmlReflection( +), + integerPart: PropertyReflection>( + dartName: r'integer', + nullable: false, + required: false, + oasName: r'integer', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_integerGetter), + setter: FunctionWrapper2(_integerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + int32Part: PropertyReflection>( + dartName: r'int32', + nullable: false, + required: false, + oasName: r'int32', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_int32Getter), + setter: FunctionWrapper2(_int32Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + int64Part: PropertyReflection>( + dartName: r'int64', + nullable: false, + required: false, + oasName: r'int64', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_int64Getter), + setter: FunctionWrapper2(_int64Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + numberPart: PropertyReflection( + dartName: r'number', + nullable: false, + required: true, + oasName: r'number', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_numberGetter), + setter: FunctionWrapper2(_numberSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +, + ), + floatPart: PropertyReflection>( + dartName: r'float', + nullable: false, + required: false, + oasName: r'float', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_floatGetter), + setter: FunctionWrapper2(_floatSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fordouble + +, +) +), + ), + $doublePart: PropertyReflection>( + dartName: r'$double', + nullable: false, + required: false, + oasName: r'double', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_$doubleGetter), + setter: FunctionWrapper2(_$doubleSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fordouble + +, +) +), + ), + decimalPart: PropertyReflection>( + dartName: r'decimal', + nullable: false, + required: false, + oasName: r'decimal', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_decimalGetter), + setter: FunctionWrapper2(_decimalSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fordouble + +, +) +), + ), + stringPart: PropertyReflection>( + dartName: r'string', + nullable: false, + required: false, + oasName: r'string', + oasType: r'string', + pattern: r'/[a-z]/i', + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_stringGetter), + setter: FunctionWrapper2(_stringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + bytePart: PropertyReflection( + dartName: r'byte', + nullable: false, + required: true, + oasName: r'byte', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_byteGetter), + setter: FunctionWrapper2(_byteSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forUint8List + +, +) +, + ), + binaryPart: PropertyReflection>( + dartName: r'binary', + nullable: false, + required: false, + oasName: r'binary', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_binaryGetter), + setter: FunctionWrapper2(_binarySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forXFile + +, +) +), + ), + datePart: PropertyReflection( + dartName: r'date', + nullable: false, + required: true, + oasName: r'date', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_dateGetter), + setter: FunctionWrapper2(_dateSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +, + ), + dateTimePart: PropertyReflection>( + dartName: r'dateTime', + nullable: false, + required: false, + oasName: r'dateTime', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_dateTimeGetter), + setter: FunctionWrapper2(_dateTimeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +), + ), + uuidPart: PropertyReflection>( + dartName: r'uuid', + nullable: false, + required: false, + oasName: r'uuid', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_uuidGetter), + setter: FunctionWrapper2(_uuidSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + uuidWithDefaultPart: PropertyReflection>( + dartName: r'uuidWithDefault', + nullable: false, + required: false, + oasName: r'uuid_with_default', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_uuidWithDefaultGetter), + setter: FunctionWrapper2(_uuidWithDefaultSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + passwordPart: PropertyReflection( + dartName: r'password', + nullable: false, + required: true, + oasName: r'password', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_passwordGetter), + setter: FunctionWrapper2(_passwordSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + patternWithDigitsPart: PropertyReflection>( + dartName: r'patternWithDigits', + nullable: false, + required: false, + oasName: r'pattern_with_digits', + oasType: r'string', + pattern: r'/^\\d{10}$/', + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_patternWithDigitsGetter), + setter: FunctionWrapper2(_patternWithDigitsSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + patternWithDigitsAndDelimiterPart: PropertyReflection>( + dartName: r'patternWithDigitsAndDelimiter', + nullable: false, + required: false, + oasName: r'pattern_with_digits_and_delimiter', + oasType: r'string', + pattern: r'/^image_\\d{1,3}$/i', + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_patternWithDigitsAndDelimiterGetter), + setter: FunctionWrapper2(_patternWithDigitsAndDelimiterSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const FormatTestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.integerPart, + required this.int32Part, + required this.int64Part, + required this.numberPart, + required this.floatPart, + required this.$doublePart, + required this.decimalPart, + required this.stringPart, + required this.bytePart, + required this.binaryPart, + required this.datePart, + required this.dateTimePart, + required this.uuidPart, + required this.uuidWithDefaultPart, + required this.passwordPart, + required this.patternWithDigitsPart, + required this.patternWithDigitsAndDelimiterPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> integerPart; + static UndefinedWrapper< + int +> _integerGetter(FormatTest parent) { + return parent.integer; + } + static void _integerSetter(FormatTest parent, UndefinedWrapper< + int +> value) { + parent.integer = value; + } + + final PropertyReflection> int32Part; + static UndefinedWrapper< + int +> _int32Getter(FormatTest parent) { + return parent.int32; + } + static void _int32Setter(FormatTest parent, UndefinedWrapper< + int +> value) { + parent.int32 = value; + } + + final PropertyReflection> int64Part; + static UndefinedWrapper< + int +> _int64Getter(FormatTest parent) { + return parent.int64; + } + static void _int64Setter(FormatTest parent, UndefinedWrapper< + int +> value) { + parent.int64 = value; + } + + final PropertyReflection numberPart; + static + num + _numberGetter(FormatTest parent) { + return parent.number; + } + static void _numberSetter(FormatTest parent, + num + value) { + parent.number = value; + } + + final PropertyReflection> floatPart; + static UndefinedWrapper< + double +> _floatGetter(FormatTest parent) { + return parent.float; + } + static void _floatSetter(FormatTest parent, UndefinedWrapper< + double +> value) { + parent.float = value; + } + + final PropertyReflection> $doublePart; + static UndefinedWrapper< + double +> _$doubleGetter(FormatTest parent) { + return parent.$double; + } + static void _$doubleSetter(FormatTest parent, UndefinedWrapper< + double +> value) { + parent.$double = value; + } + + final PropertyReflection> decimalPart; + static UndefinedWrapper< + double +> _decimalGetter(FormatTest parent) { + return parent.decimal; + } + static void _decimalSetter(FormatTest parent, UndefinedWrapper< + double +> value) { + parent.decimal = value; + } + + final PropertyReflection> stringPart; + static UndefinedWrapper< + String +> _stringGetter(FormatTest parent) { + return parent.string; + } + static void _stringSetter(FormatTest parent, UndefinedWrapper< + String +> value) { + parent.string = value; + } + + final PropertyReflection bytePart; + static + Uint8List + _byteGetter(FormatTest parent) { + return parent.byte; + } + static void _byteSetter(FormatTest parent, + Uint8List + value) { + parent.byte = value; + } + + final PropertyReflection> binaryPart; + static UndefinedWrapper< + XFile +> _binaryGetter(FormatTest parent) { + return parent.binary; + } + static void _binarySetter(FormatTest parent, UndefinedWrapper< + XFile +> value) { + parent.binary = value; + } + + final PropertyReflection datePart; + static + DateTime + _dateGetter(FormatTest parent) { + return parent.date; + } + static void _dateSetter(FormatTest parent, + DateTime + value) { + parent.date = value; + } + + final PropertyReflection> dateTimePart; + static UndefinedWrapper< + DateTime +> _dateTimeGetter(FormatTest parent) { + return parent.dateTime; + } + static void _dateTimeSetter(FormatTest parent, UndefinedWrapper< + DateTime +> value) { + parent.dateTime = value; + } + + final PropertyReflection> uuidPart; + static UndefinedWrapper< + String +> _uuidGetter(FormatTest parent) { + return parent.uuid; + } + static void _uuidSetter(FormatTest parent, UndefinedWrapper< + String +> value) { + parent.uuid = value; + } + + final PropertyReflection> uuidWithDefaultPart; + static UndefinedWrapper< + String +> _uuidWithDefaultGetter(FormatTest parent) { + return parent.uuidWithDefault; + } + static void _uuidWithDefaultSetter(FormatTest parent, UndefinedWrapper< + String +> value) { + parent.uuidWithDefault = value; + } + + final PropertyReflection passwordPart; + static + String + _passwordGetter(FormatTest parent) { + return parent.password; + } + static void _passwordSetter(FormatTest parent, + String + value) { + parent.password = value; + } + + final PropertyReflection> patternWithDigitsPart; + static UndefinedWrapper< + String +> _patternWithDigitsGetter(FormatTest parent) { + return parent.patternWithDigits; + } + static void _patternWithDigitsSetter(FormatTest parent, UndefinedWrapper< + String +> value) { + parent.patternWithDigits = value; + } + + final PropertyReflection> patternWithDigitsAndDelimiterPart; + static UndefinedWrapper< + String +> _patternWithDigitsAndDelimiterGetter(FormatTest parent) { + return parent.patternWithDigitsAndDelimiter; + } + static void _patternWithDigitsAndDelimiterSetter(FormatTest parent, UndefinedWrapper< + String +> value) { + parent.patternWithDigitsAndDelimiter = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + integerPart, +int32Part, +int64Part, +numberPart, +floatPart, +$doublePart, +decimalPart, +stringPart, +bytePart, +binaryPart, +datePart, +dateTimePart, +uuidPart, +uuidWithDefaultPart, +passwordPart, +patternWithDigitsPart, +patternWithDigitsAndDelimiterPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(FormatTest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(FormatTest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + FormatTest empty() { + return FormatTest( + number: numberPart.reflection.emptyFunction(), + byte: bytePart.reflection.emptyFunction(), + date: datePart.reflection.emptyFunction(), + password: passwordPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is FormatTestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class.dart new file mode 100644 index 000000000000..9a6c2d6e9090 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'free_form_object_test_class.reflection.dart'; + + +/// FreeFormObjectTestClassMixin +/// +/// Properties: +/// * [name] +/// * [properties] +mixin FreeFormObjectTestClassMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get name; +UndefinedWrapper< + FreeFormObjectTestClassProperties +> get properties; + +} + +/// FreeFormObjectTestClass +/// +/// Properties: +/// * [name] +/// * [properties] +class FreeFormObjectTestClass with +$OpenApiObjectMixin, + +FreeFormObjectTestClassMixin { + @override + UndefinedWrapper< + String +> name; + @override + UndefinedWrapper< + FreeFormObjectTestClassProperties +> properties; + + AdditionalProperties additionalProperties; + + + + FreeFormObjectTestClass.$all({ + required this.name, + required this.properties, + required this.additionalProperties, + + }); + + FreeFormObjectTestClass({ + this.name = const UndefinedWrapper + .undefined() +, + this.properties = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = FreeFormObjectTestClassReflection.instance; + FreeFormObjectTestClassReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory FreeFormObjectTestClass.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + FreeFormObjectTestClass clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class.reflection.dart new file mode 100644 index 000000000000..c60d43a856df --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class.reflection.dart @@ -0,0 +1,188 @@ +// Model reflection + +part of 'free_form_object_test_class.dart'; + + +//class reflection + +class FreeFormObjectTestClassReflection extends ModelReflection { + static FreeFormObjectTestClassReflection instanceGetter() => instance; + static const instance = FreeFormObjectTestClassReflection._( + modelName: r'FreeFormObjectTestClass', + className: r'FreeFormObjectTestClass', + xml: XmlReflection( +), + namePart: PropertyReflection>( + dartName: r'name', + nullable: false, + required: false, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + propertiesPart: PropertyReflection>( + dartName: r'properties', + nullable: false, + required: false, + oasName: r'properties', + oasType: r'FreeFormObjectTestClassProperties', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_propertiesGetter), + setter: FunctionWrapper2(_propertiesSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + FreeFormObjectTestClassProperties.$reflection + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const FreeFormObjectTestClassReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.namePart, + required this.propertiesPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> namePart; + static UndefinedWrapper< + String +> _nameGetter(FreeFormObjectTestClass parent) { + return parent.name; + } + static void _nameSetter(FreeFormObjectTestClass parent, UndefinedWrapper< + String +> value) { + parent.name = value; + } + + final PropertyReflection> propertiesPart; + static UndefinedWrapper< + FreeFormObjectTestClassProperties +> _propertiesGetter(FreeFormObjectTestClass parent) { + return parent.properties; + } + static void _propertiesSetter(FreeFormObjectTestClass parent, UndefinedWrapper< + FreeFormObjectTestClassProperties +> value) { + parent.properties = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + namePart, +propertiesPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(FreeFormObjectTestClass instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(FreeFormObjectTestClass instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + FreeFormObjectTestClass empty() { + return FreeFormObjectTestClass( + ); + } + + @override + bool operator ==(Object other) { + return other is FreeFormObjectTestClassReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class_properties.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class_properties.dart new file mode 100644 index 000000000000..68188b0e825d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class_properties.dart @@ -0,0 +1,92 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'free_form_object_test_class_properties.reflection.dart'; + + +/// FreeFormObjectTestClassPropertiesMixin +mixin FreeFormObjectTestClassPropertiesMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + String +> get oneOf0; + UndefinedWrapper< + Map +> get oneOf1; +} + +/// FreeFormObjectTestClassProperties +class FreeFormObjectTestClassProperties with +$OpenApiObjectMixin, + +FreeFormObjectTestClassPropertiesMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + String +> oneOf0; + + @override + UndefinedWrapper< + Map +> oneOf1; + + + FreeFormObjectTestClassProperties.$all({ + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + FreeFormObjectTestClassProperties({ + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = FreeFormObjectTestClassPropertiesReflection.instance; + FreeFormObjectTestClassPropertiesReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory FreeFormObjectTestClassProperties.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + FreeFormObjectTestClassProperties clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class_properties.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class_properties.reflection.dart new file mode 100644 index 000000000000..70f6220ca347 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/free_form_object_test_class_properties.reflection.dart @@ -0,0 +1,277 @@ +// Model reflection + +part of 'free_form_object_test_class_properties.dart'; + + +//class reflection + +class FreeFormObjectTestClassPropertiesReflection extends ModelReflection { + static FreeFormObjectTestClassPropertiesReflection instanceGetter() => instance; + static const instance = FreeFormObjectTestClassPropertiesReflection._( + modelName: r'FreeFormObjectTestClass_properties', + className: r'FreeFormObjectTestClassProperties', + xml: XmlReflection( +), + + + oneOf0Part: FreeFormObjectTestClassPropertiesOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: FreeFormObjectTestClassPropertiesOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const FreeFormObjectTestClassPropertiesReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(FreeFormObjectTestClassProperties instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(FreeFormObjectTestClassProperties instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final FreeFormObjectTestClassPropertiesOneOf0Part oneOf0Part; + + final FreeFormObjectTestClassPropertiesOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + FreeFormObjectTestClassProperties empty() { + return FreeFormObjectTestClassProperties( + ); + } + + @override + bool operator ==(Object other) { + return other is FreeFormObjectTestClassPropertiesReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class FreeFormObjectTestClassPropertiesOneOf0Part extends OneOfReflection { + + const FreeFormObjectTestClassPropertiesOneOf0Part({ + required FreeFormObjectTestClassPropertiesReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, FreeFormObjectTestClassProperties> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + String +> _getter(FreeFormObjectTestClassProperties src) { + return src.oneOf0; +} +static void _setter(FreeFormObjectTestClassProperties src, UndefinedWrapper< + String +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + String +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + + + ), +); + + UndefinedWrapper< + String +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class FreeFormObjectTestClassPropertiesOneOf1Part extends OneOfReflection +> { + + const FreeFormObjectTestClassPropertiesOneOf1Part({ + required FreeFormObjectTestClassPropertiesReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1 +>, FreeFormObjectTestClassProperties> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2 +>> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Map +> _getter(FreeFormObjectTestClassProperties src) { + return src.oneOf1; +} +static void _setter(FreeFormObjectTestClassProperties src, UndefinedWrapper< + Map +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + Map +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +) + + ), +); + + UndefinedWrapper< + Map +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit.dart new file mode 100644 index 000000000000..93b18c467d24 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit.dart @@ -0,0 +1,106 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'fruit.reflection.dart'; + + +/// FruitMixin +/// +/// Properties: +/// * [color] +mixin FruitMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get color; + + UndefinedWrapper< + Apple +> get oneOf0; + UndefinedWrapper< + Banana +> get oneOf1; +} + +/// Fruit +/// +/// Properties: +/// * [color] +class Fruit with +$OpenApiObjectMixin, + +FruitMixin { + @override + UndefinedWrapper< + String +> color; + + + + + @override + UndefinedWrapper< + Apple +> oneOf0; + + @override + UndefinedWrapper< + Banana +> oneOf1; + + + Fruit.$all({ + required this.color, + + + required this.oneOf0, + required this.oneOf1, + }); + + Fruit({ + this.color = const UndefinedWrapper + .undefined() +, + + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }); + + static const $reflection = FruitReflection.instance; + FruitReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory Fruit.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Fruit clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit.reflection.dart new file mode 100644 index 000000000000..46d53863d3b9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit.reflection.dart @@ -0,0 +1,282 @@ +// Model reflection + +part of 'fruit.dart'; + + +//class reflection + +class FruitReflection extends ModelReflection { + static FruitReflection instanceGetter() => instance; + static const instance = FruitReflection._( + modelName: r'fruit', + className: r'Fruit', + xml: XmlReflection( +), + colorPart: PropertyReflection>( + dartName: r'color', + nullable: false, + required: false, + oasName: r'color', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_colorGetter), + setter: FunctionWrapper2(_colorSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + oneOf0Part: FruitOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: FruitOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + ); + const FruitReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.colorPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + }); + + final PropertyReflection> colorPart; + static UndefinedWrapper< + String +> _colorGetter(Fruit parent) { + return parent.color; + } + static void _colorSetter(Fruit parent, UndefinedWrapper< + String +> value) { + parent.color = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + colorPart, + ]; + + + + + final FruitOneOf0Part oneOf0Part; + + final FruitOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Fruit empty() { + return Fruit( + ); + } + + @override + bool operator ==(Object other) { + return other is FruitReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class FruitOneOf0Part extends OneOfReflection { + + const FruitOneOf0Part({ + required FruitReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Fruit> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Apple +> _getter(Fruit src) { + return src.oneOf0; +} +static void _setter(Fruit src, UndefinedWrapper< + Apple +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + Apple +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Apple.$reflection + + + ), +); + + UndefinedWrapper< + Apple +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class FruitOneOf1Part extends OneOfReflection { + + const FruitOneOf1Part({ + required FruitReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Fruit> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Banana +> _getter(Fruit src) { + return src.oneOf1; +} +static void _setter(Fruit src, UndefinedWrapper< + Banana +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + Banana +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Banana.$reflection + + + ), +); + + UndefinedWrapper< + Banana +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit_req.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit_req.dart new file mode 100644 index 000000000000..9fe21b08caed --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit_req.dart @@ -0,0 +1,90 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'fruit_req.reflection.dart'; + + +/// FruitReqMixin +/// +/// Properties: +mixin FruitReqMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + AppleReq +> get oneOf0; + UndefinedWrapper< + BananaReq +> get oneOf1; +} + +/// FruitReq +/// +/// Properties: +class FruitReq with +$OpenApiObjectMixin, + +FruitReqMixin { + + + + + @override + UndefinedWrapper< + AppleReq +> oneOf0; + + @override + UndefinedWrapper< + BananaReq +> oneOf1; + + + FruitReq.$all({ + + + required this.oneOf0, + required this.oneOf1, + }); + + FruitReq({ + + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }); + + static const $reflection = FruitReqReflection.instance; + FruitReqReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory FruitReq.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + FruitReq clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit_req.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit_req.reflection.dart new file mode 100644 index 000000000000..12482c59bf1a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/fruit_req.reflection.dart @@ -0,0 +1,237 @@ +// Model reflection + +part of 'fruit_req.dart'; + + +//class reflection + +class FruitReqReflection extends ModelReflection { + static FruitReqReflection instanceGetter() => instance; + static const instance = FruitReqReflection._( + modelName: r'fruitReq', + className: r'FruitReq', + xml: XmlReflection( +), + + + oneOf0Part: FruitReqOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: FruitReqOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + ); + const FruitReqReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + + + + final FruitReqOneOf0Part oneOf0Part; + + final FruitReqOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + FruitReq empty() { + return FruitReq( + ); + } + + @override + bool operator ==(Object other) { + return other is FruitReqReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class FruitReqOneOf0Part extends OneOfReflection { + + const FruitReqOneOf0Part({ + required FruitReqReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, FruitReq> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + AppleReq +> _getter(FruitReq src) { + return src.oneOf0; +} +static void _setter(FruitReq src, UndefinedWrapper< + AppleReq +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + AppleReq +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + AppleReq.$reflection + + + ), +); + + UndefinedWrapper< + AppleReq +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class FruitReqOneOf1Part extends OneOfReflection { + + const FruitReqOneOf1Part({ + required FruitReqReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, FruitReq> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + BananaReq +> _getter(FruitReq src) { + return src.oneOf1; +} +static void _setter(FruitReq src, UndefinedWrapper< + BananaReq +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + BananaReq +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + BananaReq.$reflection + + + ), +); + + UndefinedWrapper< + BananaReq +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/gm_fruit.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/gm_fruit.dart new file mode 100644 index 000000000000..b95c6cfbb88a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/gm_fruit.dart @@ -0,0 +1,103 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'gm_fruit.reflection.dart'; + + +/// GmFruitMixin +/// +/// Properties: +/// * [color] +mixin GmFruitMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get color; + + UndefinedWrapper< + Apple +> get anyOf0; + UndefinedWrapper< + Banana +> get anyOf1; +} + +/// GmFruit +/// +/// Properties: +/// * [color] +class GmFruit with +$OpenApiObjectMixin, + +GmFruitMixin { + @override + UndefinedWrapper< + String +> color; + + + + + @override + UndefinedWrapper< + Apple +> anyOf0; + + @override + UndefinedWrapper< + Banana +> anyOf1; + + + GmFruit.$all({ + required this.color, + + + required this.anyOf0, + required this.anyOf1, + }); + + GmFruit({ + this.color = const UndefinedWrapper + .undefined() +, + + + this.anyOf0 = const UndefinedWrapper.undefined(), + + this.anyOf1 = const UndefinedWrapper.undefined(), + + }); + + static const $reflection = GmFruitReflection.instance; + GmFruitReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory GmFruit.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + GmFruit clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/gm_fruit.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/gm_fruit.reflection.dart new file mode 100644 index 000000000000..613730114424 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/gm_fruit.reflection.dart @@ -0,0 +1,264 @@ +// Model reflection + +part of 'gm_fruit.dart'; + + +//class reflection + +class GmFruitReflection extends ModelReflection { + static GmFruitReflection instanceGetter() => instance; + static const instance = GmFruitReflection._( + modelName: r'gmFruit', + className: r'GmFruit', + xml: XmlReflection( +), + colorPart: PropertyReflection>( + dartName: r'color', + nullable: false, + required: false, + oasName: r'color', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_colorGetter), + setter: FunctionWrapper2(_colorSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + anyOf0Part: GmFruitAnyOf0Part( + parentReflectionGetter: instanceGetter, + ), + + anyOf1Part: GmFruitAnyOf1Part( + parentReflectionGetter: instanceGetter, + ), + + ); + const GmFruitReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.colorPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.anyOf0Part, + + required this.anyOf1Part, + + }); + + final PropertyReflection> colorPart; + static UndefinedWrapper< + String +> _colorGetter(GmFruit parent) { + return parent.color; + } + static void _colorSetter(GmFruit parent, UndefinedWrapper< + String +> value) { + parent.color = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + colorPart, + ]; + + + + + final GmFruitAnyOf0Part anyOf0Part; + + final GmFruitAnyOf1Part anyOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + anyOf0Part,anyOf1Part, + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + GmFruit empty() { + return GmFruit( + ); + } + + @override + bool operator ==(Object other) { + return other is GmFruitReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + +class GmFruitAnyOf0Part extends AnyOfReflection { + + const GmFruitAnyOf0Part({ + required GmFruitReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, GmFruit> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Apple +> _getter(GmFruit src) { + return src.anyOf0; +} +static void _setter(GmFruit src, UndefinedWrapper< + Apple +> value) { + src.anyOf0 = value; +} + +@override +UndefinedWrapperReflection< + Apple +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Apple.$reflection + + + ), +); + + UndefinedWrapper< + Apple +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} +class GmFruitAnyOf1Part extends AnyOfReflection { + + const GmFruitAnyOf1Part({ + required GmFruitReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, GmFruit> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Banana +> _getter(GmFruit src) { + return src.anyOf1; +} +static void _setter(GmFruit src, UndefinedWrapper< + Banana +> value) { + src.anyOf1 = value; +} + +@override +UndefinedWrapperReflection< + Banana +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Banana.$reflection + + + ), +); + + UndefinedWrapper< + Banana +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/grandparent_animal.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/grandparent_animal.dart new file mode 100644 index 000000000000..2a3ad2c8333c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/grandparent_animal.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'grandparent_animal.reflection.dart'; + + +/// GrandparentAnimalMixin +/// +/// Properties: +/// * [petType] +mixin GrandparentAnimalMixin on + $OpenApiObjectMixin { + + String + get petType; + +} + +/// GrandparentAnimal +/// +/// Properties: +/// * [petType] +class GrandparentAnimal with +$OpenApiObjectMixin, + +GrandparentAnimalMixin { + @override + + String + petType; + + AdditionalProperties additionalProperties; + + + + GrandparentAnimal.$all({ + required this.petType, + required this.additionalProperties, + + }); + + GrandparentAnimal({ + required this.petType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = GrandparentAnimalReflection.instance; + GrandparentAnimalReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory GrandparentAnimal.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + GrandparentAnimal clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/grandparent_animal.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/grandparent_animal.reflection.dart new file mode 100644 index 000000000000..fe3ba288f3c7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/grandparent_animal.reflection.dart @@ -0,0 +1,149 @@ +// Model reflection + +part of 'grandparent_animal.dart'; + + +//class reflection + +class GrandparentAnimalReflection extends ModelReflection { + static GrandparentAnimalReflection instanceGetter() => instance; + static const instance = GrandparentAnimalReflection._( + modelName: r'GrandparentAnimal', + className: r'GrandparentAnimal', + xml: XmlReflection( +), + petTypePart: PropertyReflection( + dartName: r'petType', + nullable: false, + required: true, + oasName: r'pet_type', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_petTypeGetter), + setter: FunctionWrapper2(_petTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + discriminatorKey: r'pet_type', + discriminatorImplicitMappings: const { + }, + discriminatorMappings: const { + }, + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const GrandparentAnimalReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.petTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection petTypePart; + static + String + _petTypeGetter(GrandparentAnimal parent) { + return parent.petType; + } + static void _petTypeSetter(GrandparentAnimal parent, + String + value) { + parent.petType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + petTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(GrandparentAnimal instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(GrandparentAnimal instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + GrandparentAnimal empty() { + return GrandparentAnimal( + petType: petTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is GrandparentAnimalReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/has_only_read_only.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/has_only_read_only.dart new file mode 100644 index 000000000000..360b56558daf --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/has_only_read_only.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'has_only_read_only.reflection.dart'; + + +/// HasOnlyReadOnlyMixin +/// +/// Properties: +/// * [bar] +/// * [foo] +mixin HasOnlyReadOnlyMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get bar; +UndefinedWrapper< + String +> get foo; + +} + +/// HasOnlyReadOnly +/// +/// Properties: +/// * [bar] +/// * [foo] +class HasOnlyReadOnly with +$OpenApiObjectMixin, + +HasOnlyReadOnlyMixin { + @override + UndefinedWrapper< + String +> bar; + @override + UndefinedWrapper< + String +> foo; + + AdditionalProperties additionalProperties; + + + + HasOnlyReadOnly.$all({ + required this.bar, + required this.foo, + required this.additionalProperties, + + }); + + HasOnlyReadOnly({ + this.bar = const UndefinedWrapper + .undefined() +, + this.foo = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = HasOnlyReadOnlyReflection.instance; + HasOnlyReadOnlyReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory HasOnlyReadOnly.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + HasOnlyReadOnly clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/has_only_read_only.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/has_only_read_only.reflection.dart new file mode 100644 index 000000000000..d712966d9224 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/has_only_read_only.reflection.dart @@ -0,0 +1,188 @@ +// Model reflection + +part of 'has_only_read_only.dart'; + + +//class reflection + +class HasOnlyReadOnlyReflection extends ModelReflection { + static HasOnlyReadOnlyReflection instanceGetter() => instance; + static const instance = HasOnlyReadOnlyReflection._( + modelName: r'hasOnlyReadOnly', + className: r'HasOnlyReadOnly', + xml: XmlReflection( +), + barPart: PropertyReflection>( + dartName: r'bar', + nullable: false, + required: false, + oasName: r'bar', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_barGetter), + setter: FunctionWrapper2(_barSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + fooPart: PropertyReflection>( + dartName: r'foo', + nullable: false, + required: false, + oasName: r'foo', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_fooGetter), + setter: FunctionWrapper2(_fooSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const HasOnlyReadOnlyReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.barPart, + required this.fooPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> barPart; + static UndefinedWrapper< + String +> _barGetter(HasOnlyReadOnly parent) { + return parent.bar; + } + static void _barSetter(HasOnlyReadOnly parent, UndefinedWrapper< + String +> value) { + parent.bar = value; + } + + final PropertyReflection> fooPart; + static UndefinedWrapper< + String +> _fooGetter(HasOnlyReadOnly parent) { + return parent.foo; + } + static void _fooSetter(HasOnlyReadOnly parent, UndefinedWrapper< + String +> value) { + parent.foo = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + barPart, +fooPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(HasOnlyReadOnly instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(HasOnlyReadOnly instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + HasOnlyReadOnly empty() { + return HasOnlyReadOnly( + ); + } + + @override + bool operator ==(Object other) { + return other is HasOnlyReadOnlyReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/health_check_result.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/health_check_result.dart new file mode 100644 index 000000000000..995c0f590e08 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/health_check_result.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'health_check_result.reflection.dart'; + + +/// Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. +/// +/// Properties: +/// * [nullableMessage] +mixin HealthCheckResultMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +?> get nullableMessage; + +} + +/// Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. +/// +/// Properties: +/// * [nullableMessage] +class HealthCheckResult with +$OpenApiObjectMixin, + +HealthCheckResultMixin { + @override + UndefinedWrapper< + String +?> nullableMessage; + + AdditionalProperties additionalProperties; + + + + HealthCheckResult.$all({ + required this.nullableMessage, + required this.additionalProperties, + + }); + + HealthCheckResult({ + this.nullableMessage = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = HealthCheckResultReflection.instance; + HealthCheckResultReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory HealthCheckResult.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + HealthCheckResult clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/health_check_result.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/health_check_result.reflection.dart new file mode 100644 index 000000000000..fc8399046b5f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/health_check_result.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'health_check_result.dart'; + + +//class reflection + +class HealthCheckResultReflection extends ModelReflection { + static HealthCheckResultReflection instanceGetter() => instance; + static const instance = HealthCheckResultReflection._( + modelName: r'HealthCheckResult', + className: r'HealthCheckResult', + xml: XmlReflection( +), + nullableMessagePart: PropertyReflection>( + dartName: r'nullableMessage', + nullable: true, + required: false, + oasName: r'NullableMessage', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nullableMessageGetter), + setter: FunctionWrapper2(_nullableMessageSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.forString + +), +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const HealthCheckResultReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.nullableMessagePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> nullableMessagePart; + static UndefinedWrapper< + String +?> _nullableMessageGetter(HealthCheckResult parent) { + return parent.nullableMessage; + } + static void _nullableMessageSetter(HealthCheckResult parent, UndefinedWrapper< + String +?> value) { + parent.nullableMessage = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + nullableMessagePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(HealthCheckResult instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(HealthCheckResult instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + HealthCheckResult empty() { + return HealthCheckResult( + ); + } + + @override + bool operator ==(Object other) { + return other is HealthCheckResultReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/isosceles_triangle.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/isosceles_triangle.dart new file mode 100644 index 000000000000..f3081bbcb30a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/isosceles_triangle.dart @@ -0,0 +1,79 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'isosceles_triangle.reflection.dart'; + + +/// IsoscelesTriangleMixin +/// +/// Properties: +mixin IsoscelesTriangleMixin on + ShapeInterfaceMixin, TriangleInterfaceMixin, $OpenApiObjectMixin { + +} + +/// IsoscelesTriangle +/// +/// Properties: +/// * [shapeType] +/// * [triangleType] +class IsoscelesTriangle with +$OpenApiObjectMixin, +ShapeInterfaceMixin,TriangleInterfaceMixin, +IsoscelesTriangleMixin { + @override + + String + shapeType; + @override + + String + triangleType; + + + + + + IsoscelesTriangle.$all({ + required this.shapeType, + required this.triangleType, + + + }); + + IsoscelesTriangle({ + required this.shapeType , +required this.triangleType , + + + }); + + static const $reflection = IsoscelesTriangleReflection.instance; + IsoscelesTriangleReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory IsoscelesTriangle.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + IsoscelesTriangle clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/isosceles_triangle.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/isosceles_triangle.reflection.dart new file mode 100644 index 000000000000..b9a70e11c474 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/isosceles_triangle.reflection.dart @@ -0,0 +1,185 @@ +// Model reflection + +part of 'isosceles_triangle.dart'; + + +//class reflection + +class IsoscelesTriangleReflection extends ModelReflection { + static IsoscelesTriangleReflection instanceGetter() => instance; + static const instance = IsoscelesTriangleReflection._( + modelName: r'IsoscelesTriangle', + className: r'IsoscelesTriangle', + xml: XmlReflection( +), + shapeTypePart: PropertyReflection( + dartName: r'shapeType', + nullable: false, + required: true, + oasName: r'shapeType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_shapeTypeGetter), + setter: FunctionWrapper2(_shapeTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + triangleTypePart: PropertyReflection( + dartName: r'triangleType', + nullable: false, + required: true, + oasName: r'triangleType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_triangleTypeGetter), + setter: FunctionWrapper2(_triangleTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + allOfShapeInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: ShapeInterfaceReflection.instance, + ), +allOfTriangleInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: TriangleInterfaceReflection.instance, + ), + + + ); + const IsoscelesTriangleReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.shapeTypePart, + required this.triangleTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfShapeInterfacePart, +required this.allOfTriangleInterfacePart, + + }); + + final PropertyReflection shapeTypePart; + static + String + _shapeTypeGetter(IsoscelesTriangle parent) { + return parent.shapeType; + } + static void _shapeTypeSetter(IsoscelesTriangle parent, + String + value) { + parent.shapeType = value; + } + + final PropertyReflection triangleTypePart; + static + String + _triangleTypeGetter(IsoscelesTriangle parent) { + return parent.triangleType; + } + static void _triangleTypeSetter(IsoscelesTriangle parent, + String + value) { + parent.triangleType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + shapeTypePart, +triangleTypePart, + ]; + + + final AllOfReflection allOfShapeInterfacePart; +final AllOfReflection allOfTriangleInterfacePart; + + + + @override + List> get allOfs => [ + allOfShapeInterfacePart,allOfTriangleInterfacePart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + IsoscelesTriangle empty() { + return IsoscelesTriangle( + shapeType: shapeTypePart.reflection.emptyFunction(), + triangleType: triangleTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is IsoscelesTriangleReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mammal.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mammal.dart new file mode 100644 index 000000000000..0c56ed007642 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mammal.dart @@ -0,0 +1,116 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'mammal.reflection.dart'; + + +/// MammalMixin +/// +/// Properties: +/// * [className] +mixin MammalMixin on + $OpenApiObjectMixin { + + String + get className; + + UndefinedWrapper< + Whale +> get oneOf0; + UndefinedWrapper< + Zebra +> get oneOf1; + UndefinedWrapper< + Pig +> get oneOf2; +} + +/// Mammal +/// +/// Properties: +/// * [className] +class Mammal with +$OpenApiObjectMixin, + +MammalMixin { + @override + + String + className; + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + Whale +> oneOf0; + + @override + UndefinedWrapper< + Zebra +> oneOf1; + + @override + UndefinedWrapper< + Pig +> oneOf2; + + + Mammal.$all({ + required this.className, + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + required this.oneOf2, + }); + + Mammal({ + required this.className , + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + this.oneOf2 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = MammalReflection.instance; + MammalReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,oneOf2,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory Mammal.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Mammal clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mammal.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mammal.reflection.dart new file mode 100644 index 000000000000..9aafd97ae4b5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mammal.reflection.dart @@ -0,0 +1,397 @@ +// Model reflection + +part of 'mammal.dart'; + + +//class reflection + +class MammalReflection extends ModelReflection { + static MammalReflection instanceGetter() => instance; + static const instance = MammalReflection._( + modelName: r'mammal', + className: r'Mammal', + xml: XmlReflection( +), + classNamePart: PropertyReflection( + dartName: r'className', + nullable: false, + required: true, + oasName: r'className', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_classNameGetter), + setter: FunctionWrapper2(_classNameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + discriminatorKey: r'className', + discriminatorImplicitMappings: const { + r'Pig': PigReflection.instance, + r'Whale': WhaleReflection.instance, + r'Zebra': ZebraReflection.instance, + }, + discriminatorMappings: const { + r'Pig': PigReflection.instance, + r'whale': WhaleReflection.instance, + r'zebra': ZebraReflection.instance, + }, + + + oneOf0Part: MammalOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: MammalOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf2Part: MammalOneOf2Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const MammalReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.classNamePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.oneOf2Part, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection classNamePart; + static + String + _classNameGetter(Mammal parent) { + return parent.className; + } + static void _classNameSetter(Mammal parent, + String + value) { + parent.className = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + classNamePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Mammal instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Mammal instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final MammalOneOf0Part oneOf0Part; + + final MammalOneOf1Part oneOf1Part; + + final MammalOneOf2Part oneOf2Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part,oneOf2Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Mammal empty() { + return Mammal( + className: classNamePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is MammalReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class MammalOneOf0Part extends OneOfReflection { + + const MammalOneOf0Part({ + required MammalReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Mammal> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Whale +> _getter(Mammal src) { + return src.oneOf0; +} +static void _setter(Mammal src, UndefinedWrapper< + Whale +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + Whale +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Whale.$reflection + + + ), +); + + UndefinedWrapper< + Whale +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class MammalOneOf1Part extends OneOfReflection { + + const MammalOneOf1Part({ + required MammalReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Mammal> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Zebra +> _getter(Mammal src) { + return src.oneOf1; +} +static void _setter(Mammal src, UndefinedWrapper< + Zebra +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + Zebra +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Zebra.$reflection + + + ), +); + + UndefinedWrapper< + Zebra +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class MammalOneOf2Part extends OneOfReflection { + + const MammalOneOf2Part({ + required MammalReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Mammal> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Pig +> _getter(Mammal src) { + return src.oneOf2; +} +static void _setter(Mammal src, UndefinedWrapper< + Pig +> value) { + src.oneOf2 = value; +} + +@override +UndefinedWrapperReflection< + Pig +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Pig.$reflection + + + ), +); + + UndefinedWrapper< + Pig +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/map_test.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/map_test.dart new file mode 100644 index 000000000000..2222cc6f57df --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/map_test.dart @@ -0,0 +1,215 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'map_test.reflection.dart'; + + +/// MapTestMixin +/// +/// Properties: +/// * [mapMapOfString] +/// * [mapOfEnumString] +/// * [directMap] +/// * [indirectMap] +mixin MapTestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + Map +> +> get mapMapOfString; +UndefinedWrapper< + Map +> get mapOfEnumString; +UndefinedWrapper< + Map +> get directMap; +UndefinedWrapper< + Map +> get indirectMap; + +} + +/// MapTest +/// +/// Properties: +/// * [mapMapOfString] +/// * [mapOfEnumString] +/// * [directMap] +/// * [indirectMap] +class MapTest with +$OpenApiObjectMixin, + +MapTestMixin { + @override + UndefinedWrapper< + Map +> +> mapMapOfString; + @override + UndefinedWrapper< + Map +> mapOfEnumString; + @override + UndefinedWrapper< + Map +> directMap; + @override + UndefinedWrapper< + Map +> indirectMap; + + AdditionalProperties additionalProperties; + + + + MapTest.$all({ + required this.mapMapOfString, + required this.mapOfEnumString, + required this.directMap, + required this.indirectMap, + required this.additionalProperties, + + }); + + MapTest({ + this.mapMapOfString = const UndefinedWrapper + .undefined() +, + this.mapOfEnumString = const UndefinedWrapper + .undefined() +, + this.directMap = const UndefinedWrapper + .undefined() +, + this.indirectMap = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = MapTestReflection.instance; + MapTestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory MapTest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + MapTest clone() { + return $reflection.clone(this); + } +} + + + + + + + + + +extension type const MapTestMapOfEnumStringEnum._(String value) implements String { + const MapTestMapOfEnumStringEnum.UPPER() : this._(r'UPPER'); + const MapTestMapOfEnumStringEnum.lower() : this._(r'lower'); + + /// Creates a [MapTestMapOfEnumStringEnum] enum from a value and safely checking if it exists. + factory MapTestMapOfEnumStringEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'UPPER', oasValue: r'UPPER', value: MapTestMapOfEnumStringEnum.UPPER()), + + EnumMemberReflection(dartName: r'lower', oasValue: r'lower', value: MapTestMapOfEnumStringEnum.lower()), + + ], + ); + + factory MapTestMapOfEnumStringEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [MapTestMapOfEnumStringEnum] enum from a value without checking if it exists. + const MapTestMapOfEnumStringEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + MapTestMapOfEnumStringEnum.UPPER(), + MapTestMapOfEnumStringEnum.lower(), + + ]; +} + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/map_test.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/map_test.reflection.dart new file mode 100644 index 000000000000..9d51e5569cd5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/map_test.reflection.dart @@ -0,0 +1,370 @@ +// Model reflection + +part of 'map_test.dart'; + + +//class reflection + +class MapTestReflection extends ModelReflection { + static MapTestReflection instanceGetter() => instance; + static const instance = MapTestReflection._( + modelName: r'MapTest', + className: r'MapTest', + xml: XmlReflection( +), + mapMapOfStringPart: PropertyReflection +> +>>( + dartName: r'mapMapOfString', + nullable: false, + required: false, + oasName: r'map_map_of_string', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mapMapOfStringGetter), + setter: FunctionWrapper2(_mapMapOfStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +) +, +) +), + ), + mapOfEnumStringPart: PropertyReflection +>>( + dartName: r'mapOfEnumString', + nullable: false, + required: false, + oasName: r'map_of_enum_string', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mapOfEnumStringGetter), + setter: FunctionWrapper2(_mapOfEnumStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapTestMapOfEnumStringEnum.$reflection + + +, +) +) +, +) +), + ), + directMapPart: PropertyReflection +>>( + dartName: r'directMap', + nullable: false, + required: false, + oasName: r'direct_map', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_directMapGetter), + setter: FunctionWrapper2(_directMapSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +) +, +) +), + ), + indirectMapPart: PropertyReflection +>>( + dartName: r'indirectMap', + nullable: false, + required: false, + oasName: r'indirect_map', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_indirectMapGetter), + setter: FunctionWrapper2(_indirectMapSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const MapTestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.mapMapOfStringPart, + required this.mapOfEnumStringPart, + required this.directMapPart, + required this.indirectMapPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection +> +>> mapMapOfStringPart; + static UndefinedWrapper< + Map +> +> _mapMapOfStringGetter(MapTest parent) { + return parent.mapMapOfString; + } + static void _mapMapOfStringSetter(MapTest parent, UndefinedWrapper< + Map +> +> value) { + parent.mapMapOfString = value; + } + + final PropertyReflection +>> mapOfEnumStringPart; + static UndefinedWrapper< + Map +> _mapOfEnumStringGetter(MapTest parent) { + return parent.mapOfEnumString; + } + static void _mapOfEnumStringSetter(MapTest parent, UndefinedWrapper< + Map +> value) { + parent.mapOfEnumString = value; + } + + final PropertyReflection +>> directMapPart; + static UndefinedWrapper< + Map +> _directMapGetter(MapTest parent) { + return parent.directMap; + } + static void _directMapSetter(MapTest parent, UndefinedWrapper< + Map +> value) { + parent.directMap = value; + } + + final PropertyReflection +>> indirectMapPart; + static UndefinedWrapper< + Map +> _indirectMapGetter(MapTest parent) { + return parent.indirectMap; + } + static void _indirectMapSetter(MapTest parent, UndefinedWrapper< + Map +> value) { + parent.indirectMap = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + mapMapOfStringPart, +mapOfEnumStringPart, +directMapPart, +indirectMapPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(MapTest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(MapTest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + MapTest empty() { + return MapTest( + ); + } + + @override + bool operator ==(Object other) { + return other is MapTestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_properties_and_additional_properties_class.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_properties_and_additional_properties_class.dart new file mode 100644 index 000000000000..6311b30bea54 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_properties_and_additional_properties_class.dart @@ -0,0 +1,122 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'mixed_properties_and_additional_properties_class.reflection.dart'; + + +/// MixedPropertiesAndAdditionalPropertiesClassMixin +/// +/// Properties: +/// * [uuid] +/// * [dateTime] +/// * [map] +mixin MixedPropertiesAndAdditionalPropertiesClassMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get uuid; +UndefinedWrapper< + DateTime +> get dateTime; +UndefinedWrapper< + Map +> get map; + +} + +/// MixedPropertiesAndAdditionalPropertiesClass +/// +/// Properties: +/// * [uuid] +/// * [dateTime] +/// * [map] +class MixedPropertiesAndAdditionalPropertiesClass with +$OpenApiObjectMixin, + +MixedPropertiesAndAdditionalPropertiesClassMixin { + @override + UndefinedWrapper< + String +> uuid; + @override + UndefinedWrapper< + DateTime +> dateTime; + @override + UndefinedWrapper< + Map +> map; + + AdditionalProperties additionalProperties; + + + + MixedPropertiesAndAdditionalPropertiesClass.$all({ + required this.uuid, + required this.dateTime, + required this.map, + required this.additionalProperties, + + }); + + MixedPropertiesAndAdditionalPropertiesClass({ + this.uuid = const UndefinedWrapper + .undefined() +, + this.dateTime = const UndefinedWrapper + .undefined() +, + this.map = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = MixedPropertiesAndAdditionalPropertiesClassReflection.instance; + MixedPropertiesAndAdditionalPropertiesClassReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory MixedPropertiesAndAdditionalPropertiesClass.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + MixedPropertiesAndAdditionalPropertiesClass clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_properties_and_additional_properties_class.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_properties_and_additional_properties_class.reflection.dart new file mode 100644 index 000000000000..93f005c6fe64 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_properties_and_additional_properties_class.reflection.dart @@ -0,0 +1,252 @@ +// Model reflection + +part of 'mixed_properties_and_additional_properties_class.dart'; + + +//class reflection + +class MixedPropertiesAndAdditionalPropertiesClassReflection extends ModelReflection { + static MixedPropertiesAndAdditionalPropertiesClassReflection instanceGetter() => instance; + static const instance = MixedPropertiesAndAdditionalPropertiesClassReflection._( + modelName: r'MixedPropertiesAndAdditionalPropertiesClass', + className: r'MixedPropertiesAndAdditionalPropertiesClass', + xml: XmlReflection( +), + uuidPart: PropertyReflection>( + dartName: r'uuid', + nullable: false, + required: false, + oasName: r'uuid', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_uuidGetter), + setter: FunctionWrapper2(_uuidSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + dateTimePart: PropertyReflection>( + dartName: r'dateTime', + nullable: false, + required: false, + oasName: r'dateTime', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_dateTimeGetter), + setter: FunctionWrapper2(_dateTimeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +), + ), + mapPart: PropertyReflection +>>( + dartName: r'map', + nullable: false, + required: false, + oasName: r'map', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_mapGetter), + setter: FunctionWrapper2(_mapSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Animal.$reflection + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const MixedPropertiesAndAdditionalPropertiesClassReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.uuidPart, + required this.dateTimePart, + required this.mapPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> uuidPart; + static UndefinedWrapper< + String +> _uuidGetter(MixedPropertiesAndAdditionalPropertiesClass parent) { + return parent.uuid; + } + static void _uuidSetter(MixedPropertiesAndAdditionalPropertiesClass parent, UndefinedWrapper< + String +> value) { + parent.uuid = value; + } + + final PropertyReflection> dateTimePart; + static UndefinedWrapper< + DateTime +> _dateTimeGetter(MixedPropertiesAndAdditionalPropertiesClass parent) { + return parent.dateTime; + } + static void _dateTimeSetter(MixedPropertiesAndAdditionalPropertiesClass parent, UndefinedWrapper< + DateTime +> value) { + parent.dateTime = value; + } + + final PropertyReflection +>> mapPart; + static UndefinedWrapper< + Map +> _mapGetter(MixedPropertiesAndAdditionalPropertiesClass parent) { + return parent.map; + } + static void _mapSetter(MixedPropertiesAndAdditionalPropertiesClass parent, UndefinedWrapper< + Map +> value) { + parent.map = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + uuidPart, +dateTimePart, +mapPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(MixedPropertiesAndAdditionalPropertiesClass instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(MixedPropertiesAndAdditionalPropertiesClass instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + MixedPropertiesAndAdditionalPropertiesClass empty() { + return MixedPropertiesAndAdditionalPropertiesClass( + ); + } + + @override + bool operator ==(Object other) { + return other is MixedPropertiesAndAdditionalPropertiesClassReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_number.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_number.dart new file mode 100644 index 000000000000..4d12d53d1d90 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_number.dart @@ -0,0 +1,86 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'mixed_type_one_of_number.reflection.dart'; + + +/// MixedTypeOneOfNumberMixin +mixin MixedTypeOneOfNumberMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + double +> get oneOf0; + UndefinedWrapper< + double +> get oneOf1; +} + +/// MixedTypeOneOfNumber +class MixedTypeOneOfNumber with +$OpenApiObjectMixin, + +MixedTypeOneOfNumberMixin { + + + + + @override + UndefinedWrapper< + double +> oneOf0; + + @override + UndefinedWrapper< + double +> oneOf1; + + + MixedTypeOneOfNumber.$all({ + + + required this.oneOf0, + required this.oneOf1, + }); + + MixedTypeOneOfNumber({ + + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }); + + static const $reflection = MixedTypeOneOfNumberReflection.instance; + MixedTypeOneOfNumberReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory MixedTypeOneOfNumber.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + MixedTypeOneOfNumber clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_number.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_number.reflection.dart new file mode 100644 index 000000000000..e7edc6004446 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_number.reflection.dart @@ -0,0 +1,237 @@ +// Model reflection + +part of 'mixed_type_one_of_number.dart'; + + +//class reflection + +class MixedTypeOneOfNumberReflection extends ModelReflection { + static MixedTypeOneOfNumberReflection instanceGetter() => instance; + static const instance = MixedTypeOneOfNumberReflection._( + modelName: r'MixedTypeOneOfNumber', + className: r'MixedTypeOneOfNumber', + xml: XmlReflection( +), + + + oneOf0Part: MixedTypeOneOfNumberOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: MixedTypeOneOfNumberOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + ); + const MixedTypeOneOfNumberReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + + + + final MixedTypeOneOfNumberOneOf0Part oneOf0Part; + + final MixedTypeOneOfNumberOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + MixedTypeOneOfNumber empty() { + return MixedTypeOneOfNumber( + ); + } + + @override + bool operator ==(Object other) { + return other is MixedTypeOneOfNumberReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class MixedTypeOneOfNumberOneOf0Part extends OneOfReflection { + + const MixedTypeOneOfNumberOneOf0Part({ + required MixedTypeOneOfNumberReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, MixedTypeOneOfNumber> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + double +> _getter(MixedTypeOneOfNumber src) { + return src.oneOf0; +} +static void _setter(MixedTypeOneOfNumber src, UndefinedWrapper< + double +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + double +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fordouble + + + ), +); + + UndefinedWrapper< + double +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class MixedTypeOneOfNumberOneOf1Part extends OneOfReflection { + + const MixedTypeOneOfNumberOneOf1Part({ + required MixedTypeOneOfNumberReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, MixedTypeOneOfNumber> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + double +> _getter(MixedTypeOneOfNumber src) { + return src.oneOf1; +} +static void _setter(MixedTypeOneOfNumber src, UndefinedWrapper< + double +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + double +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fordouble + + + ), +); + + UndefinedWrapper< + double +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object.dart new file mode 100644 index 000000000000..1626455a9688 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object.dart @@ -0,0 +1,130 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'mixed_type_one_of_object.reflection.dart'; + + +/// MixedTypeOneOfObjectMixin +/// +/// Properties: +/// * [c] +mixin MixedTypeOneOfObjectMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + bool +> get c; + + UndefinedWrapper< + MixedTypeOneOfObjectOneOf +> get oneOf0; + UndefinedWrapper< + MixedTypeOneOfObjectOneOf1 +> get oneOf1; + UndefinedWrapper< + MixedTypeOneOfObjectAnyOf +> get anyOf0; + UndefinedWrapper< + MixedTypeOneOfObjectAnyOf1 +> get anyOf1; +} + +/// MixedTypeOneOfObject +/// +/// Properties: +/// * [c] +class MixedTypeOneOfObject with +$OpenApiObjectMixin, + +MixedTypeOneOfObjectMixin { + @override + UndefinedWrapper< + bool +> c; + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + MixedTypeOneOfObjectOneOf +> oneOf0; + + @override + UndefinedWrapper< + MixedTypeOneOfObjectOneOf1 +> oneOf1; + + @override + UndefinedWrapper< + MixedTypeOneOfObjectAnyOf +> anyOf0; + + @override + UndefinedWrapper< + MixedTypeOneOfObjectAnyOf1 +> anyOf1; + + + MixedTypeOneOfObject.$all({ + required this.c, + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + required this.anyOf0, + required this.anyOf1, + }); + + MixedTypeOneOfObject({ + this.c = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + this.anyOf0 = const UndefinedWrapper.undefined(), + + this.anyOf1 = const UndefinedWrapper.undefined(), + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = MixedTypeOneOfObjectReflection.instance; + MixedTypeOneOfObjectReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory MixedTypeOneOfObject.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + MixedTypeOneOfObject clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object.reflection.dart new file mode 100644 index 000000000000..7da8a14c594a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object.reflection.dart @@ -0,0 +1,445 @@ +// Model reflection + +part of 'mixed_type_one_of_object.dart'; + + +//class reflection + +class MixedTypeOneOfObjectReflection extends ModelReflection { + static MixedTypeOneOfObjectReflection instanceGetter() => instance; + static const instance = MixedTypeOneOfObjectReflection._( + modelName: r'MixedTypeOneOfObject', + className: r'MixedTypeOneOfObject', + xml: XmlReflection( +), + cPart: PropertyReflection>( + dartName: r'c', + nullable: false, + required: false, + oasName: r'c', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_cGetter), + setter: FunctionWrapper2(_cSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + + + oneOf0Part: MixedTypeOneOfObjectOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: MixedTypeOneOfObjectOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + anyOf0Part: MixedTypeOneOfObjectAnyOf0Part( + parentReflectionGetter: instanceGetter, + ), + + anyOf1Part: MixedTypeOneOfObjectAnyOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const MixedTypeOneOfObjectReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.cPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.anyOf0Part, + + required this.anyOf1Part, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> cPart; + static UndefinedWrapper< + bool +> _cGetter(MixedTypeOneOfObject parent) { + return parent.c; + } + static void _cSetter(MixedTypeOneOfObject parent, UndefinedWrapper< + bool +> value) { + parent.c = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + cPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(MixedTypeOneOfObject instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(MixedTypeOneOfObject instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final MixedTypeOneOfObjectOneOf0Part oneOf0Part; + + final MixedTypeOneOfObjectOneOf1Part oneOf1Part; + + final MixedTypeOneOfObjectAnyOf0Part anyOf0Part; + + final MixedTypeOneOfObjectAnyOf1Part anyOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + anyOf0Part,anyOf1Part, + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + MixedTypeOneOfObject empty() { + return MixedTypeOneOfObject( + ); + } + + @override + bool operator ==(Object other) { + return other is MixedTypeOneOfObjectReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class MixedTypeOneOfObjectOneOf0Part extends OneOfReflection { + + const MixedTypeOneOfObjectOneOf0Part({ + required MixedTypeOneOfObjectReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, MixedTypeOneOfObject> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + MixedTypeOneOfObjectOneOf +> _getter(MixedTypeOneOfObject src) { + return src.oneOf0; +} +static void _setter(MixedTypeOneOfObject src, UndefinedWrapper< + MixedTypeOneOfObjectOneOf +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + MixedTypeOneOfObjectOneOf +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + MixedTypeOneOfObjectOneOf.$reflection + + + ), +); + + UndefinedWrapper< + MixedTypeOneOfObjectOneOf +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class MixedTypeOneOfObjectOneOf1Part extends OneOfReflection { + + const MixedTypeOneOfObjectOneOf1Part({ + required MixedTypeOneOfObjectReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, MixedTypeOneOfObject> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + MixedTypeOneOfObjectOneOf1 +> _getter(MixedTypeOneOfObject src) { + return src.oneOf1; +} +static void _setter(MixedTypeOneOfObject src, UndefinedWrapper< + MixedTypeOneOfObjectOneOf1 +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + MixedTypeOneOfObjectOneOf1 +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + MixedTypeOneOfObjectOneOf1.$reflection + + + ), +); + + UndefinedWrapper< + MixedTypeOneOfObjectOneOf1 +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} +class MixedTypeOneOfObjectAnyOf0Part extends AnyOfReflection { + + const MixedTypeOneOfObjectAnyOf0Part({ + required MixedTypeOneOfObjectReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, MixedTypeOneOfObject> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + MixedTypeOneOfObjectAnyOf +> _getter(MixedTypeOneOfObject src) { + return src.anyOf0; +} +static void _setter(MixedTypeOneOfObject src, UndefinedWrapper< + MixedTypeOneOfObjectAnyOf +> value) { + src.anyOf0 = value; +} + +@override +UndefinedWrapperReflection< + MixedTypeOneOfObjectAnyOf +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + MixedTypeOneOfObjectAnyOf.$reflection + + + ), +); + + UndefinedWrapper< + MixedTypeOneOfObjectAnyOf +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} +class MixedTypeOneOfObjectAnyOf1Part extends AnyOfReflection { + + const MixedTypeOneOfObjectAnyOf1Part({ + required MixedTypeOneOfObjectReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, MixedTypeOneOfObject> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + MixedTypeOneOfObjectAnyOf1 +> _getter(MixedTypeOneOfObject src) { + return src.anyOf1; +} +static void _setter(MixedTypeOneOfObject src, UndefinedWrapper< + MixedTypeOneOfObjectAnyOf1 +> value) { + src.anyOf1 = value; +} + +@override +UndefinedWrapperReflection< + MixedTypeOneOfObjectAnyOf1 +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + MixedTypeOneOfObjectAnyOf1.$reflection + + + ), +); + + UndefinedWrapper< + MixedTypeOneOfObjectAnyOf1 +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of.dart new file mode 100644 index 000000000000..6affdaebd6f4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'mixed_type_one_of_object_any_of.reflection.dart'; + + +/// MixedTypeOneOfObjectAnyOfMixin +/// +/// Properties: +/// * [a] +mixin MixedTypeOneOfObjectAnyOfMixin on + $OpenApiObjectMixin { + + int + get a; + +} + +/// MixedTypeOneOfObjectAnyOf +/// +/// Properties: +/// * [a] +class MixedTypeOneOfObjectAnyOf with +$OpenApiObjectMixin, + +MixedTypeOneOfObjectAnyOfMixin { + @override + + int + a; + + AdditionalProperties additionalProperties; + + + + MixedTypeOneOfObjectAnyOf.$all({ + required this.a, + required this.additionalProperties, + + }); + + MixedTypeOneOfObjectAnyOf({ + required this.a , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = MixedTypeOneOfObjectAnyOfReflection.instance; + MixedTypeOneOfObjectAnyOfReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory MixedTypeOneOfObjectAnyOf.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + MixedTypeOneOfObjectAnyOf clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of.reflection.dart new file mode 100644 index 000000000000..6e1138f35be7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'mixed_type_one_of_object_any_of.dart'; + + +//class reflection + +class MixedTypeOneOfObjectAnyOfReflection extends ModelReflection { + static MixedTypeOneOfObjectAnyOfReflection instanceGetter() => instance; + static const instance = MixedTypeOneOfObjectAnyOfReflection._( + modelName: r'MixedTypeOneOfObject_anyOf', + className: r'MixedTypeOneOfObjectAnyOf', + xml: XmlReflection( +), + aPart: PropertyReflection( + dartName: r'a', + nullable: false, + required: true, + oasName: r'a', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_aGetter), + setter: FunctionWrapper2(_aSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const MixedTypeOneOfObjectAnyOfReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.aPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection aPart; + static + int + _aGetter(MixedTypeOneOfObjectAnyOf parent) { + return parent.a; + } + static void _aSetter(MixedTypeOneOfObjectAnyOf parent, + int + value) { + parent.a = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + aPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(MixedTypeOneOfObjectAnyOf instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(MixedTypeOneOfObjectAnyOf instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + MixedTypeOneOfObjectAnyOf empty() { + return MixedTypeOneOfObjectAnyOf( + a: aPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is MixedTypeOneOfObjectAnyOfReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of1.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of1.dart new file mode 100644 index 000000000000..3568a683187a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of1.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'mixed_type_one_of_object_any_of1.reflection.dart'; + + +/// MixedTypeOneOfObjectAnyOf1Mixin +/// +/// Properties: +/// * [b] +mixin MixedTypeOneOfObjectAnyOf1Mixin on + $OpenApiObjectMixin { + + num + get b; + +} + +/// MixedTypeOneOfObjectAnyOf1 +/// +/// Properties: +/// * [b] +class MixedTypeOneOfObjectAnyOf1 with +$OpenApiObjectMixin, + +MixedTypeOneOfObjectAnyOf1Mixin { + @override + + num + b; + + AdditionalProperties additionalProperties; + + + + MixedTypeOneOfObjectAnyOf1.$all({ + required this.b, + required this.additionalProperties, + + }); + + MixedTypeOneOfObjectAnyOf1({ + required this.b , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = MixedTypeOneOfObjectAnyOf1Reflection.instance; + MixedTypeOneOfObjectAnyOf1Reflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory MixedTypeOneOfObjectAnyOf1.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + MixedTypeOneOfObjectAnyOf1 clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of1.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of1.reflection.dart new file mode 100644 index 000000000000..b29a47140533 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_any_of1.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'mixed_type_one_of_object_any_of1.dart'; + + +//class reflection + +class MixedTypeOneOfObjectAnyOf1Reflection extends ModelReflection { + static MixedTypeOneOfObjectAnyOf1Reflection instanceGetter() => instance; + static const instance = MixedTypeOneOfObjectAnyOf1Reflection._( + modelName: r'MixedTypeOneOfObject_anyOf_1', + className: r'MixedTypeOneOfObjectAnyOf1', + xml: XmlReflection( +), + bPart: PropertyReflection( + dartName: r'b', + nullable: false, + required: true, + oasName: r'b', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_bGetter), + setter: FunctionWrapper2(_bSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const MixedTypeOneOfObjectAnyOf1Reflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.bPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection bPart; + static + num + _bGetter(MixedTypeOneOfObjectAnyOf1 parent) { + return parent.b; + } + static void _bSetter(MixedTypeOneOfObjectAnyOf1 parent, + num + value) { + parent.b = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + bPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(MixedTypeOneOfObjectAnyOf1 instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(MixedTypeOneOfObjectAnyOf1 instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + MixedTypeOneOfObjectAnyOf1 empty() { + return MixedTypeOneOfObjectAnyOf1( + b: bPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is MixedTypeOneOfObjectAnyOf1Reflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of.dart new file mode 100644 index 000000000000..293c1e0cf666 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'mixed_type_one_of_object_one_of.reflection.dart'; + + +/// MixedTypeOneOfObjectOneOfMixin +/// +/// Properties: +/// * [content] +mixin MixedTypeOneOfObjectOneOfMixin on + $OpenApiObjectMixin { + + String + get content; + +} + +/// MixedTypeOneOfObjectOneOf +/// +/// Properties: +/// * [content] +class MixedTypeOneOfObjectOneOf with +$OpenApiObjectMixin, + +MixedTypeOneOfObjectOneOfMixin { + @override + + String + content; + + AdditionalProperties additionalProperties; + + + + MixedTypeOneOfObjectOneOf.$all({ + required this.content, + required this.additionalProperties, + + }); + + MixedTypeOneOfObjectOneOf({ + required this.content , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = MixedTypeOneOfObjectOneOfReflection.instance; + MixedTypeOneOfObjectOneOfReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory MixedTypeOneOfObjectOneOf.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + MixedTypeOneOfObjectOneOf clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of.reflection.dart new file mode 100644 index 000000000000..c7ec89521222 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'mixed_type_one_of_object_one_of.dart'; + + +//class reflection + +class MixedTypeOneOfObjectOneOfReflection extends ModelReflection { + static MixedTypeOneOfObjectOneOfReflection instanceGetter() => instance; + static const instance = MixedTypeOneOfObjectOneOfReflection._( + modelName: r'MixedTypeOneOfObject_oneOf', + className: r'MixedTypeOneOfObjectOneOf', + xml: XmlReflection( +), + contentPart: PropertyReflection( + dartName: r'content', + nullable: false, + required: true, + oasName: r'content', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_contentGetter), + setter: FunctionWrapper2(_contentSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const MixedTypeOneOfObjectOneOfReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.contentPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection contentPart; + static + String + _contentGetter(MixedTypeOneOfObjectOneOf parent) { + return parent.content; + } + static void _contentSetter(MixedTypeOneOfObjectOneOf parent, + String + value) { + parent.content = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + contentPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(MixedTypeOneOfObjectOneOf instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(MixedTypeOneOfObjectOneOf instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + MixedTypeOneOfObjectOneOf empty() { + return MixedTypeOneOfObjectOneOf( + content: contentPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is MixedTypeOneOfObjectOneOfReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of1.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of1.dart new file mode 100644 index 000000000000..b6e7313c548d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of1.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'mixed_type_one_of_object_one_of1.reflection.dart'; + + +/// MixedTypeOneOfObjectOneOf1Mixin +/// +/// Properties: +/// * [url] +mixin MixedTypeOneOfObjectOneOf1Mixin on + $OpenApiObjectMixin { + + Uri + get url; + +} + +/// MixedTypeOneOfObjectOneOf1 +/// +/// Properties: +/// * [url] +class MixedTypeOneOfObjectOneOf1 with +$OpenApiObjectMixin, + +MixedTypeOneOfObjectOneOf1Mixin { + @override + + Uri + url; + + AdditionalProperties additionalProperties; + + + + MixedTypeOneOfObjectOneOf1.$all({ + required this.url, + required this.additionalProperties, + + }); + + MixedTypeOneOfObjectOneOf1({ + required this.url , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = MixedTypeOneOfObjectOneOf1Reflection.instance; + MixedTypeOneOfObjectOneOf1Reflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory MixedTypeOneOfObjectOneOf1.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + MixedTypeOneOfObjectOneOf1 clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of1.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of1.reflection.dart new file mode 100644 index 000000000000..889c7421abdd --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/mixed_type_one_of_object_one_of1.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'mixed_type_one_of_object_one_of1.dart'; + + +//class reflection + +class MixedTypeOneOfObjectOneOf1Reflection extends ModelReflection { + static MixedTypeOneOfObjectOneOf1Reflection instanceGetter() => instance; + static const instance = MixedTypeOneOfObjectOneOf1Reflection._( + modelName: r'MixedTypeOneOfObject_oneOf_1', + className: r'MixedTypeOneOfObjectOneOf1', + xml: XmlReflection( +), + urlPart: PropertyReflection( + dartName: r'url', + nullable: false, + required: true, + oasName: r'url', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_urlGetter), + setter: FunctionWrapper2(_urlSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forUri + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const MixedTypeOneOfObjectOneOf1Reflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.urlPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection urlPart; + static + Uri + _urlGetter(MixedTypeOneOfObjectOneOf1 parent) { + return parent.url; + } + static void _urlSetter(MixedTypeOneOfObjectOneOf1 parent, + Uri + value) { + parent.url = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + urlPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(MixedTypeOneOfObjectOneOf1 instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(MixedTypeOneOfObjectOneOf1 instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + MixedTypeOneOfObjectOneOf1 empty() { + return MixedTypeOneOfObjectOneOf1( + url: urlPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is MixedTypeOneOfObjectOneOf1Reflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/model_with_one_of_any_of_properties.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/model_with_one_of_any_of_properties.dart new file mode 100644 index 000000000000..3b0776be1a38 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/model_with_one_of_any_of_properties.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'model_with_one_of_any_of_properties.reflection.dart'; + + +/// ModelWithOneOfAnyOfPropertiesMixin +/// +/// Properties: +/// * [oneofProp] +/// * [anyofProp] +mixin ModelWithOneOfAnyOfPropertiesMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + ArrayOneOf +> get oneofProp; +UndefinedWrapper< + ArrayAnyOf +> get anyofProp; + +} + +/// ModelWithOneOfAnyOfProperties +/// +/// Properties: +/// * [oneofProp] +/// * [anyofProp] +class ModelWithOneOfAnyOfProperties with +$OpenApiObjectMixin, + +ModelWithOneOfAnyOfPropertiesMixin { + @override + UndefinedWrapper< + ArrayOneOf +> oneofProp; + @override + UndefinedWrapper< + ArrayAnyOf +> anyofProp; + + AdditionalProperties additionalProperties; + + + + ModelWithOneOfAnyOfProperties.$all({ + required this.oneofProp, + required this.anyofProp, + required this.additionalProperties, + + }); + + ModelWithOneOfAnyOfProperties({ + this.oneofProp = const UndefinedWrapper + .undefined() +, + this.anyofProp = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ModelWithOneOfAnyOfPropertiesReflection.instance; + ModelWithOneOfAnyOfPropertiesReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ModelWithOneOfAnyOfProperties.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ModelWithOneOfAnyOfProperties clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/model_with_one_of_any_of_properties.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/model_with_one_of_any_of_properties.reflection.dart new file mode 100644 index 000000000000..f976b153bcce --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/model_with_one_of_any_of_properties.reflection.dart @@ -0,0 +1,188 @@ +// Model reflection + +part of 'model_with_one_of_any_of_properties.dart'; + + +//class reflection + +class ModelWithOneOfAnyOfPropertiesReflection extends ModelReflection { + static ModelWithOneOfAnyOfPropertiesReflection instanceGetter() => instance; + static const instance = ModelWithOneOfAnyOfPropertiesReflection._( + modelName: r'ModelWithOneOfAnyOfProperties', + className: r'ModelWithOneOfAnyOfProperties', + xml: XmlReflection( +), + oneofPropPart: PropertyReflection>( + dartName: r'oneofProp', + nullable: false, + required: false, + oasName: r'oneof_prop', + oasType: r'ArrayOneOf', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_oneofPropGetter), + setter: FunctionWrapper2(_oneofPropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ArrayOneOf.$reflection + +, +) +), + ), + anyofPropPart: PropertyReflection>( + dartName: r'anyofProp', + nullable: false, + required: false, + oasName: r'anyof_prop', + oasType: r'ArrayAnyOf', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_anyofPropGetter), + setter: FunctionWrapper2(_anyofPropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ArrayAnyOf.$reflection + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ModelWithOneOfAnyOfPropertiesReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.oneofPropPart, + required this.anyofPropPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> oneofPropPart; + static UndefinedWrapper< + ArrayOneOf +> _oneofPropGetter(ModelWithOneOfAnyOfProperties parent) { + return parent.oneofProp; + } + static void _oneofPropSetter(ModelWithOneOfAnyOfProperties parent, UndefinedWrapper< + ArrayOneOf +> value) { + parent.oneofProp = value; + } + + final PropertyReflection> anyofPropPart; + static UndefinedWrapper< + ArrayAnyOf +> _anyofPropGetter(ModelWithOneOfAnyOfProperties parent) { + return parent.anyofProp; + } + static void _anyofPropSetter(ModelWithOneOfAnyOfProperties parent, UndefinedWrapper< + ArrayAnyOf +> value) { + parent.anyofProp = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + oneofPropPart, +anyofPropPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ModelWithOneOfAnyOfProperties instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ModelWithOneOfAnyOfProperties instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ModelWithOneOfAnyOfProperties empty() { + return ModelWithOneOfAnyOfProperties( + ); + } + + @override + bool operator ==(Object other) { + return other is ModelWithOneOfAnyOfPropertiesReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/name.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/name.dart new file mode 100644 index 000000000000..1896f3cc33e1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/name.dart @@ -0,0 +1,128 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'name.reflection.dart'; + + +/// Model for testing model name same as property name +/// +/// Properties: +/// * [name] +/// * [snakeCase] +/// * [property] +/// * [$123number] +mixin NameMixin on + $OpenApiObjectMixin { + + int + get name; +UndefinedWrapper< + int +> get snakeCase; +UndefinedWrapper< + String +> get property; +UndefinedWrapper< + int +> get $123number; + +} + +/// Model for testing model name same as property name +/// +/// Properties: +/// * [name] +/// * [snakeCase] +/// * [property] +/// * [$123number] +class Name with +$OpenApiObjectMixin, + +NameMixin { + @override + + int + name; + @override + UndefinedWrapper< + int +> snakeCase; + @override + UndefinedWrapper< + String +> property; + @override + UndefinedWrapper< + int +> $123number; + + AdditionalProperties additionalProperties; + + + + Name.$all({ + required this.name, + required this.snakeCase, + required this.property, + required this.$123number, + required this.additionalProperties, + + }); + + Name({ + required this.name , + this.snakeCase = const UndefinedWrapper + .undefined() +, + this.property = const UndefinedWrapper + .undefined() +, + this.$123number = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = NameReflection.instance; + NameReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Name.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Name clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/name.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/name.reflection.dart new file mode 100644 index 000000000000..fbbd34c3926c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/name.reflection.dart @@ -0,0 +1,280 @@ +// Model reflection + +part of 'name.dart'; + + +//class reflection + +class NameReflection extends ModelReflection { + static NameReflection instanceGetter() => instance; + static const instance = NameReflection._( + modelName: r'Name', + className: r'Name', + xml: XmlReflection( + xmlName: r'Name', +), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +, + ), + snakeCasePart: PropertyReflection>( + dartName: r'snakeCase', + nullable: false, + required: false, + oasName: r'snake_case', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_snakeCaseGetter), + setter: FunctionWrapper2(_snakeCaseSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + propertyPart: PropertyReflection>( + dartName: r'property', + nullable: false, + required: false, + oasName: r'property', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_propertyGetter), + setter: FunctionWrapper2(_propertySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + $123numberPart: PropertyReflection>( + dartName: r'$123number', + nullable: false, + required: false, + oasName: r'123Number', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_$123numberGetter), + setter: FunctionWrapper2(_$123numberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const NameReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.namePart, + required this.snakeCasePart, + required this.propertyPart, + required this.$123numberPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection namePart; + static + int + _nameGetter(Name parent) { + return parent.name; + } + static void _nameSetter(Name parent, + int + value) { + parent.name = value; + } + + final PropertyReflection> snakeCasePart; + static UndefinedWrapper< + int +> _snakeCaseGetter(Name parent) { + return parent.snakeCase; + } + static void _snakeCaseSetter(Name parent, UndefinedWrapper< + int +> value) { + parent.snakeCase = value; + } + + final PropertyReflection> propertyPart; + static UndefinedWrapper< + String +> _propertyGetter(Name parent) { + return parent.property; + } + static void _propertySetter(Name parent, UndefinedWrapper< + String +> value) { + parent.property = value; + } + + final PropertyReflection> $123numberPart; + static UndefinedWrapper< + int +> _$123numberGetter(Name parent) { + return parent.$123number; + } + static void _$123numberSetter(Name parent, UndefinedWrapper< + int +> value) { + parent.$123number = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + namePart, +snakeCasePart, +propertyPart, +$123numberPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Name instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Name instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Name empty() { + return Name( + name: namePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is NameReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet.dart new file mode 100644 index 000000000000..ea8c85791b1b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet.dart @@ -0,0 +1,242 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'new_pet.reflection.dart'; + + +/// NewPetMixin +/// +/// Properties: +/// * [id] +/// * [categoryInlineAllof] +/// * [categoryAllOfRef] +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +mixin NewPetMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; +UndefinedWrapper< + NewPetCategoryInlineAllof +> get categoryInlineAllof; +UndefinedWrapper< + Category +> get categoryAllOfRef; + + String + get name; + + List< + + String +> + get photoUrls; +UndefinedWrapper< + List< + + Tag +> +> get tags; +UndefinedWrapper< + NewPetStatusEnum +> get status; + +} + +/// NewPet +/// +/// Properties: +/// * [id] +/// * [categoryInlineAllof] +/// * [categoryAllOfRef] +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +class NewPet with +$OpenApiObjectMixin, + +NewPetMixin { + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + NewPetCategoryInlineAllof +> categoryInlineAllof; + @override + UndefinedWrapper< + Category +> categoryAllOfRef; + @override + + String + name; + @override + + List< + + String +> + photoUrls; + @override + UndefinedWrapper< + List< + + Tag +> +> tags; + @override + UndefinedWrapper< + NewPetStatusEnum +> status; + + AdditionalProperties additionalProperties; + + + + NewPet.$all({ + required this.id, + required this.categoryInlineAllof, + required this.categoryAllOfRef, + required this.name, + required this.photoUrls, + required this.tags, + required this.status, + required this.additionalProperties, + + }); + + NewPet({ + this.id = const UndefinedWrapper + .undefined() +, + this.categoryInlineAllof = const UndefinedWrapper + .undefined() +, + this.categoryAllOfRef = const UndefinedWrapper + .undefined() +, +required this.name , +required this.photoUrls , + this.tags = const UndefinedWrapper + .undefined() +, + this.status = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = NewPetReflection.instance; + NewPetReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory NewPet.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + NewPet clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + + + + +extension type const NewPetStatusEnum._(String value) implements String { + /// pet status in the store + const NewPetStatusEnum.available() : this._(r'available'); + /// pet status in the store + const NewPetStatusEnum.pending() : this._(r'pending'); + /// pet status in the store + const NewPetStatusEnum.sold() : this._(r'sold'); + + /// Creates a [NewPetStatusEnum] enum from a value and safely checking if it exists. + factory NewPetStatusEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'available', oasValue: r'available', value: NewPetStatusEnum.available()), + + EnumMemberReflection(dartName: r'pending', oasValue: r'pending', value: NewPetStatusEnum.pending()), + + EnumMemberReflection(dartName: r'sold', oasValue: r'sold', value: NewPetStatusEnum.sold()), + + ], + ); + + factory NewPetStatusEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [NewPetStatusEnum] enum from a value without checking if it exists. + const NewPetStatusEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + NewPetStatusEnum.available(), + NewPetStatusEnum.pending(), + NewPetStatusEnum.sold(), + + ]; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet.reflection.dart new file mode 100644 index 000000000000..f85fb9a5e9f0 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet.reflection.dart @@ -0,0 +1,461 @@ +// Model reflection + +part of 'new_pet.dart'; + + +//class reflection + +class NewPetReflection extends ModelReflection { + static NewPetReflection instanceGetter() => instance; + static const instance = NewPetReflection._( + modelName: r'NewPet', + className: r'NewPet', + xml: XmlReflection( +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + categoryInlineAllofPart: PropertyReflection>( + dartName: r'categoryInlineAllof', + nullable: false, + required: false, + oasName: r'category_inline_allof', + oasType: r'NewPetCategoryInlineAllof', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_categoryInlineAllofGetter), + setter: FunctionWrapper2(_categoryInlineAllofSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + NewPetCategoryInlineAllof.$reflection + +, +) +), + ), + categoryAllOfRefPart: PropertyReflection>( + dartName: r'categoryAllOfRef', + nullable: false, + required: false, + oasName: r'category_allOf_ref', + oasType: r'Category', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'Category', +), + getter: FunctionWrapper1(_categoryAllOfRefGetter), + setter: FunctionWrapper2(_categoryAllOfRefSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Category', +), + + + + + + Category.$reflection + +, +) +), + ), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + photoUrlsPart: PropertyReflection +>( + dartName: r'photoUrls', + nullable: false, + required: true, + oasName: r'photoUrls', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + getter: FunctionWrapper1(_photoUrlsGetter), + setter: FunctionWrapper2(_photoUrlsSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +, + ), + tagsPart: PropertyReflection +>>( + dartName: r'tags', + nullable: false, + required: false, + oasName: r'tags', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + getter: FunctionWrapper1(_tagsGetter), + setter: FunctionWrapper2(_tagsSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Tag', +), + + + + + + Tag.$reflection + +, +) +) +, +) +), + ), + statusPart: PropertyReflection>( + dartName: r'status', + nullable: false, + required: false, + oasName: r'status', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_statusGetter), + setter: FunctionWrapper2(_statusSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + NewPetStatusEnum.$reflection + + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const NewPetReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.categoryInlineAllofPart, + required this.categoryAllOfRefPart, + required this.namePart, + required this.photoUrlsPart, + required this.tagsPart, + required this.statusPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(NewPet parent) { + return parent.id; + } + static void _idSetter(NewPet parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> categoryInlineAllofPart; + static UndefinedWrapper< + NewPetCategoryInlineAllof +> _categoryInlineAllofGetter(NewPet parent) { + return parent.categoryInlineAllof; + } + static void _categoryInlineAllofSetter(NewPet parent, UndefinedWrapper< + NewPetCategoryInlineAllof +> value) { + parent.categoryInlineAllof = value; + } + + final PropertyReflection> categoryAllOfRefPart; + static UndefinedWrapper< + Category +> _categoryAllOfRefGetter(NewPet parent) { + return parent.categoryAllOfRef; + } + static void _categoryAllOfRefSetter(NewPet parent, UndefinedWrapper< + Category +> value) { + parent.categoryAllOfRef = value; + } + + final PropertyReflection namePart; + static + String + _nameGetter(NewPet parent) { + return parent.name; + } + static void _nameSetter(NewPet parent, + String + value) { + parent.name = value; + } + + final PropertyReflection +> photoUrlsPart; + static + List< + + String +> + _photoUrlsGetter(NewPet parent) { + return parent.photoUrls; + } + static void _photoUrlsSetter(NewPet parent, + List< + + String +> + value) { + parent.photoUrls = value; + } + + final PropertyReflection +>> tagsPart; + static UndefinedWrapper< + List< + + Tag +> +> _tagsGetter(NewPet parent) { + return parent.tags; + } + static void _tagsSetter(NewPet parent, UndefinedWrapper< + List< + + Tag +> +> value) { + parent.tags = value; + } + + final PropertyReflection> statusPart; + static UndefinedWrapper< + NewPetStatusEnum +> _statusGetter(NewPet parent) { + return parent.status; + } + static void _statusSetter(NewPet parent, UndefinedWrapper< + NewPetStatusEnum +> value) { + parent.status = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +categoryInlineAllofPart, +categoryAllOfRefPart, +namePart, +photoUrlsPart, +tagsPart, +statusPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(NewPet instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(NewPet instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + NewPet empty() { + return NewPet( + name: namePart.reflection.emptyFunction(), + photoUrls: photoUrlsPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is NewPetReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof.dart new file mode 100644 index 000000000000..381c06befc6b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof.dart @@ -0,0 +1,117 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'new_pet_category_inline_allof.reflection.dart'; + + +/// NewPetCategoryInlineAllofMixin +/// +/// Properties: +/// * [id] +/// * [name] +/// * [categoryTag] +mixin NewPetCategoryInlineAllofMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; + + String + get name; +UndefinedWrapper< + NewPetCategoryInlineAllofAllOfCategoryTag +> get categoryTag; + +} + +/// NewPetCategoryInlineAllof +/// +/// Properties: +/// * [id] +/// * [name] +/// * [categoryTag] +class NewPetCategoryInlineAllof with +$OpenApiObjectMixin, + +NewPetCategoryInlineAllofMixin { + @override + UndefinedWrapper< + int +> id; + @override + + String + name; + @override + UndefinedWrapper< + NewPetCategoryInlineAllofAllOfCategoryTag +> categoryTag; + + AdditionalProperties additionalProperties; + + + + NewPetCategoryInlineAllof.$all({ + required this.id, + required this.name, + required this.categoryTag, + required this.additionalProperties, + + }); + + NewPetCategoryInlineAllof({ + this.id = const UndefinedWrapper + .undefined() +, + this.name = + + 'default-name' + +, + this.categoryTag = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = NewPetCategoryInlineAllofReflection.instance; + NewPetCategoryInlineAllofReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory NewPetCategoryInlineAllof.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + NewPetCategoryInlineAllof clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof.reflection.dart new file mode 100644 index 000000000000..2b2bde2a41ec --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof.reflection.dart @@ -0,0 +1,242 @@ +// Model reflection + +part of 'new_pet_category_inline_allof.dart'; + + +//class reflection + +class NewPetCategoryInlineAllofReflection extends ModelReflection { + static NewPetCategoryInlineAllofReflection instanceGetter() => instance; + static const instance = NewPetCategoryInlineAllofReflection._( + modelName: r'NewPet_category_inline_allof', + className: r'NewPetCategoryInlineAllof', + xml: XmlReflection( +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + categoryTagPart: PropertyReflection>( + dartName: r'categoryTag', + nullable: false, + required: false, + oasName: r'category_tag', + oasType: r'NewPetCategoryInlineAllofAllOfCategoryTag', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_categoryTagGetter), + setter: FunctionWrapper2(_categoryTagSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + NewPetCategoryInlineAllofAllOfCategoryTag.$reflection + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const NewPetCategoryInlineAllofReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.namePart, + required this.categoryTagPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(NewPetCategoryInlineAllof parent) { + return parent.id; + } + static void _idSetter(NewPetCategoryInlineAllof parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection namePart; + static + String + _nameGetter(NewPetCategoryInlineAllof parent) { + return parent.name; + } + static void _nameSetter(NewPetCategoryInlineAllof parent, + String + value) { + parent.name = value; + } + + final PropertyReflection> categoryTagPart; + static UndefinedWrapper< + NewPetCategoryInlineAllofAllOfCategoryTag +> _categoryTagGetter(NewPetCategoryInlineAllof parent) { + return parent.categoryTag; + } + static void _categoryTagSetter(NewPetCategoryInlineAllof parent, UndefinedWrapper< + NewPetCategoryInlineAllofAllOfCategoryTag +> value) { + parent.categoryTag = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +namePart, +categoryTagPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(NewPetCategoryInlineAllof instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(NewPetCategoryInlineAllof instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + NewPetCategoryInlineAllof empty() { + return NewPetCategoryInlineAllof( + name: namePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is NewPetCategoryInlineAllofReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof_all_of_category_tag.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof_all_of_category_tag.dart new file mode 100644 index 000000000000..4546ce99604c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof_all_of_category_tag.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'new_pet_category_inline_allof_all_of_category_tag.reflection.dart'; + + +/// NewPetCategoryInlineAllofAllOfCategoryTagMixin +/// +/// Properties: +/// * [id] +/// * [name] +mixin NewPetCategoryInlineAllofAllOfCategoryTagMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; +UndefinedWrapper< + String +> get name; + +} + +/// NewPetCategoryInlineAllofAllOfCategoryTag +/// +/// Properties: +/// * [id] +/// * [name] +class NewPetCategoryInlineAllofAllOfCategoryTag with +$OpenApiObjectMixin, + +NewPetCategoryInlineAllofAllOfCategoryTagMixin { + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + String +> name; + + AdditionalProperties additionalProperties; + + + + NewPetCategoryInlineAllofAllOfCategoryTag.$all({ + required this.id, + required this.name, + required this.additionalProperties, + + }); + + NewPetCategoryInlineAllofAllOfCategoryTag({ + this.id = const UndefinedWrapper + .undefined() +, + this.name = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = NewPetCategoryInlineAllofAllOfCategoryTagReflection.instance; + NewPetCategoryInlineAllofAllOfCategoryTagReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory NewPetCategoryInlineAllofAllOfCategoryTag.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + NewPetCategoryInlineAllofAllOfCategoryTag clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof_all_of_category_tag.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof_all_of_category_tag.reflection.dart new file mode 100644 index 000000000000..ea7b16dc0a88 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/new_pet_category_inline_allof_all_of_category_tag.reflection.dart @@ -0,0 +1,188 @@ +// Model reflection + +part of 'new_pet_category_inline_allof_all_of_category_tag.dart'; + + +//class reflection + +class NewPetCategoryInlineAllofAllOfCategoryTagReflection extends ModelReflection { + static NewPetCategoryInlineAllofAllOfCategoryTagReflection instanceGetter() => instance; + static const instance = NewPetCategoryInlineAllofAllOfCategoryTagReflection._( + modelName: r'NewPet_category_inline_allof_allOf_category_tag', + className: r'NewPetCategoryInlineAllofAllOfCategoryTag', + xml: XmlReflection( +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + namePart: PropertyReflection>( + dartName: r'name', + nullable: false, + required: false, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const NewPetCategoryInlineAllofAllOfCategoryTagReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.namePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(NewPetCategoryInlineAllofAllOfCategoryTag parent) { + return parent.id; + } + static void _idSetter(NewPetCategoryInlineAllofAllOfCategoryTag parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> namePart; + static UndefinedWrapper< + String +> _nameGetter(NewPetCategoryInlineAllofAllOfCategoryTag parent) { + return parent.name; + } + static void _nameSetter(NewPetCategoryInlineAllofAllOfCategoryTag parent, UndefinedWrapper< + String +> value) { + parent.name = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +namePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(NewPetCategoryInlineAllofAllOfCategoryTag instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(NewPetCategoryInlineAllofAllOfCategoryTag instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + NewPetCategoryInlineAllofAllOfCategoryTag empty() { + return NewPetCategoryInlineAllofAllOfCategoryTag( + ); + } + + @override + bool operator ==(Object other) { + return other is NewPetCategoryInlineAllofAllOfCategoryTagReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_class.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_class.dart new file mode 100644 index 000000000000..120a92ff3856 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_class.dart @@ -0,0 +1,308 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'nullable_class.reflection.dart'; + + +/// NullableClassMixin +/// +/// Properties: +/// * [integerProp] +/// * [numberProp] +/// * [booleanProp] +/// * [stringProp] +/// * [dateProp] +/// * [datetimeProp] +/// * [arrayNullableProp] +/// * [arrayAndItemsNullableProp] +/// * [arrayItemsNullable] +/// * [objectNullableProp] +/// * [objectAndItemsNullableProp] +/// * [objectItemsNullable] +mixin NullableClassMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +?> get integerProp; +UndefinedWrapper< + num +?> get numberProp; +UndefinedWrapper< + bool +?> get booleanProp; +UndefinedWrapper< + String +?> get stringProp; +UndefinedWrapper< + DateTime +?> get dateProp; +UndefinedWrapper< + DateTime +?> get datetimeProp; +UndefinedWrapper< + List< + + $FreeFormObject +> +?> get arrayNullableProp; +UndefinedWrapper< + List< + + $FreeFormObject +?> +?> get arrayAndItemsNullableProp; +UndefinedWrapper< + List< + + $FreeFormObject +?> +> get arrayItemsNullable; +UndefinedWrapper< + Map +?> get objectNullableProp; +UndefinedWrapper< + Map +?> get objectAndItemsNullableProp; +UndefinedWrapper< + Map +> get objectItemsNullable; + +} + +/// NullableClass +/// +/// Properties: +/// * [integerProp] +/// * [numberProp] +/// * [booleanProp] +/// * [stringProp] +/// * [dateProp] +/// * [datetimeProp] +/// * [arrayNullableProp] +/// * [arrayAndItemsNullableProp] +/// * [arrayItemsNullable] +/// * [objectNullableProp] +/// * [objectAndItemsNullableProp] +/// * [objectItemsNullable] +class NullableClass with +$OpenApiObjectMixin, + +NullableClassMixin { + @override + UndefinedWrapper< + int +?> integerProp; + @override + UndefinedWrapper< + num +?> numberProp; + @override + UndefinedWrapper< + bool +?> booleanProp; + @override + UndefinedWrapper< + String +?> stringProp; + @override + UndefinedWrapper< + DateTime +?> dateProp; + @override + UndefinedWrapper< + DateTime +?> datetimeProp; + @override + UndefinedWrapper< + List< + + $FreeFormObject +> +?> arrayNullableProp; + @override + UndefinedWrapper< + List< + + $FreeFormObject +?> +?> arrayAndItemsNullableProp; + @override + UndefinedWrapper< + List< + + $FreeFormObject +?> +> arrayItemsNullable; + @override + UndefinedWrapper< + Map +?> objectNullableProp; + @override + UndefinedWrapper< + Map +?> objectAndItemsNullableProp; + @override + UndefinedWrapper< + Map +> objectItemsNullable; + + AdditionalProperties< + $FreeFormObject +?> additionalProperties; + + + + NullableClass.$all({ + required this.integerProp, + required this.numberProp, + required this.booleanProp, + required this.stringProp, + required this.dateProp, + required this.datetimeProp, + required this.arrayNullableProp, + required this.arrayAndItemsNullableProp, + required this.arrayItemsNullable, + required this.objectNullableProp, + required this.objectAndItemsNullableProp, + required this.objectItemsNullable, + required this.additionalProperties, + + }); + + NullableClass({ + this.integerProp = const UndefinedWrapper + .undefined() +, + this.numberProp = const UndefinedWrapper + .undefined() +, + this.booleanProp = const UndefinedWrapper + .undefined() +, + this.stringProp = const UndefinedWrapper + .undefined() +, + this.dateProp = const UndefinedWrapper + .undefined() +, + this.datetimeProp = const UndefinedWrapper + .undefined() +, + this.arrayNullableProp = const UndefinedWrapper + .undefined() +, + this.arrayAndItemsNullableProp = const UndefinedWrapper + .undefined() +, + this.arrayItemsNullable = const UndefinedWrapper + .undefined() +, + this.objectNullableProp = const UndefinedWrapper + .undefined() +, + this.objectAndItemsNullableProp = const UndefinedWrapper + .undefined() +, + this.objectItemsNullable = const UndefinedWrapper + .undefined() +, + AdditionalProperties< + $FreeFormObject +?>? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = NullableClassReflection.instance; + NullableClassReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory NullableClass.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + NullableClass clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_class.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_class.reflection.dart new file mode 100644 index 000000000000..7b797c90545c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_class.reflection.dart @@ -0,0 +1,761 @@ +// Model reflection + +part of 'nullable_class.dart'; + + +//class reflection + +class NullableClassReflection extends ModelReflection { + static NullableClassReflection instanceGetter() => instance; + static const instance = NullableClassReflection._( + modelName: r'NullableClass', + className: r'NullableClass', + xml: XmlReflection( +), + integerPropPart: PropertyReflection>( + dartName: r'integerProp', + nullable: true, + required: false, + oasName: r'integer_prop', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_integerPropGetter), + setter: FunctionWrapper2(_integerPropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.forint + +), +) +), + ), + numberPropPart: PropertyReflection>( + dartName: r'numberProp', + nullable: true, + required: false, + oasName: r'number_prop', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_numberPropGetter), + setter: FunctionWrapper2(_numberPropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.fornum + +), +) +), + ), + booleanPropPart: PropertyReflection>( + dartName: r'booleanProp', + nullable: true, + required: false, + oasName: r'boolean_prop', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_booleanPropGetter), + setter: FunctionWrapper2(_booleanPropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.forbool + +), +) +), + ), + stringPropPart: PropertyReflection>( + dartName: r'stringProp', + nullable: true, + required: false, + oasName: r'string_prop', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_stringPropGetter), + setter: FunctionWrapper2(_stringPropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.forString + +), +) +), + ), + datePropPart: PropertyReflection>( + dartName: r'dateProp', + nullable: true, + required: false, + oasName: r'date_prop', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_datePropGetter), + setter: FunctionWrapper2(_datePropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.forDateTime + +), +) +), + ), + datetimePropPart: PropertyReflection>( + dartName: r'datetimeProp', + nullable: true, + required: false, + oasName: r'datetime_prop', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_datetimePropGetter), + setter: FunctionWrapper2(_datetimePropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.forDateTime + +), +) +), + ), + arrayNullablePropPart: PropertyReflection +?>>( + dartName: r'arrayNullableProp', + nullable: true, + required: false, + oasName: r'array_nullable_prop', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayNullablePropGetter), + setter: FunctionWrapper2(_arrayNullablePropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.for$FreeFormObject + +, +) +) +), +) +), + ), + arrayAndItemsNullablePropPart: PropertyReflection +?>>( + dartName: r'arrayAndItemsNullableProp', + nullable: true, + required: false, + oasName: r'array_and_items_nullable_prop', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayAndItemsNullablePropGetter), + setter: FunctionWrapper2(_arrayAndItemsNullablePropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.for$FreeFormObject + +), +) +) +), +) +), + ), + arrayItemsNullablePart: PropertyReflection +>>( + dartName: r'arrayItemsNullable', + nullable: false, + required: false, + oasName: r'array_items_nullable', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_arrayItemsNullableGetter), + setter: FunctionWrapper2(_arrayItemsNullableSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.for$FreeFormObject + +), +) +) +, +) +), + ), + objectNullablePropPart: PropertyReflection +?>>( + dartName: r'objectNullableProp', + nullable: true, + required: false, + oasName: r'object_nullable_prop', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_objectNullablePropGetter), + setter: FunctionWrapper2(_objectNullablePropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.for$FreeFormObject + +, +) +) +), +) +), + ), + objectAndItemsNullablePropPart: PropertyReflection +?>>( + dartName: r'objectAndItemsNullableProp', + nullable: true, + required: false, + oasName: r'object_and_items_nullable_prop', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_objectAndItemsNullablePropGetter), + setter: FunctionWrapper2(_objectAndItemsNullablePropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.for$FreeFormObject + +), +) +) +), +) +), + ), + objectItemsNullablePart: PropertyReflection +>>( + dartName: r'objectItemsNullable', + nullable: false, + required: false, + oasName: r'object_items_nullable', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_objectItemsNullableGetter), + setter: FunctionWrapper2(_objectItemsNullableSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + MapReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.for$FreeFormObject + +), +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.for$FreeFormObject + +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const NullableClassReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.integerPropPart, + required this.numberPropPart, + required this.booleanPropPart, + required this.stringPropPart, + required this.datePropPart, + required this.datetimePropPart, + required this.arrayNullablePropPart, + required this.arrayAndItemsNullablePropPart, + required this.arrayItemsNullablePart, + required this.objectNullablePropPart, + required this.objectAndItemsNullablePropPart, + required this.objectItemsNullablePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> integerPropPart; + static UndefinedWrapper< + int +?> _integerPropGetter(NullableClass parent) { + return parent.integerProp; + } + static void _integerPropSetter(NullableClass parent, UndefinedWrapper< + int +?> value) { + parent.integerProp = value; + } + + final PropertyReflection> numberPropPart; + static UndefinedWrapper< + num +?> _numberPropGetter(NullableClass parent) { + return parent.numberProp; + } + static void _numberPropSetter(NullableClass parent, UndefinedWrapper< + num +?> value) { + parent.numberProp = value; + } + + final PropertyReflection> booleanPropPart; + static UndefinedWrapper< + bool +?> _booleanPropGetter(NullableClass parent) { + return parent.booleanProp; + } + static void _booleanPropSetter(NullableClass parent, UndefinedWrapper< + bool +?> value) { + parent.booleanProp = value; + } + + final PropertyReflection> stringPropPart; + static UndefinedWrapper< + String +?> _stringPropGetter(NullableClass parent) { + return parent.stringProp; + } + static void _stringPropSetter(NullableClass parent, UndefinedWrapper< + String +?> value) { + parent.stringProp = value; + } + + final PropertyReflection> datePropPart; + static UndefinedWrapper< + DateTime +?> _datePropGetter(NullableClass parent) { + return parent.dateProp; + } + static void _datePropSetter(NullableClass parent, UndefinedWrapper< + DateTime +?> value) { + parent.dateProp = value; + } + + final PropertyReflection> datetimePropPart; + static UndefinedWrapper< + DateTime +?> _datetimePropGetter(NullableClass parent) { + return parent.datetimeProp; + } + static void _datetimePropSetter(NullableClass parent, UndefinedWrapper< + DateTime +?> value) { + parent.datetimeProp = value; + } + + final PropertyReflection +?>> arrayNullablePropPart; + static UndefinedWrapper< + List< + + $FreeFormObject +> +?> _arrayNullablePropGetter(NullableClass parent) { + return parent.arrayNullableProp; + } + static void _arrayNullablePropSetter(NullableClass parent, UndefinedWrapper< + List< + + $FreeFormObject +> +?> value) { + parent.arrayNullableProp = value; + } + + final PropertyReflection +?>> arrayAndItemsNullablePropPart; + static UndefinedWrapper< + List< + + $FreeFormObject +?> +?> _arrayAndItemsNullablePropGetter(NullableClass parent) { + return parent.arrayAndItemsNullableProp; + } + static void _arrayAndItemsNullablePropSetter(NullableClass parent, UndefinedWrapper< + List< + + $FreeFormObject +?> +?> value) { + parent.arrayAndItemsNullableProp = value; + } + + final PropertyReflection +>> arrayItemsNullablePart; + static UndefinedWrapper< + List< + + $FreeFormObject +?> +> _arrayItemsNullableGetter(NullableClass parent) { + return parent.arrayItemsNullable; + } + static void _arrayItemsNullableSetter(NullableClass parent, UndefinedWrapper< + List< + + $FreeFormObject +?> +> value) { + parent.arrayItemsNullable = value; + } + + final PropertyReflection +?>> objectNullablePropPart; + static UndefinedWrapper< + Map +?> _objectNullablePropGetter(NullableClass parent) { + return parent.objectNullableProp; + } + static void _objectNullablePropSetter(NullableClass parent, UndefinedWrapper< + Map +?> value) { + parent.objectNullableProp = value; + } + + final PropertyReflection +?>> objectAndItemsNullablePropPart; + static UndefinedWrapper< + Map +?> _objectAndItemsNullablePropGetter(NullableClass parent) { + return parent.objectAndItemsNullableProp; + } + static void _objectAndItemsNullablePropSetter(NullableClass parent, UndefinedWrapper< + Map +?> value) { + parent.objectAndItemsNullableProp = value; + } + + final PropertyReflection +>> objectItemsNullablePart; + static UndefinedWrapper< + Map +> _objectItemsNullableGetter(NullableClass parent) { + return parent.objectItemsNullable; + } + static void _objectItemsNullableSetter(NullableClass parent, UndefinedWrapper< + Map +> value) { + parent.objectItemsNullable = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + integerPropPart, +numberPropPart, +booleanPropPart, +stringPropPart, +datePropPart, +datetimePropPart, +arrayNullablePropPart, +arrayAndItemsNullablePropPart, +arrayItemsNullablePart, +objectNullablePropPart, +objectAndItemsNullablePropPart, +objectItemsNullablePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties< + $FreeFormObject +?> _AdditionalPropertiesGetter(NullableClass instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(NullableClass instance, AdditionalProperties< + $FreeFormObject +?> additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + NullableClass empty() { + return NullableClass( + ); + } + + @override + bool operator ==(Object other) { + return other is NullableClassReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_shape.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_shape.dart new file mode 100644 index 000000000000..12e38708a98a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_shape.dart @@ -0,0 +1,88 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'nullable_shape.reflection.dart'; + + +/// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. +mixin NullableShapeMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + Triangle +> get oneOf0; + UndefinedWrapper< + Quadrilateral +> get oneOf1; +} + +/// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. +class NullableShape with +$OpenApiObjectMixin, + +NullableShapeMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + Triangle +> oneOf0; + + @override + UndefinedWrapper< + Quadrilateral +> oneOf1; + + + NullableShape.$all({ + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + NullableShape({ + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = NullableShapeReflection.instance; + NullableShapeReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory NullableShape.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + NullableShape clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_shape.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_shape.reflection.dart new file mode 100644 index 000000000000..9ebb2e1a27bc --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/nullable_shape.reflection.dart @@ -0,0 +1,271 @@ +// Model reflection + +part of 'nullable_shape.dart'; + + +//class reflection + +class NullableShapeReflection extends ModelReflection { + static NullableShapeReflection instanceGetter() => instance; + static const instance = NullableShapeReflection._( + modelName: r'NullableShape', + className: r'NullableShape', + xml: XmlReflection( +), + discriminatorKey: r'shapeType', + discriminatorImplicitMappings: const { + r'Quadrilateral': QuadrilateralReflection.instance, + r'Triangle': TriangleReflection.instance, + }, + discriminatorMappings: const { + r'Quadrilateral': QuadrilateralReflection.instance, + r'Triangle': TriangleReflection.instance, + }, + + + oneOf0Part: NullableShapeOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: NullableShapeOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const NullableShapeReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(NullableShape instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(NullableShape instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final NullableShapeOneOf0Part oneOf0Part; + + final NullableShapeOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + NullableShape empty() { + return NullableShape( + ); + } + + @override + bool operator ==(Object other) { + return other is NullableShapeReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class NullableShapeOneOf0Part extends OneOfReflection { + + const NullableShapeOneOf0Part({ + required NullableShapeReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, NullableShape> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Triangle +> _getter(NullableShape src) { + return src.oneOf0; +} +static void _setter(NullableShape src, UndefinedWrapper< + Triangle +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + Triangle +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Triangle.$reflection + + + ), +); + + UndefinedWrapper< + Triangle +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class NullableShapeOneOf1Part extends OneOfReflection { + + const NullableShapeOneOf1Part({ + required NullableShapeReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, NullableShape> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Quadrilateral +> _getter(NullableShape src) { + return src.oneOf1; +} +static void _setter(NullableShape src, UndefinedWrapper< + Quadrilateral +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + Quadrilateral +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Quadrilateral.$reflection + + + ), +); + + UndefinedWrapper< + Quadrilateral +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/number_only.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/number_only.dart new file mode 100644 index 000000000000..3e1d2a4713ca --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/number_only.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'number_only.reflection.dart'; + + +/// NumberOnlyMixin +/// +/// Properties: +/// * [justNumber] +mixin NumberOnlyMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + num +> get justNumber; + +} + +/// NumberOnly +/// +/// Properties: +/// * [justNumber] +class NumberOnly with +$OpenApiObjectMixin, + +NumberOnlyMixin { + @override + UndefinedWrapper< + num +> justNumber; + + AdditionalProperties additionalProperties; + + + + NumberOnly.$all({ + required this.justNumber, + required this.additionalProperties, + + }); + + NumberOnly({ + this.justNumber = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = NumberOnlyReflection.instance; + NumberOnlyReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory NumberOnly.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + NumberOnly clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/number_only.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/number_only.reflection.dart new file mode 100644 index 000000000000..e59c17501b5f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/number_only.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'number_only.dart'; + + +//class reflection + +class NumberOnlyReflection extends ModelReflection { + static NumberOnlyReflection instanceGetter() => instance; + static const instance = NumberOnlyReflection._( + modelName: r'NumberOnly', + className: r'NumberOnly', + xml: XmlReflection( +), + justNumberPart: PropertyReflection>( + dartName: r'justNumber', + nullable: false, + required: false, + oasName: r'JustNumber', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_justNumberGetter), + setter: FunctionWrapper2(_justNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const NumberOnlyReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.justNumberPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> justNumberPart; + static UndefinedWrapper< + num +> _justNumberGetter(NumberOnly parent) { + return parent.justNumber; + } + static void _justNumberSetter(NumberOnly parent, UndefinedWrapper< + num +> value) { + parent.justNumber = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + justNumberPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(NumberOnly instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(NumberOnly instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + NumberOnly empty() { + return NumberOnly( + ); + } + + @override + bool operator ==(Object other) { + return other is NumberOnlyReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/object_with_deprecated_fields.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/object_with_deprecated_fields.dart new file mode 100644 index 000000000000..0fa66230816b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/object_with_deprecated_fields.dart @@ -0,0 +1,138 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'object_with_deprecated_fields.reflection.dart'; + + +/// ObjectWithDeprecatedFieldsMixin +/// +/// Properties: +/// * [uuid] +/// * [id] +/// * [deprecatedRef] +/// * [bars] +mixin ObjectWithDeprecatedFieldsMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get uuid; +UndefinedWrapper< + num +> get id; +UndefinedWrapper< + DeprecatedObject +> get deprecatedRef; +UndefinedWrapper< + List< + + String +> +> get bars; + +} + +/// ObjectWithDeprecatedFields +/// +/// Properties: +/// * [uuid] +/// * [id] +/// * [deprecatedRef] +/// * [bars] +class ObjectWithDeprecatedFields with +$OpenApiObjectMixin, + +ObjectWithDeprecatedFieldsMixin { + @override + UndefinedWrapper< + String +> uuid; + @override + UndefinedWrapper< + num +> id; + @override + UndefinedWrapper< + DeprecatedObject +> deprecatedRef; + @override + UndefinedWrapper< + List< + + String +> +> bars; + + AdditionalProperties additionalProperties; + + + + ObjectWithDeprecatedFields.$all({ + required this.uuid, + required this.id, + required this.deprecatedRef, + required this.bars, + required this.additionalProperties, + + }); + + ObjectWithDeprecatedFields({ + this.uuid = const UndefinedWrapper + .undefined() +, + this.id = const UndefinedWrapper + .undefined() +, + this.deprecatedRef = const UndefinedWrapper + .undefined() +, + this.bars = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ObjectWithDeprecatedFieldsReflection.instance; + ObjectWithDeprecatedFieldsReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ObjectWithDeprecatedFields.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ObjectWithDeprecatedFields clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/object_with_deprecated_fields.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/object_with_deprecated_fields.reflection.dart new file mode 100644 index 000000000000..bb496f931b5f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/object_with_deprecated_fields.reflection.dart @@ -0,0 +1,297 @@ +// Model reflection + +part of 'object_with_deprecated_fields.dart'; + + +//class reflection + +class ObjectWithDeprecatedFieldsReflection extends ModelReflection { + static ObjectWithDeprecatedFieldsReflection instanceGetter() => instance; + static const instance = ObjectWithDeprecatedFieldsReflection._( + modelName: r'ObjectWithDeprecatedFields', + className: r'ObjectWithDeprecatedFields', + xml: XmlReflection( +), + uuidPart: PropertyReflection>( + dartName: r'uuid', + nullable: false, + required: false, + oasName: r'uuid', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_uuidGetter), + setter: FunctionWrapper2(_uuidSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +), + ), + deprecatedRefPart: PropertyReflection>( + dartName: r'deprecatedRef', + nullable: false, + required: false, + oasName: r'deprecatedRef', + oasType: r'DeprecatedObject', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_deprecatedRefGetter), + setter: FunctionWrapper2(_deprecatedRefSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + DeprecatedObject.$reflection + +, +) +), + ), + barsPart: PropertyReflection +>>( + dartName: r'bars', + nullable: false, + required: false, + oasName: r'bars', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_barsGetter), + setter: FunctionWrapper2(_barsSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ObjectWithDeprecatedFieldsReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.uuidPart, + required this.idPart, + required this.deprecatedRefPart, + required this.barsPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> uuidPart; + static UndefinedWrapper< + String +> _uuidGetter(ObjectWithDeprecatedFields parent) { + return parent.uuid; + } + static void _uuidSetter(ObjectWithDeprecatedFields parent, UndefinedWrapper< + String +> value) { + parent.uuid = value; + } + + final PropertyReflection> idPart; + static UndefinedWrapper< + num +> _idGetter(ObjectWithDeprecatedFields parent) { + return parent.id; + } + static void _idSetter(ObjectWithDeprecatedFields parent, UndefinedWrapper< + num +> value) { + parent.id = value; + } + + final PropertyReflection> deprecatedRefPart; + static UndefinedWrapper< + DeprecatedObject +> _deprecatedRefGetter(ObjectWithDeprecatedFields parent) { + return parent.deprecatedRef; + } + static void _deprecatedRefSetter(ObjectWithDeprecatedFields parent, UndefinedWrapper< + DeprecatedObject +> value) { + parent.deprecatedRef = value; + } + + final PropertyReflection +>> barsPart; + static UndefinedWrapper< + List< + + String +> +> _barsGetter(ObjectWithDeprecatedFields parent) { + return parent.bars; + } + static void _barsSetter(ObjectWithDeprecatedFields parent, UndefinedWrapper< + List< + + String +> +> value) { + parent.bars = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + uuidPart, +idPart, +deprecatedRefPart, +barsPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ObjectWithDeprecatedFields instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ObjectWithDeprecatedFields instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ObjectWithDeprecatedFields empty() { + return ObjectWithDeprecatedFields( + ); + } + + @override + bool operator ==(Object other) { + return other is ObjectWithDeprecatedFieldsReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/order.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/order.dart new file mode 100644 index 000000000000..6a629e7fb769 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/order.dart @@ -0,0 +1,218 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'order.reflection.dart'; + + +/// OrderMixin +/// +/// Properties: +/// * [id] +/// * [petId] +/// * [quantity] +/// * [shipDate] +/// * [status] - Order Status +/// * [complete] +mixin OrderMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; +UndefinedWrapper< + int +> get petId; +UndefinedWrapper< + int +> get quantity; +UndefinedWrapper< + DateTime +> get shipDate; +UndefinedWrapper< + OrderStatusEnum +> get status; +UndefinedWrapper< + bool +> get complete; + +} + +/// Order +/// +/// Properties: +/// * [id] +/// * [petId] +/// * [quantity] +/// * [shipDate] +/// * [status] - Order Status +/// * [complete] +class Order with +$OpenApiObjectMixin, + +OrderMixin { + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + int +> petId; + @override + UndefinedWrapper< + int +> quantity; + @override + UndefinedWrapper< + DateTime +> shipDate; + @override + UndefinedWrapper< + OrderStatusEnum +> status; + @override + UndefinedWrapper< + bool +> complete; + + AdditionalProperties additionalProperties; + + + + Order.$all({ + required this.id, + required this.petId, + required this.quantity, + required this.shipDate, + required this.status, + required this.complete, + required this.additionalProperties, + + }); + + Order({ + this.id = const UndefinedWrapper + .undefined() +, + this.petId = const UndefinedWrapper + .undefined() +, + this.quantity = const UndefinedWrapper + .undefined() +, + this.shipDate = const UndefinedWrapper + .undefined() +, + this.status = const UndefinedWrapper + .undefined() +, + this.complete = const UndefinedWrapper + ( + + false + ) + +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = OrderReflection.instance; + OrderReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Order.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Order clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + +extension type const OrderStatusEnum._(String value) implements String { + /// Order Status + const OrderStatusEnum.placed() : this._(r'placed'); + /// Order Status + const OrderStatusEnum.approved() : this._(r'approved'); + /// Order Status + const OrderStatusEnum.delivered() : this._(r'delivered'); + + /// Creates a [OrderStatusEnum] enum from a value and safely checking if it exists. + factory OrderStatusEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'placed', oasValue: r'placed', value: OrderStatusEnum.placed()), + + EnumMemberReflection(dartName: r'approved', oasValue: r'approved', value: OrderStatusEnum.approved()), + + EnumMemberReflection(dartName: r'delivered', oasValue: r'delivered', value: OrderStatusEnum.delivered()), + + ], + ); + + factory OrderStatusEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [OrderStatusEnum] enum from a value without checking if it exists. + const OrderStatusEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + OrderStatusEnum.placed(), + OrderStatusEnum.approved(), + OrderStatusEnum.delivered(), + + ]; +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/order.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/order.reflection.dart new file mode 100644 index 000000000000..1018f7301ae9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/order.reflection.dart @@ -0,0 +1,366 @@ +// Model reflection + +part of 'order.dart'; + + +//class reflection + +class OrderReflection extends ModelReflection { + static OrderReflection instanceGetter() => instance; + static const instance = OrderReflection._( + modelName: r'Order', + className: r'Order', + xml: XmlReflection( + xmlName: r'Order', +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + petIdPart: PropertyReflection>( + dartName: r'petId', + nullable: false, + required: false, + oasName: r'petId', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_petIdGetter), + setter: FunctionWrapper2(_petIdSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + quantityPart: PropertyReflection>( + dartName: r'quantity', + nullable: false, + required: false, + oasName: r'quantity', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_quantityGetter), + setter: FunctionWrapper2(_quantitySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + shipDatePart: PropertyReflection>( + dartName: r'shipDate', + nullable: false, + required: false, + oasName: r'shipDate', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_shipDateGetter), + setter: FunctionWrapper2(_shipDateSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +), + ), + statusPart: PropertyReflection>( + dartName: r'status', + nullable: false, + required: false, + oasName: r'status', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_statusGetter), + setter: FunctionWrapper2(_statusSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + OrderStatusEnum.$reflection + + +, +) +), + ), + completePart: PropertyReflection>( + dartName: r'complete', + nullable: false, + required: false, + oasName: r'complete', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_completeGetter), + setter: FunctionWrapper2(_completeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const OrderReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.petIdPart, + required this.quantityPart, + required this.shipDatePart, + required this.statusPart, + required this.completePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(Order parent) { + return parent.id; + } + static void _idSetter(Order parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> petIdPart; + static UndefinedWrapper< + int +> _petIdGetter(Order parent) { + return parent.petId; + } + static void _petIdSetter(Order parent, UndefinedWrapper< + int +> value) { + parent.petId = value; + } + + final PropertyReflection> quantityPart; + static UndefinedWrapper< + int +> _quantityGetter(Order parent) { + return parent.quantity; + } + static void _quantitySetter(Order parent, UndefinedWrapper< + int +> value) { + parent.quantity = value; + } + + final PropertyReflection> shipDatePart; + static UndefinedWrapper< + DateTime +> _shipDateGetter(Order parent) { + return parent.shipDate; + } + static void _shipDateSetter(Order parent, UndefinedWrapper< + DateTime +> value) { + parent.shipDate = value; + } + + final PropertyReflection> statusPart; + static UndefinedWrapper< + OrderStatusEnum +> _statusGetter(Order parent) { + return parent.status; + } + static void _statusSetter(Order parent, UndefinedWrapper< + OrderStatusEnum +> value) { + parent.status = value; + } + + final PropertyReflection> completePart; + static UndefinedWrapper< + bool +> _completeGetter(Order parent) { + return parent.complete; + } + static void _completeSetter(Order parent, UndefinedWrapper< + bool +> value) { + parent.complete = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +petIdPart, +quantityPart, +shipDatePart, +statusPart, +completePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Order instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Order instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Order empty() { + return Order( + ); + } + + @override + bool operator ==(Object other) { + return other is OrderReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_composite.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_composite.dart new file mode 100644 index 000000000000..7b5f614710ec --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_composite.dart @@ -0,0 +1,114 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'outer_composite.reflection.dart'; + + +/// OuterCompositeMixin +/// +/// Properties: +/// * [myNumber] +/// * [myString] +/// * [myBoolean] +mixin OuterCompositeMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + num +> get myNumber; +UndefinedWrapper< + String +> get myString; +UndefinedWrapper< + bool +> get myBoolean; + +} + +/// OuterComposite +/// +/// Properties: +/// * [myNumber] +/// * [myString] +/// * [myBoolean] +class OuterComposite with +$OpenApiObjectMixin, + +OuterCompositeMixin { + @override + UndefinedWrapper< + num +> myNumber; + @override + UndefinedWrapper< + String +> myString; + @override + UndefinedWrapper< + bool +> myBoolean; + + AdditionalProperties additionalProperties; + + + + OuterComposite.$all({ + required this.myNumber, + required this.myString, + required this.myBoolean, + required this.additionalProperties, + + }); + + OuterComposite({ + this.myNumber = const UndefinedWrapper + .undefined() +, + this.myString = const UndefinedWrapper + .undefined() +, + this.myBoolean = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = OuterCompositeReflection.instance; + OuterCompositeReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory OuterComposite.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + OuterComposite clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_composite.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_composite.reflection.dart new file mode 100644 index 000000000000..652da8646646 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_composite.reflection.dart @@ -0,0 +1,233 @@ +// Model reflection + +part of 'outer_composite.dart'; + + +//class reflection + +class OuterCompositeReflection extends ModelReflection { + static OuterCompositeReflection instanceGetter() => instance; + static const instance = OuterCompositeReflection._( + modelName: r'OuterComposite', + className: r'OuterComposite', + xml: XmlReflection( +), + myNumberPart: PropertyReflection>( + dartName: r'myNumber', + nullable: false, + required: false, + oasName: r'my_number', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_myNumberGetter), + setter: FunctionWrapper2(_myNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +), + ), + myStringPart: PropertyReflection>( + dartName: r'myString', + nullable: false, + required: false, + oasName: r'my_string', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_myStringGetter), + setter: FunctionWrapper2(_myStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + myBooleanPart: PropertyReflection>( + dartName: r'myBoolean', + nullable: false, + required: false, + oasName: r'my_boolean', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_myBooleanGetter), + setter: FunctionWrapper2(_myBooleanSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const OuterCompositeReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.myNumberPart, + required this.myStringPart, + required this.myBooleanPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> myNumberPart; + static UndefinedWrapper< + num +> _myNumberGetter(OuterComposite parent) { + return parent.myNumber; + } + static void _myNumberSetter(OuterComposite parent, UndefinedWrapper< + num +> value) { + parent.myNumber = value; + } + + final PropertyReflection> myStringPart; + static UndefinedWrapper< + String +> _myStringGetter(OuterComposite parent) { + return parent.myString; + } + static void _myStringSetter(OuterComposite parent, UndefinedWrapper< + String +> value) { + parent.myString = value; + } + + final PropertyReflection> myBooleanPart; + static UndefinedWrapper< + bool +> _myBooleanGetter(OuterComposite parent) { + return parent.myBoolean; + } + static void _myBooleanSetter(OuterComposite parent, UndefinedWrapper< + bool +> value) { + parent.myBoolean = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + myNumberPart, +myStringPart, +myBooleanPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(OuterComposite instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(OuterComposite instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + OuterComposite empty() { + return OuterComposite( + ); + } + + @override + bool operator ==(Object other) { + return other is OuterCompositeReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum.dart new file mode 100644 index 000000000000..5a6bb846bfae --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum.dart @@ -0,0 +1,68 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'outer_enum.reflection.dart'; + + +//enum def + +extension type const OuterEnum._(String value) implements String { + const OuterEnum.placed() : this._(r'placed'); + const OuterEnum.approved() : this._(r'approved'); + const OuterEnum.delivered() : this._(r'delivered'); + const OuterEnum.LOWER_CASE_S() : this._(r's'); + const OuterEnum.UPPER_CASE_S() : this._(r'S'); + + /// Creates a [OuterEnum] enum from a value and safely checking if it exists. + factory OuterEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'placed', oasValue: r'placed', value: OuterEnum.placed()), + + EnumMemberReflection(dartName: r'approved', oasValue: r'approved', value: OuterEnum.approved()), + + EnumMemberReflection(dartName: r'delivered', oasValue: r'delivered', value: OuterEnum.delivered()), + + EnumMemberReflection(dartName: r'LOWER_CASE_S', oasValue: r's', value: OuterEnum.LOWER_CASE_S()), + + EnumMemberReflection(dartName: r'UPPER_CASE_S', oasValue: r'S', value: OuterEnum.UPPER_CASE_S()), + + ], + ); + + factory OuterEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [OuterEnum] enum from a value without checking if it exists. + const OuterEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + OuterEnum.placed(), + OuterEnum.approved(), + OuterEnum.delivered(), + OuterEnum.LOWER_CASE_S(), + OuterEnum.UPPER_CASE_S(), + + ]; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum.reflection.dart new file mode 100644 index 000000000000..e8dd472b3457 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum.reflection.dart @@ -0,0 +1,6 @@ +// Model reflection + +part of 'outer_enum.dart'; + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_default_value.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_default_value.dart new file mode 100644 index 000000000000..0900d74efd6e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_default_value.dart @@ -0,0 +1,60 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'outer_enum_default_value.reflection.dart'; + + +//enum def + +extension type const OuterEnumDefaultValue._(String value) implements String { + const OuterEnumDefaultValue.placed() : this._(r'placed'); + const OuterEnumDefaultValue.approved() : this._(r'approved'); + const OuterEnumDefaultValue.delivered() : this._(r'delivered'); + + /// Creates a [OuterEnumDefaultValue] enum from a value and safely checking if it exists. + factory OuterEnumDefaultValue.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'placed', oasValue: r'placed', value: OuterEnumDefaultValue.placed()), + + EnumMemberReflection(dartName: r'approved', oasValue: r'approved', value: OuterEnumDefaultValue.approved()), + + EnumMemberReflection(dartName: r'delivered', oasValue: r'delivered', value: OuterEnumDefaultValue.delivered()), + + ], + ); + + factory OuterEnumDefaultValue.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [OuterEnumDefaultValue] enum from a value without checking if it exists. + const OuterEnumDefaultValue.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + OuterEnumDefaultValue.placed(), + OuterEnumDefaultValue.approved(), + OuterEnumDefaultValue.delivered(), + + ]; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_default_value.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_default_value.reflection.dart new file mode 100644 index 000000000000..50561ec65230 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_default_value.reflection.dart @@ -0,0 +1,6 @@ +// Model reflection + +part of 'outer_enum_default_value.dart'; + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer.dart new file mode 100644 index 000000000000..a9b4dbe9859b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer.dart @@ -0,0 +1,60 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'outer_enum_integer.reflection.dart'; + + +//enum def + +extension type const OuterEnumInteger._(int value) implements int { + const OuterEnumInteger.number0() : this._(0); + const OuterEnumInteger.number1() : this._(1); + const OuterEnumInteger.number2() : this._(2); + + /// Creates a [OuterEnumInteger] enum from a value and safely checking if it exists. + factory OuterEnumInteger.$safe(int value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forint, + members: [ + + EnumMemberReflection(dartName: r'number0', oasValue: 0, value: OuterEnumInteger.number0()), + + EnumMemberReflection(dartName: r'number1', oasValue: 1, value: OuterEnumInteger.number1()), + + EnumMemberReflection(dartName: r'number2', oasValue: 2, value: OuterEnumInteger.number2()), + + ], + ); + + factory OuterEnumInteger.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [OuterEnumInteger] enum from a value without checking if it exists. + const OuterEnumInteger.$unsafe(int value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + OuterEnumInteger.number0(), + OuterEnumInteger.number1(), + OuterEnumInteger.number2(), + + ]; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer.reflection.dart new file mode 100644 index 000000000000..2c175fd63b3c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer.reflection.dart @@ -0,0 +1,6 @@ +// Model reflection + +part of 'outer_enum_integer.dart'; + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer_default_value.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer_default_value.dart new file mode 100644 index 000000000000..2da9f22b1d6b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer_default_value.dart @@ -0,0 +1,60 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'outer_enum_integer_default_value.reflection.dart'; + + +//enum def + +extension type const OuterEnumIntegerDefaultValue._(int value) implements int { + const OuterEnumIntegerDefaultValue.number0() : this._(0); + const OuterEnumIntegerDefaultValue.number1() : this._(1); + const OuterEnumIntegerDefaultValue.number2() : this._(2); + + /// Creates a [OuterEnumIntegerDefaultValue] enum from a value and safely checking if it exists. + factory OuterEnumIntegerDefaultValue.$safe(int value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forint, + members: [ + + EnumMemberReflection(dartName: r'number0', oasValue: 0, value: OuterEnumIntegerDefaultValue.number0()), + + EnumMemberReflection(dartName: r'number1', oasValue: 1, value: OuterEnumIntegerDefaultValue.number1()), + + EnumMemberReflection(dartName: r'number2', oasValue: 2, value: OuterEnumIntegerDefaultValue.number2()), + + ], + ); + + factory OuterEnumIntegerDefaultValue.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [OuterEnumIntegerDefaultValue] enum from a value without checking if it exists. + const OuterEnumIntegerDefaultValue.$unsafe(int value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + OuterEnumIntegerDefaultValue.number0(), + OuterEnumIntegerDefaultValue.number1(), + OuterEnumIntegerDefaultValue.number2(), + + ]; +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer_default_value.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer_default_value.reflection.dart new file mode 100644 index 000000000000..b921ad73b47d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/outer_enum_integer_default_value.reflection.dart @@ -0,0 +1,6 @@ +// Model reflection + +part of 'outer_enum_integer_default_value.dart'; + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/parent_pet.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/parent_pet.dart new file mode 100644 index 000000000000..c77e4d931a69 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/parent_pet.dart @@ -0,0 +1,69 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'parent_pet.reflection.dart'; + + +/// ParentPetMixin +mixin ParentPetMixin on + GrandparentAnimalMixin, $OpenApiObjectMixin { + +} + +/// ParentPet +class ParentPet with +$OpenApiObjectMixin, +GrandparentAnimalMixin, +ParentPetMixin { + @override + + String + petType; + + AdditionalProperties additionalProperties; + + + + ParentPet.$all({ + required this.petType, + required this.additionalProperties, + + }); + + ParentPet({ + required this.petType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ParentPetReflection.instance; + ParentPetReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory ParentPet.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ParentPet clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/parent_pet.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/parent_pet.reflection.dart new file mode 100644 index 000000000000..6ac206b54d34 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/parent_pet.reflection.dart @@ -0,0 +1,164 @@ +// Model reflection + +part of 'parent_pet.dart'; + + +//class reflection + +class ParentPetReflection extends ModelReflection { + static ParentPetReflection instanceGetter() => instance; + static const instance = ParentPetReflection._( + modelName: r'ParentPet', + className: r'ParentPet', + xml: XmlReflection( +), + petTypePart: PropertyReflection( + dartName: r'petType', + nullable: false, + required: true, + oasName: r'pet_type', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_petTypeGetter), + setter: FunctionWrapper2(_petTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + discriminatorKey: r'pet_type', + discriminatorImplicitMappings: const { + r'GrandparentAnimal': GrandparentAnimalReflection.instance, + }, + discriminatorMappings: const { + }, + allOfGrandparentAnimalPart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: GrandparentAnimalReflection.instance, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ParentPetReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.petTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfGrandparentAnimalPart, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection petTypePart; + static + String + _petTypeGetter(ParentPet parent) { + return parent.petType; + } + static void _petTypeSetter(ParentPet parent, + String + value) { + parent.petType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + petTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ParentPet instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ParentPet instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + final AllOfReflection allOfGrandparentAnimalPart; + + + + @override + List> get allOfs => [ + allOfGrandparentAnimalPart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ParentPet empty() { + return ParentPet( + petType: petTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is ParentPetReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet.dart new file mode 100644 index 000000000000..57dcdfca4eb9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet.dart @@ -0,0 +1,226 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'pet.reflection.dart'; + + +/// PetMixin +/// +/// Properties: +/// * [id] +/// * [category] +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +mixin PetMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; +UndefinedWrapper< + Category +> get category; + + String + get name; + + List< + + String +> + get photoUrls; +UndefinedWrapper< + List< + + Tag +> +> get tags; +UndefinedWrapper< + PetStatusEnum +> get status; + +} + +/// Pet +/// +/// Properties: +/// * [id] +/// * [category] +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +class Pet with +$OpenApiObjectMixin, + +PetMixin { + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + Category +> category; + @override + + String + name; + @override + + List< + + String +> + photoUrls; + @override + UndefinedWrapper< + List< + + Tag +> +> tags; + @override + UndefinedWrapper< + PetStatusEnum +> status; + + AdditionalProperties additionalProperties; + + + + Pet.$all({ + required this.id, + required this.category, + required this.name, + required this.photoUrls, + required this.tags, + required this.status, + required this.additionalProperties, + + }); + + Pet({ + this.id = const UndefinedWrapper + .undefined() +, + this.category = const UndefinedWrapper + .undefined() +, +required this.name , +required this.photoUrls , + this.tags = const UndefinedWrapper + .undefined() +, + this.status = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = PetReflection.instance; + PetReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Pet.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Pet clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + +extension type const PetStatusEnum._(String value) implements String { + /// pet status in the store + const PetStatusEnum.available() : this._(r'available'); + /// pet status in the store + const PetStatusEnum.pending() : this._(r'pending'); + /// pet status in the store + const PetStatusEnum.sold() : this._(r'sold'); + + /// Creates a [PetStatusEnum] enum from a value and safely checking if it exists. + factory PetStatusEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'available', oasValue: r'available', value: PetStatusEnum.available()), + + EnumMemberReflection(dartName: r'pending', oasValue: r'pending', value: PetStatusEnum.pending()), + + EnumMemberReflection(dartName: r'sold', oasValue: r'sold', value: PetStatusEnum.sold()), + + ], + ); + + factory PetStatusEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [PetStatusEnum] enum from a value without checking if it exists. + const PetStatusEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + PetStatusEnum.available(), + PetStatusEnum.pending(), + PetStatusEnum.sold(), + + ]; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet.reflection.dart new file mode 100644 index 000000000000..fcf19dc249b8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet.reflection.dart @@ -0,0 +1,417 @@ +// Model reflection + +part of 'pet.dart'; + + +//class reflection + +class PetReflection extends ModelReflection { + static PetReflection instanceGetter() => instance; + static const instance = PetReflection._( + modelName: r'Pet', + className: r'Pet', + xml: XmlReflection( + xmlName: r'Pet', +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + categoryPart: PropertyReflection>( + dartName: r'category', + nullable: false, + required: false, + oasName: r'category', + oasType: r'Category', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'Category', +), + getter: FunctionWrapper1(_categoryGetter), + setter: FunctionWrapper2(_categorySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Category', +), + + + + + + Category.$reflection + +, +) +), + ), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + photoUrlsPart: PropertyReflection +>( + dartName: r'photoUrls', + nullable: false, + required: true, + oasName: r'photoUrls', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + getter: FunctionWrapper1(_photoUrlsGetter), + setter: FunctionWrapper2(_photoUrlsSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +, + ), + tagsPart: PropertyReflection +>>( + dartName: r'tags', + nullable: false, + required: false, + oasName: r'tags', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + getter: FunctionWrapper1(_tagsGetter), + setter: FunctionWrapper2(_tagsSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Tag', +), + + + + + + Tag.$reflection + +, +) +) +, +) +), + ), + statusPart: PropertyReflection>( + dartName: r'status', + nullable: false, + required: false, + oasName: r'status', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_statusGetter), + setter: FunctionWrapper2(_statusSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + PetStatusEnum.$reflection + + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const PetReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.categoryPart, + required this.namePart, + required this.photoUrlsPart, + required this.tagsPart, + required this.statusPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(Pet parent) { + return parent.id; + } + static void _idSetter(Pet parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> categoryPart; + static UndefinedWrapper< + Category +> _categoryGetter(Pet parent) { + return parent.category; + } + static void _categorySetter(Pet parent, UndefinedWrapper< + Category +> value) { + parent.category = value; + } + + final PropertyReflection namePart; + static + String + _nameGetter(Pet parent) { + return parent.name; + } + static void _nameSetter(Pet parent, + String + value) { + parent.name = value; + } + + final PropertyReflection +> photoUrlsPart; + static + List< + + String +> + _photoUrlsGetter(Pet parent) { + return parent.photoUrls; + } + static void _photoUrlsSetter(Pet parent, + List< + + String +> + value) { + parent.photoUrls = value; + } + + final PropertyReflection +>> tagsPart; + static UndefinedWrapper< + List< + + Tag +> +> _tagsGetter(Pet parent) { + return parent.tags; + } + static void _tagsSetter(Pet parent, UndefinedWrapper< + List< + + Tag +> +> value) { + parent.tags = value; + } + + final PropertyReflection> statusPart; + static UndefinedWrapper< + PetStatusEnum +> _statusGetter(Pet parent) { + return parent.status; + } + static void _statusSetter(Pet parent, UndefinedWrapper< + PetStatusEnum +> value) { + parent.status = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +categoryPart, +namePart, +photoUrlsPart, +tagsPart, +statusPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Pet instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Pet instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Pet empty() { + return Pet( + name: namePart.reflection.emptyFunction(), + photoUrls: photoUrlsPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is PetReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_composition.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_composition.dart new file mode 100644 index 000000000000..5214f5a42241 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_composition.dart @@ -0,0 +1,123 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'pet_composition.reflection.dart'; + + +/// PetCompositionMixin +/// +/// Properties: +mixin PetCompositionMixin on + PetMixin, $OpenApiObjectMixin { + +} + +/// PetComposition +/// +/// Properties: +/// * [photoUrls] +/// * [name] +/// * [id] +/// * [category] +/// * [tags] +/// * [status] - pet status in the store +class PetComposition with +$OpenApiObjectMixin, +PetMixin, +PetCompositionMixin { + @override + + List< + + String +> + photoUrls; + @override + + String + name; + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + Category +> category; + @override + UndefinedWrapper< + List< + + Tag +> +> tags; + @override + UndefinedWrapper< + PetStatusEnum +> status; + + AdditionalProperties additionalProperties; + + + + PetComposition.$all({ + required this.photoUrls, + required this.name, + required this.id, + required this.category, + required this.tags, + required this.status, + required this.additionalProperties, + + }); + + PetComposition({ + required this.photoUrls , +required this.name , + this.id = const UndefinedWrapper + .undefined() +, + this.category = const UndefinedWrapper + .undefined() +, + this.tags = const UndefinedWrapper + .undefined() +, + this.status = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = PetCompositionReflection.instance; + PetCompositionReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory PetComposition.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + PetComposition clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_composition.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_composition.reflection.dart new file mode 100644 index 000000000000..4b3cba2cc16c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_composition.reflection.dart @@ -0,0 +1,430 @@ +// Model reflection + +part of 'pet_composition.dart'; + + +//class reflection + +class PetCompositionReflection extends ModelReflection { + static PetCompositionReflection instanceGetter() => instance; + static const instance = PetCompositionReflection._( + modelName: r'PetComposition', + className: r'PetComposition', + xml: XmlReflection( +), + photoUrlsPart: PropertyReflection +>( + dartName: r'photoUrls', + nullable: false, + required: true, + oasName: r'photoUrls', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + getter: FunctionWrapper1(_photoUrlsGetter), + setter: FunctionWrapper2(_photoUrlsSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +, + ), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + categoryPart: PropertyReflection>( + dartName: r'category', + nullable: false, + required: false, + oasName: r'category', + oasType: r'Category', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'Category', +), + getter: FunctionWrapper1(_categoryGetter), + setter: FunctionWrapper2(_categorySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Category', +), + + + + + + Category.$reflection + +, +) +), + ), + tagsPart: PropertyReflection +>>( + dartName: r'tags', + nullable: false, + required: false, + oasName: r'tags', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + getter: FunctionWrapper1(_tagsGetter), + setter: FunctionWrapper2(_tagsSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Tag', +), + + + + + + Tag.$reflection + +, +) +) +, +) +), + ), + statusPart: PropertyReflection>( + dartName: r'status', + nullable: false, + required: false, + oasName: r'status', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_statusGetter), + setter: FunctionWrapper2(_statusSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + PetStatusEnum.$reflection + + +, +) +), + ), + allOfPetPart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: PetReflection.instance, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const PetCompositionReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.photoUrlsPart, + required this.namePart, + required this.idPart, + required this.categoryPart, + required this.tagsPart, + required this.statusPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfPetPart, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection +> photoUrlsPart; + static + List< + + String +> + _photoUrlsGetter(PetComposition parent) { + return parent.photoUrls; + } + static void _photoUrlsSetter(PetComposition parent, + List< + + String +> + value) { + parent.photoUrls = value; + } + + final PropertyReflection namePart; + static + String + _nameGetter(PetComposition parent) { + return parent.name; + } + static void _nameSetter(PetComposition parent, + String + value) { + parent.name = value; + } + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(PetComposition parent) { + return parent.id; + } + static void _idSetter(PetComposition parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> categoryPart; + static UndefinedWrapper< + Category +> _categoryGetter(PetComposition parent) { + return parent.category; + } + static void _categorySetter(PetComposition parent, UndefinedWrapper< + Category +> value) { + parent.category = value; + } + + final PropertyReflection +>> tagsPart; + static UndefinedWrapper< + List< + + Tag +> +> _tagsGetter(PetComposition parent) { + return parent.tags; + } + static void _tagsSetter(PetComposition parent, UndefinedWrapper< + List< + + Tag +> +> value) { + parent.tags = value; + } + + final PropertyReflection> statusPart; + static UndefinedWrapper< + PetStatusEnum +> _statusGetter(PetComposition parent) { + return parent.status; + } + static void _statusSetter(PetComposition parent, UndefinedWrapper< + PetStatusEnum +> value) { + parent.status = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + photoUrlsPart, +namePart, +idPart, +categoryPart, +tagsPart, +statusPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(PetComposition instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(PetComposition instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + final AllOfReflection allOfPetPart; + + + + @override + List> get allOfs => [ + allOfPetPart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + PetComposition empty() { + return PetComposition( + photoUrls: photoUrlsPart.reflection.emptyFunction(), + name: namePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is PetCompositionReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_ref.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_ref.dart new file mode 100644 index 000000000000..9919b1cf83f1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_ref.dart @@ -0,0 +1,226 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'pet_ref.reflection.dart'; + + +/// PetRefMixin +/// +/// Properties: +/// * [id] +/// * [category] +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +mixin PetRefMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; +UndefinedWrapper< + Category +> get category; + + String + get name; + + List< + + String +> + get photoUrls; +UndefinedWrapper< + List< + + Tag +> +> get tags; +UndefinedWrapper< + PetRefStatusEnum +> get status; + +} + +/// PetRef +/// +/// Properties: +/// * [id] +/// * [category] +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +class PetRef with +$OpenApiObjectMixin, + +PetRefMixin { + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + Category +> category; + @override + + String + name; + @override + + List< + + String +> + photoUrls; + @override + UndefinedWrapper< + List< + + Tag +> +> tags; + @override + UndefinedWrapper< + PetRefStatusEnum +> status; + + AdditionalProperties additionalProperties; + + + + PetRef.$all({ + required this.id, + required this.category, + required this.name, + required this.photoUrls, + required this.tags, + required this.status, + required this.additionalProperties, + + }); + + PetRef({ + this.id = const UndefinedWrapper + .undefined() +, + this.category = const UndefinedWrapper + .undefined() +, +required this.name , +required this.photoUrls , + this.tags = const UndefinedWrapper + .undefined() +, + this.status = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = PetRefReflection.instance; + PetRefReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory PetRef.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + PetRef clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + +extension type const PetRefStatusEnum._(String value) implements String { + /// pet status in the store + const PetRefStatusEnum.available() : this._(r'available'); + /// pet status in the store + const PetRefStatusEnum.pending() : this._(r'pending'); + /// pet status in the store + const PetRefStatusEnum.sold() : this._(r'sold'); + + /// Creates a [PetRefStatusEnum] enum from a value and safely checking if it exists. + factory PetRefStatusEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'available', oasValue: r'available', value: PetRefStatusEnum.available()), + + EnumMemberReflection(dartName: r'pending', oasValue: r'pending', value: PetRefStatusEnum.pending()), + + EnumMemberReflection(dartName: r'sold', oasValue: r'sold', value: PetRefStatusEnum.sold()), + + ], + ); + + factory PetRefStatusEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [PetRefStatusEnum] enum from a value without checking if it exists. + const PetRefStatusEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + PetRefStatusEnum.available(), + PetRefStatusEnum.pending(), + PetRefStatusEnum.sold(), + + ]; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_ref.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_ref.reflection.dart new file mode 100644 index 000000000000..a370652ad873 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_ref.reflection.dart @@ -0,0 +1,417 @@ +// Model reflection + +part of 'pet_ref.dart'; + + +//class reflection + +class PetRefReflection extends ModelReflection { + static PetRefReflection instanceGetter() => instance; + static const instance = PetRefReflection._( + modelName: r'PetRef', + className: r'PetRef', + xml: XmlReflection( + xmlName: r'Pet', +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + categoryPart: PropertyReflection>( + dartName: r'category', + nullable: false, + required: false, + oasName: r'category', + oasType: r'Category', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'Category', +), + getter: FunctionWrapper1(_categoryGetter), + setter: FunctionWrapper2(_categorySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Category', +), + + + + + + Category.$reflection + +, +) +), + ), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + photoUrlsPart: PropertyReflection +>( + dartName: r'photoUrls', + nullable: false, + required: true, + oasName: r'photoUrls', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + getter: FunctionWrapper1(_photoUrlsGetter), + setter: FunctionWrapper2(_photoUrlsSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +, + ), + tagsPart: PropertyReflection +>>( + dartName: r'tags', + nullable: false, + required: false, + oasName: r'tags', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + getter: FunctionWrapper1(_tagsGetter), + setter: FunctionWrapper2(_tagsSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Tag', +), + + + + + + Tag.$reflection + +, +) +) +, +) +), + ), + statusPart: PropertyReflection>( + dartName: r'status', + nullable: false, + required: false, + oasName: r'status', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_statusGetter), + setter: FunctionWrapper2(_statusSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + PetRefStatusEnum.$reflection + + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const PetRefReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.categoryPart, + required this.namePart, + required this.photoUrlsPart, + required this.tagsPart, + required this.statusPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(PetRef parent) { + return parent.id; + } + static void _idSetter(PetRef parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> categoryPart; + static UndefinedWrapper< + Category +> _categoryGetter(PetRef parent) { + return parent.category; + } + static void _categorySetter(PetRef parent, UndefinedWrapper< + Category +> value) { + parent.category = value; + } + + final PropertyReflection namePart; + static + String + _nameGetter(PetRef parent) { + return parent.name; + } + static void _nameSetter(PetRef parent, + String + value) { + parent.name = value; + } + + final PropertyReflection +> photoUrlsPart; + static + List< + + String +> + _photoUrlsGetter(PetRef parent) { + return parent.photoUrls; + } + static void _photoUrlsSetter(PetRef parent, + List< + + String +> + value) { + parent.photoUrls = value; + } + + final PropertyReflection +>> tagsPart; + static UndefinedWrapper< + List< + + Tag +> +> _tagsGetter(PetRef parent) { + return parent.tags; + } + static void _tagsSetter(PetRef parent, UndefinedWrapper< + List< + + Tag +> +> value) { + parent.tags = value; + } + + final PropertyReflection> statusPart; + static UndefinedWrapper< + PetRefStatusEnum +> _statusGetter(PetRef parent) { + return parent.status; + } + static void _statusSetter(PetRef parent, UndefinedWrapper< + PetRefStatusEnum +> value) { + parent.status = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +categoryPart, +namePart, +photoUrlsPart, +tagsPart, +statusPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(PetRef instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(PetRef instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + PetRef empty() { + return PetRef( + name: namePart.reflection.emptyFunction(), + photoUrls: photoUrlsPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is PetRefReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_using_all_of.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_using_all_of.dart new file mode 100644 index 000000000000..c6dccf1f2664 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_using_all_of.dart @@ -0,0 +1,226 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'pet_using_all_of.reflection.dart'; + + +/// PetUsingAllOfMixin +/// +/// Properties: +/// * [id] +/// * [category] - multi line description 2nd line last line +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +mixin PetUsingAllOfMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; +UndefinedWrapper< + Category +> get category; + + String + get name; + + List< + + String +> + get photoUrls; +UndefinedWrapper< + List< + + Tag +> +> get tags; +UndefinedWrapper< + PetUsingAllOfStatusEnum +> get status; + +} + +/// PetUsingAllOf +/// +/// Properties: +/// * [id] +/// * [category] - multi line description 2nd line last line +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +class PetUsingAllOf with +$OpenApiObjectMixin, + +PetUsingAllOfMixin { + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + Category +> category; + @override + + String + name; + @override + + List< + + String +> + photoUrls; + @override + UndefinedWrapper< + List< + + Tag +> +> tags; + @override + UndefinedWrapper< + PetUsingAllOfStatusEnum +> status; + + AdditionalProperties additionalProperties; + + + + PetUsingAllOf.$all({ + required this.id, + required this.category, + required this.name, + required this.photoUrls, + required this.tags, + required this.status, + required this.additionalProperties, + + }); + + PetUsingAllOf({ + this.id = const UndefinedWrapper + .undefined() +, + this.category = const UndefinedWrapper + .undefined() +, +required this.name , +required this.photoUrls , + this.tags = const UndefinedWrapper + .undefined() +, + this.status = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = PetUsingAllOfReflection.instance; + PetUsingAllOfReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory PetUsingAllOf.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + PetUsingAllOf clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + +extension type const PetUsingAllOfStatusEnum._(String value) implements String { + /// pet status in the store + const PetUsingAllOfStatusEnum.available() : this._(r'available'); + /// pet status in the store + const PetUsingAllOfStatusEnum.pending() : this._(r'pending'); + /// pet status in the store + const PetUsingAllOfStatusEnum.sold() : this._(r'sold'); + + /// Creates a [PetUsingAllOfStatusEnum] enum from a value and safely checking if it exists. + factory PetUsingAllOfStatusEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'available', oasValue: r'available', value: PetUsingAllOfStatusEnum.available()), + + EnumMemberReflection(dartName: r'pending', oasValue: r'pending', value: PetUsingAllOfStatusEnum.pending()), + + EnumMemberReflection(dartName: r'sold', oasValue: r'sold', value: PetUsingAllOfStatusEnum.sold()), + + ], + ); + + factory PetUsingAllOfStatusEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [PetUsingAllOfStatusEnum] enum from a value without checking if it exists. + const PetUsingAllOfStatusEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + PetUsingAllOfStatusEnum.available(), + PetUsingAllOfStatusEnum.pending(), + PetUsingAllOfStatusEnum.sold(), + + ]; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_using_all_of.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_using_all_of.reflection.dart new file mode 100644 index 000000000000..f2be4108a684 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_using_all_of.reflection.dart @@ -0,0 +1,416 @@ +// Model reflection + +part of 'pet_using_all_of.dart'; + + +//class reflection + +class PetUsingAllOfReflection extends ModelReflection { + static PetUsingAllOfReflection instanceGetter() => instance; + static const instance = PetUsingAllOfReflection._( + modelName: r'PetUsingAllOf', + className: r'PetUsingAllOf', + xml: XmlReflection( +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + categoryPart: PropertyReflection>( + dartName: r'category', + nullable: false, + required: false, + oasName: r'category', + oasType: r'Category', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'Category', +), + getter: FunctionWrapper1(_categoryGetter), + setter: FunctionWrapper2(_categorySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Category', +), + + + + + + Category.$reflection + +, +) +), + ), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + photoUrlsPart: PropertyReflection +>( + dartName: r'photoUrls', + nullable: false, + required: true, + oasName: r'photoUrls', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + getter: FunctionWrapper1(_photoUrlsGetter), + setter: FunctionWrapper2(_photoUrlsSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +, + ), + tagsPart: PropertyReflection +>>( + dartName: r'tags', + nullable: false, + required: false, + oasName: r'tags', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + getter: FunctionWrapper1(_tagsGetter), + setter: FunctionWrapper2(_tagsSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Tag', +), + + + + + + Tag.$reflection + +, +) +) +, +) +), + ), + statusPart: PropertyReflection>( + dartName: r'status', + nullable: false, + required: false, + oasName: r'status', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_statusGetter), + setter: FunctionWrapper2(_statusSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + PetUsingAllOfStatusEnum.$reflection + + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const PetUsingAllOfReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.categoryPart, + required this.namePart, + required this.photoUrlsPart, + required this.tagsPart, + required this.statusPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(PetUsingAllOf parent) { + return parent.id; + } + static void _idSetter(PetUsingAllOf parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> categoryPart; + static UndefinedWrapper< + Category +> _categoryGetter(PetUsingAllOf parent) { + return parent.category; + } + static void _categorySetter(PetUsingAllOf parent, UndefinedWrapper< + Category +> value) { + parent.category = value; + } + + final PropertyReflection namePart; + static + String + _nameGetter(PetUsingAllOf parent) { + return parent.name; + } + static void _nameSetter(PetUsingAllOf parent, + String + value) { + parent.name = value; + } + + final PropertyReflection +> photoUrlsPart; + static + List< + + String +> + _photoUrlsGetter(PetUsingAllOf parent) { + return parent.photoUrls; + } + static void _photoUrlsSetter(PetUsingAllOf parent, + List< + + String +> + value) { + parent.photoUrls = value; + } + + final PropertyReflection +>> tagsPart; + static UndefinedWrapper< + List< + + Tag +> +> _tagsGetter(PetUsingAllOf parent) { + return parent.tags; + } + static void _tagsSetter(PetUsingAllOf parent, UndefinedWrapper< + List< + + Tag +> +> value) { + parent.tags = value; + } + + final PropertyReflection> statusPart; + static UndefinedWrapper< + PetUsingAllOfStatusEnum +> _statusGetter(PetUsingAllOf parent) { + return parent.status; + } + static void _statusSetter(PetUsingAllOf parent, UndefinedWrapper< + PetUsingAllOfStatusEnum +> value) { + parent.status = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +categoryPart, +namePart, +photoUrlsPart, +tagsPart, +statusPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(PetUsingAllOf instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(PetUsingAllOf instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + PetUsingAllOf empty() { + return PetUsingAllOf( + name: namePart.reflection.emptyFunction(), + photoUrls: photoUrlsPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is PetUsingAllOfReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_with_required_tags.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_with_required_tags.dart new file mode 100644 index 000000000000..3af8f47209e3 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_with_required_tags.dart @@ -0,0 +1,224 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'pet_with_required_tags.reflection.dart'; + + +/// PetWithRequiredTagsMixin +/// +/// Properties: +/// * [id] +/// * [category] +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +mixin PetWithRequiredTagsMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; +UndefinedWrapper< + Category +> get category; + + String + get name; + + List< + + String +> + get photoUrls; + + List< + + Tag +> + get tags; +UndefinedWrapper< + PetWithRequiredTagsStatusEnum +> get status; + +} + +/// PetWithRequiredTags +/// +/// Properties: +/// * [id] +/// * [category] +/// * [name] +/// * [photoUrls] +/// * [tags] +/// * [status] - pet status in the store +class PetWithRequiredTags with +$OpenApiObjectMixin, + +PetWithRequiredTagsMixin { + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + Category +> category; + @override + + String + name; + @override + + List< + + String +> + photoUrls; + @override + + List< + + Tag +> + tags; + @override + UndefinedWrapper< + PetWithRequiredTagsStatusEnum +> status; + + AdditionalProperties additionalProperties; + + + + PetWithRequiredTags.$all({ + required this.id, + required this.category, + required this.name, + required this.photoUrls, + required this.tags, + required this.status, + required this.additionalProperties, + + }); + + PetWithRequiredTags({ + this.id = const UndefinedWrapper + .undefined() +, + this.category = const UndefinedWrapper + .undefined() +, +required this.name , +required this.photoUrls , +required this.tags , + this.status = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = PetWithRequiredTagsReflection.instance; + PetWithRequiredTagsReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory PetWithRequiredTags.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + PetWithRequiredTags clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + +extension type const PetWithRequiredTagsStatusEnum._(String value) implements String { + /// pet status in the store + const PetWithRequiredTagsStatusEnum.available() : this._(r'available'); + /// pet status in the store + const PetWithRequiredTagsStatusEnum.pending() : this._(r'pending'); + /// pet status in the store + const PetWithRequiredTagsStatusEnum.sold() : this._(r'sold'); + + /// Creates a [PetWithRequiredTagsStatusEnum] enum from a value and safely checking if it exists. + factory PetWithRequiredTagsStatusEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'available', oasValue: r'available', value: PetWithRequiredTagsStatusEnum.available()), + + EnumMemberReflection(dartName: r'pending', oasValue: r'pending', value: PetWithRequiredTagsStatusEnum.pending()), + + EnumMemberReflection(dartName: r'sold', oasValue: r'sold', value: PetWithRequiredTagsStatusEnum.sold()), + + ], + ); + + factory PetWithRequiredTagsStatusEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [PetWithRequiredTagsStatusEnum] enum from a value without checking if it exists. + const PetWithRequiredTagsStatusEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + PetWithRequiredTagsStatusEnum.available(), + PetWithRequiredTagsStatusEnum.pending(), + PetWithRequiredTagsStatusEnum.sold(), + + ]; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_with_required_tags.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_with_required_tags.reflection.dart new file mode 100644 index 000000000000..960102c7c95a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pet_with_required_tags.reflection.dart @@ -0,0 +1,418 @@ +// Model reflection + +part of 'pet_with_required_tags.dart'; + + +//class reflection + +class PetWithRequiredTagsReflection extends ModelReflection { + static PetWithRequiredTagsReflection instanceGetter() => instance; + static const instance = PetWithRequiredTagsReflection._( + modelName: r'PetWithRequiredTags', + className: r'PetWithRequiredTags', + xml: XmlReflection( + xmlName: r'Pet', +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + categoryPart: PropertyReflection>( + dartName: r'category', + nullable: false, + required: false, + oasName: r'category', + oasType: r'Category', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'Category', +), + getter: FunctionWrapper1(_categoryGetter), + setter: FunctionWrapper2(_categorySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Category', +), + + + + + + Category.$reflection + +, +) +), + ), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + photoUrlsPart: PropertyReflection +>( + dartName: r'photoUrls', + nullable: false, + required: true, + oasName: r'photoUrls', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + getter: FunctionWrapper1(_photoUrlsGetter), + setter: FunctionWrapper2(_photoUrlsSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'photoUrl', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +, + ), + tagsPart: PropertyReflection +>( + dartName: r'tags', + nullable: false, + required: true, + oasName: r'tags', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + getter: FunctionWrapper1(_tagsGetter), + setter: FunctionWrapper2(_tagsSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'tag', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'Tag', +), + + + + + + Tag.$reflection + +, +) +) +, +) +, + ), + statusPart: PropertyReflection>( + dartName: r'status', + nullable: false, + required: false, + oasName: r'status', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_statusGetter), + setter: FunctionWrapper2(_statusSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + PetWithRequiredTagsStatusEnum.$reflection + + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const PetWithRequiredTagsReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.categoryPart, + required this.namePart, + required this.photoUrlsPart, + required this.tagsPart, + required this.statusPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(PetWithRequiredTags parent) { + return parent.id; + } + static void _idSetter(PetWithRequiredTags parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> categoryPart; + static UndefinedWrapper< + Category +> _categoryGetter(PetWithRequiredTags parent) { + return parent.category; + } + static void _categorySetter(PetWithRequiredTags parent, UndefinedWrapper< + Category +> value) { + parent.category = value; + } + + final PropertyReflection namePart; + static + String + _nameGetter(PetWithRequiredTags parent) { + return parent.name; + } + static void _nameSetter(PetWithRequiredTags parent, + String + value) { + parent.name = value; + } + + final PropertyReflection +> photoUrlsPart; + static + List< + + String +> + _photoUrlsGetter(PetWithRequiredTags parent) { + return parent.photoUrls; + } + static void _photoUrlsSetter(PetWithRequiredTags parent, + List< + + String +> + value) { + parent.photoUrls = value; + } + + final PropertyReflection +> tagsPart; + static + List< + + Tag +> + _tagsGetter(PetWithRequiredTags parent) { + return parent.tags; + } + static void _tagsSetter(PetWithRequiredTags parent, + List< + + Tag +> + value) { + parent.tags = value; + } + + final PropertyReflection> statusPart; + static UndefinedWrapper< + PetWithRequiredTagsStatusEnum +> _statusGetter(PetWithRequiredTags parent) { + return parent.status; + } + static void _statusSetter(PetWithRequiredTags parent, UndefinedWrapper< + PetWithRequiredTagsStatusEnum +> value) { + parent.status = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +categoryPart, +namePart, +photoUrlsPart, +tagsPart, +statusPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(PetWithRequiredTags instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(PetWithRequiredTags instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + PetWithRequiredTags empty() { + return PetWithRequiredTags( + name: namePart.reflection.emptyFunction(), + photoUrls: photoUrlsPart.reflection.emptyFunction(), + tags: tagsPart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is PetWithRequiredTagsReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request.dart new file mode 100644 index 000000000000..03990bd6c7b3 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request.dart @@ -0,0 +1,122 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'pets_multicontent_test_post_request.reflection.dart'; + + +/// PetsMulticontentTestPostRequestMixin +/// +/// Properties: +/// * [id] +/// * [address] +/// * [profileImages] +mixin PetsMulticontentTestPostRequestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get id; +UndefinedWrapper< + PetsMulticontentTestPostRequestAddress +> get address; +UndefinedWrapper< + List< + + XFile +> +> get profileImages; + +} + +/// PetsMulticontentTestPostRequest +/// +/// Properties: +/// * [id] +/// * [address] +/// * [profileImages] +class PetsMulticontentTestPostRequest with +$OpenApiObjectMixin, + +PetsMulticontentTestPostRequestMixin { + @override + UndefinedWrapper< + String +> id; + @override + UndefinedWrapper< + PetsMulticontentTestPostRequestAddress +> address; + @override + UndefinedWrapper< + List< + + XFile +> +> profileImages; + + AdditionalProperties additionalProperties; + + + + PetsMulticontentTestPostRequest.$all({ + required this.id, + required this.address, + required this.profileImages, + required this.additionalProperties, + + }); + + PetsMulticontentTestPostRequest({ + this.id = const UndefinedWrapper + .undefined() +, + this.address = const UndefinedWrapper + .undefined() +, + this.profileImages = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = PetsMulticontentTestPostRequestReflection.instance; + PetsMulticontentTestPostRequestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory PetsMulticontentTestPostRequest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + PetsMulticontentTestPostRequest clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request.reflection.dart new file mode 100644 index 000000000000..962e75a0697c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request.reflection.dart @@ -0,0 +1,252 @@ +// Model reflection + +part of 'pets_multicontent_test_post_request.dart'; + + +//class reflection + +class PetsMulticontentTestPostRequestReflection extends ModelReflection { + static PetsMulticontentTestPostRequestReflection instanceGetter() => instance; + static const instance = PetsMulticontentTestPostRequestReflection._( + modelName: r'_pets_multicontent_test_post_request', + className: r'PetsMulticontentTestPostRequest', + xml: XmlReflection( +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + addressPart: PropertyReflection>( + dartName: r'address', + nullable: false, + required: false, + oasName: r'address', + oasType: r'PetsMulticontentTestPostRequestAddress', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_addressGetter), + setter: FunctionWrapper2(_addressSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PetsMulticontentTestPostRequestAddress.$reflection + +, +) +), + ), + profileImagesPart: PropertyReflection +>>( + dartName: r'profileImages', + nullable: false, + required: false, + oasName: r'profileImages', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_profileImagesGetter), + setter: FunctionWrapper2(_profileImagesSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forXFile + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const PetsMulticontentTestPostRequestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.addressPart, + required this.profileImagesPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + String +> _idGetter(PetsMulticontentTestPostRequest parent) { + return parent.id; + } + static void _idSetter(PetsMulticontentTestPostRequest parent, UndefinedWrapper< + String +> value) { + parent.id = value; + } + + final PropertyReflection> addressPart; + static UndefinedWrapper< + PetsMulticontentTestPostRequestAddress +> _addressGetter(PetsMulticontentTestPostRequest parent) { + return parent.address; + } + static void _addressSetter(PetsMulticontentTestPostRequest parent, UndefinedWrapper< + PetsMulticontentTestPostRequestAddress +> value) { + parent.address = value; + } + + final PropertyReflection +>> profileImagesPart; + static UndefinedWrapper< + List< + + XFile +> +> _profileImagesGetter(PetsMulticontentTestPostRequest parent) { + return parent.profileImages; + } + static void _profileImagesSetter(PetsMulticontentTestPostRequest parent, UndefinedWrapper< + List< + + XFile +> +> value) { + parent.profileImages = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +addressPart, +profileImagesPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(PetsMulticontentTestPostRequest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(PetsMulticontentTestPostRequest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + PetsMulticontentTestPostRequest empty() { + return PetsMulticontentTestPostRequest( + ); + } + + @override + bool operator ==(Object other) { + return other is PetsMulticontentTestPostRequestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request_address.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request_address.dart new file mode 100644 index 000000000000..d57bb8ef750d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request_address.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'pets_multicontent_test_post_request_address.reflection.dart'; + + +/// PetsMulticontentTestPostRequestAddressMixin +/// +/// Properties: +/// * [street] +/// * [city] +mixin PetsMulticontentTestPostRequestAddressMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get street; +UndefinedWrapper< + String +> get city; + +} + +/// PetsMulticontentTestPostRequestAddress +/// +/// Properties: +/// * [street] +/// * [city] +class PetsMulticontentTestPostRequestAddress with +$OpenApiObjectMixin, + +PetsMulticontentTestPostRequestAddressMixin { + @override + UndefinedWrapper< + String +> street; + @override + UndefinedWrapper< + String +> city; + + AdditionalProperties additionalProperties; + + + + PetsMulticontentTestPostRequestAddress.$all({ + required this.street, + required this.city, + required this.additionalProperties, + + }); + + PetsMulticontentTestPostRequestAddress({ + this.street = const UndefinedWrapper + .undefined() +, + this.city = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = PetsMulticontentTestPostRequestAddressReflection.instance; + PetsMulticontentTestPostRequestAddressReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory PetsMulticontentTestPostRequestAddress.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + PetsMulticontentTestPostRequestAddress clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request_address.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request_address.reflection.dart new file mode 100644 index 000000000000..d9238e5a61dd --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pets_multicontent_test_post_request_address.reflection.dart @@ -0,0 +1,188 @@ +// Model reflection + +part of 'pets_multicontent_test_post_request_address.dart'; + + +//class reflection + +class PetsMulticontentTestPostRequestAddressReflection extends ModelReflection { + static PetsMulticontentTestPostRequestAddressReflection instanceGetter() => instance; + static const instance = PetsMulticontentTestPostRequestAddressReflection._( + modelName: r'_pets_multicontent_test_post_request_address', + className: r'PetsMulticontentTestPostRequestAddress', + xml: XmlReflection( +), + streetPart: PropertyReflection>( + dartName: r'street', + nullable: false, + required: false, + oasName: r'street', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_streetGetter), + setter: FunctionWrapper2(_streetSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + cityPart: PropertyReflection>( + dartName: r'city', + nullable: false, + required: false, + oasName: r'city', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_cityGetter), + setter: FunctionWrapper2(_citySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const PetsMulticontentTestPostRequestAddressReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.streetPart, + required this.cityPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> streetPart; + static UndefinedWrapper< + String +> _streetGetter(PetsMulticontentTestPostRequestAddress parent) { + return parent.street; + } + static void _streetSetter(PetsMulticontentTestPostRequestAddress parent, UndefinedWrapper< + String +> value) { + parent.street = value; + } + + final PropertyReflection> cityPart; + static UndefinedWrapper< + String +> _cityGetter(PetsMulticontentTestPostRequestAddress parent) { + return parent.city; + } + static void _citySetter(PetsMulticontentTestPostRequestAddress parent, UndefinedWrapper< + String +> value) { + parent.city = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + streetPart, +cityPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(PetsMulticontentTestPostRequestAddress instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(PetsMulticontentTestPostRequestAddress instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + PetsMulticontentTestPostRequestAddress empty() { + return PetsMulticontentTestPostRequestAddress( + ); + } + + @override + bool operator ==(Object other) { + return other is PetsMulticontentTestPostRequestAddressReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pig.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pig.dart new file mode 100644 index 000000000000..34c94b5d4ede --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pig.dart @@ -0,0 +1,106 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'pig.reflection.dart'; + + +/// PigMixin +/// +/// Properties: +/// * [className] +mixin PigMixin on + $OpenApiObjectMixin { + + String + get className; + + UndefinedWrapper< + BasquePig +> get oneOf0; + UndefinedWrapper< + DanishPig +> get oneOf1; +} + +/// Pig +/// +/// Properties: +/// * [className] +class Pig with +$OpenApiObjectMixin, + +PigMixin { + @override + + String + className; + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + BasquePig +> oneOf0; + + @override + UndefinedWrapper< + DanishPig +> oneOf1; + + + Pig.$all({ + required this.className, + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + Pig({ + required this.className , + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = PigReflection.instance; + PigReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory Pig.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Pig clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/pig.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/pig.reflection.dart new file mode 100644 index 000000000000..0abd58eeff7d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/pig.reflection.dart @@ -0,0 +1,317 @@ +// Model reflection + +part of 'pig.dart'; + + +//class reflection + +class PigReflection extends ModelReflection { + static PigReflection instanceGetter() => instance; + static const instance = PigReflection._( + modelName: r'Pig', + className: r'Pig', + xml: XmlReflection( +), + classNamePart: PropertyReflection( + dartName: r'className', + nullable: false, + required: true, + oasName: r'className', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_classNameGetter), + setter: FunctionWrapper2(_classNameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + discriminatorKey: r'className', + discriminatorImplicitMappings: const { + r'BasquePig': BasquePigReflection.instance, + r'DanishPig': DanishPigReflection.instance, + }, + discriminatorMappings: const { + r'BasquePig': BasquePigReflection.instance, + r'DanishPig': DanishPigReflection.instance, + }, + + + oneOf0Part: PigOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: PigOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const PigReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.classNamePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection classNamePart; + static + String + _classNameGetter(Pig parent) { + return parent.className; + } + static void _classNameSetter(Pig parent, + String + value) { + parent.className = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + classNamePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Pig instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Pig instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final PigOneOf0Part oneOf0Part; + + final PigOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Pig empty() { + return Pig( + className: classNamePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is PigReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class PigOneOf0Part extends OneOfReflection { + + const PigOneOf0Part({ + required PigReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Pig> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + BasquePig +> _getter(Pig src) { + return src.oneOf0; +} +static void _setter(Pig src, UndefinedWrapper< + BasquePig +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + BasquePig +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + BasquePig.$reflection + + + ), +); + + UndefinedWrapper< + BasquePig +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class PigOneOf1Part extends OneOfReflection { + + const PigOneOf1Part({ + required PigReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Pig> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + DanishPig +> _getter(Pig src) { + return src.oneOf1; +} +static void _setter(Pig src, UndefinedWrapper< + DanishPig +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + DanishPig +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + DanishPig.$reflection + + + ), +); + + UndefinedWrapper< + DanishPig +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/property_name_collision.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/property_name_collision.dart new file mode 100644 index 000000000000..ac86dbbc06e4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/property_name_collision.dart @@ -0,0 +1,114 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'property_name_collision.reflection.dart'; + + +/// PropertyNameCollisionMixin +/// +/// Properties: +/// * [$type] +/// * [type] +/// * [type$] +mixin PropertyNameCollisionMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get $type; +UndefinedWrapper< + String +> get type; +UndefinedWrapper< + String +> get type$; + +} + +/// PropertyNameCollision +/// +/// Properties: +/// * [$type] +/// * [type] +/// * [type$] +class PropertyNameCollision with +$OpenApiObjectMixin, + +PropertyNameCollisionMixin { + @override + UndefinedWrapper< + String +> $type; + @override + UndefinedWrapper< + String +> type; + @override + UndefinedWrapper< + String +> type$; + + AdditionalProperties additionalProperties; + + + + PropertyNameCollision.$all({ + required this.$type, + required this.type, + required this.type$, + required this.additionalProperties, + + }); + + PropertyNameCollision({ + this.$type = const UndefinedWrapper + .undefined() +, + this.type = const UndefinedWrapper + .undefined() +, + this.type$ = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = PropertyNameCollisionReflection.instance; + PropertyNameCollisionReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory PropertyNameCollision.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + PropertyNameCollision clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/property_name_collision.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/property_name_collision.reflection.dart new file mode 100644 index 000000000000..12ad38edabda --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/property_name_collision.reflection.dart @@ -0,0 +1,233 @@ +// Model reflection + +part of 'property_name_collision.dart'; + + +//class reflection + +class PropertyNameCollisionReflection extends ModelReflection { + static PropertyNameCollisionReflection instanceGetter() => instance; + static const instance = PropertyNameCollisionReflection._( + modelName: r'PropertyNameCollision', + className: r'PropertyNameCollision', + xml: XmlReflection( +), + $typePart: PropertyReflection>( + dartName: r'$type', + nullable: false, + required: false, + oasName: r'_type', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_$typeGetter), + setter: FunctionWrapper2(_$typeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + typePart: PropertyReflection>( + dartName: r'type', + nullable: false, + required: false, + oasName: r'type', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_typeGetter), + setter: FunctionWrapper2(_typeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + type$Part: PropertyReflection>( + dartName: r'type$', + nullable: false, + required: false, + oasName: r'type_', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_type$Getter), + setter: FunctionWrapper2(_type$Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const PropertyNameCollisionReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.$typePart, + required this.typePart, + required this.type$Part, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> $typePart; + static UndefinedWrapper< + String +> _$typeGetter(PropertyNameCollision parent) { + return parent.$type; + } + static void _$typeSetter(PropertyNameCollision parent, UndefinedWrapper< + String +> value) { + parent.$type = value; + } + + final PropertyReflection> typePart; + static UndefinedWrapper< + String +> _typeGetter(PropertyNameCollision parent) { + return parent.type; + } + static void _typeSetter(PropertyNameCollision parent, UndefinedWrapper< + String +> value) { + parent.type = value; + } + + final PropertyReflection> type$Part; + static UndefinedWrapper< + String +> _type$Getter(PropertyNameCollision parent) { + return parent.type$; + } + static void _type$Setter(PropertyNameCollision parent, UndefinedWrapper< + String +> value) { + parent.type$ = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + $typePart, +typePart, +type$Part, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(PropertyNameCollision instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(PropertyNameCollision instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + PropertyNameCollision empty() { + return PropertyNameCollision( + ); + } + + @override + bool operator ==(Object other) { + return other is PropertyNameCollisionReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral.dart new file mode 100644 index 000000000000..5b4be1782fee --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral.dart @@ -0,0 +1,106 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'quadrilateral.reflection.dart'; + + +/// QuadrilateralMixin +/// +/// Properties: +/// * [quadrilateralType] +mixin QuadrilateralMixin on + $OpenApiObjectMixin { + + String + get quadrilateralType; + + UndefinedWrapper< + SimpleQuadrilateral +> get oneOf0; + UndefinedWrapper< + ComplexQuadrilateral +> get oneOf1; +} + +/// Quadrilateral +/// +/// Properties: +/// * [quadrilateralType] +class Quadrilateral with +$OpenApiObjectMixin, + +QuadrilateralMixin { + @override + + String + quadrilateralType; + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + SimpleQuadrilateral +> oneOf0; + + @override + UndefinedWrapper< + ComplexQuadrilateral +> oneOf1; + + + Quadrilateral.$all({ + required this.quadrilateralType, + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + Quadrilateral({ + required this.quadrilateralType , + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = QuadrilateralReflection.instance; + QuadrilateralReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory Quadrilateral.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Quadrilateral clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral.reflection.dart new file mode 100644 index 000000000000..54c0030a8852 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral.reflection.dart @@ -0,0 +1,317 @@ +// Model reflection + +part of 'quadrilateral.dart'; + + +//class reflection + +class QuadrilateralReflection extends ModelReflection { + static QuadrilateralReflection instanceGetter() => instance; + static const instance = QuadrilateralReflection._( + modelName: r'Quadrilateral', + className: r'Quadrilateral', + xml: XmlReflection( +), + quadrilateralTypePart: PropertyReflection( + dartName: r'quadrilateralType', + nullable: false, + required: true, + oasName: r'quadrilateralType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_quadrilateralTypeGetter), + setter: FunctionWrapper2(_quadrilateralTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + discriminatorKey: r'quadrilateralType', + discriminatorImplicitMappings: const { + r'ComplexQuadrilateral': ComplexQuadrilateralReflection.instance, + r'SimpleQuadrilateral': SimpleQuadrilateralReflection.instance, + }, + discriminatorMappings: const { + r'ComplexQuadrilateral': ComplexQuadrilateralReflection.instance, + r'SimpleQuadrilateral': SimpleQuadrilateralReflection.instance, + }, + + + oneOf0Part: QuadrilateralOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: QuadrilateralOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const QuadrilateralReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.quadrilateralTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection quadrilateralTypePart; + static + String + _quadrilateralTypeGetter(Quadrilateral parent) { + return parent.quadrilateralType; + } + static void _quadrilateralTypeSetter(Quadrilateral parent, + String + value) { + parent.quadrilateralType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + quadrilateralTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Quadrilateral instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Quadrilateral instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final QuadrilateralOneOf0Part oneOf0Part; + + final QuadrilateralOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Quadrilateral empty() { + return Quadrilateral( + quadrilateralType: quadrilateralTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is QuadrilateralReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class QuadrilateralOneOf0Part extends OneOfReflection { + + const QuadrilateralOneOf0Part({ + required QuadrilateralReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Quadrilateral> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + SimpleQuadrilateral +> _getter(Quadrilateral src) { + return src.oneOf0; +} +static void _setter(Quadrilateral src, UndefinedWrapper< + SimpleQuadrilateral +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + SimpleQuadrilateral +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + SimpleQuadrilateral.$reflection + + + ), +); + + UndefinedWrapper< + SimpleQuadrilateral +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class QuadrilateralOneOf1Part extends OneOfReflection { + + const QuadrilateralOneOf1Part({ + required QuadrilateralReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Quadrilateral> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + ComplexQuadrilateral +> _getter(Quadrilateral src) { + return src.oneOf1; +} +static void _setter(Quadrilateral src, UndefinedWrapper< + ComplexQuadrilateral +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + ComplexQuadrilateral +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ComplexQuadrilateral.$reflection + + + ), +); + + UndefinedWrapper< + ComplexQuadrilateral +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral_interface.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral_interface.dart new file mode 100644 index 000000000000..725ac7820694 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral_interface.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'quadrilateral_interface.reflection.dart'; + + +/// QuadrilateralInterfaceMixin +/// +/// Properties: +/// * [quadrilateralType] +mixin QuadrilateralInterfaceMixin on + $OpenApiObjectMixin { + + String + get quadrilateralType; + +} + +/// QuadrilateralInterface +/// +/// Properties: +/// * [quadrilateralType] +class QuadrilateralInterface with +$OpenApiObjectMixin, + +QuadrilateralInterfaceMixin { + @override + + String + quadrilateralType; + + AdditionalProperties additionalProperties; + + + + QuadrilateralInterface.$all({ + required this.quadrilateralType, + required this.additionalProperties, + + }); + + QuadrilateralInterface({ + required this.quadrilateralType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = QuadrilateralInterfaceReflection.instance; + QuadrilateralInterfaceReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory QuadrilateralInterface.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + QuadrilateralInterface clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral_interface.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral_interface.reflection.dart new file mode 100644 index 000000000000..e05a3dd9ed69 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/quadrilateral_interface.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'quadrilateral_interface.dart'; + + +//class reflection + +class QuadrilateralInterfaceReflection extends ModelReflection { + static QuadrilateralInterfaceReflection instanceGetter() => instance; + static const instance = QuadrilateralInterfaceReflection._( + modelName: r'QuadrilateralInterface', + className: r'QuadrilateralInterface', + xml: XmlReflection( +), + quadrilateralTypePart: PropertyReflection( + dartName: r'quadrilateralType', + nullable: false, + required: true, + oasName: r'quadrilateralType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_quadrilateralTypeGetter), + setter: FunctionWrapper2(_quadrilateralTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const QuadrilateralInterfaceReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.quadrilateralTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection quadrilateralTypePart; + static + String + _quadrilateralTypeGetter(QuadrilateralInterface parent) { + return parent.quadrilateralType; + } + static void _quadrilateralTypeSetter(QuadrilateralInterface parent, + String + value) { + parent.quadrilateralType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + quadrilateralTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(QuadrilateralInterface instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(QuadrilateralInterface instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + QuadrilateralInterface empty() { + return QuadrilateralInterface( + quadrilateralType: quadrilateralTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is QuadrilateralInterfaceReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/read_only_first.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/read_only_first.dart new file mode 100644 index 000000000000..7908938aa86b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/read_only_first.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'read_only_first.reflection.dart'; + + +/// ReadOnlyFirstMixin +/// +/// Properties: +/// * [bar] +/// * [baz] +mixin ReadOnlyFirstMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get bar; +UndefinedWrapper< + String +> get baz; + +} + +/// ReadOnlyFirst +/// +/// Properties: +/// * [bar] +/// * [baz] +class ReadOnlyFirst with +$OpenApiObjectMixin, + +ReadOnlyFirstMixin { + @override + UndefinedWrapper< + String +> bar; + @override + UndefinedWrapper< + String +> baz; + + AdditionalProperties additionalProperties; + + + + ReadOnlyFirst.$all({ + required this.bar, + required this.baz, + required this.additionalProperties, + + }); + + ReadOnlyFirst({ + this.bar = const UndefinedWrapper + .undefined() +, + this.baz = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ReadOnlyFirstReflection.instance; + ReadOnlyFirstReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ReadOnlyFirst.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ReadOnlyFirst clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/read_only_first.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/read_only_first.reflection.dart new file mode 100644 index 000000000000..fb7ee3ae4067 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/read_only_first.reflection.dart @@ -0,0 +1,188 @@ +// Model reflection + +part of 'read_only_first.dart'; + + +//class reflection + +class ReadOnlyFirstReflection extends ModelReflection { + static ReadOnlyFirstReflection instanceGetter() => instance; + static const instance = ReadOnlyFirstReflection._( + modelName: r'ReadOnlyFirst', + className: r'ReadOnlyFirst', + xml: XmlReflection( +), + barPart: PropertyReflection>( + dartName: r'bar', + nullable: false, + required: false, + oasName: r'bar', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_barGetter), + setter: FunctionWrapper2(_barSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + bazPart: PropertyReflection>( + dartName: r'baz', + nullable: false, + required: false, + oasName: r'baz', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_bazGetter), + setter: FunctionWrapper2(_bazSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ReadOnlyFirstReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.barPart, + required this.bazPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> barPart; + static UndefinedWrapper< + String +> _barGetter(ReadOnlyFirst parent) { + return parent.bar; + } + static void _barSetter(ReadOnlyFirst parent, UndefinedWrapper< + String +> value) { + parent.bar = value; + } + + final PropertyReflection> bazPart; + static UndefinedWrapper< + String +> _bazGetter(ReadOnlyFirst parent) { + return parent.baz; + } + static void _bazSetter(ReadOnlyFirst parent, UndefinedWrapper< + String +> value) { + parent.baz = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + barPart, +bazPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ReadOnlyFirst instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ReadOnlyFirst instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ReadOnlyFirst empty() { + return ReadOnlyFirst( + ); + } + + @override + bool operator ==(Object other) { + return other is ReadOnlyFirstReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar.dart new file mode 100644 index 000000000000..e0e19af0c459 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'scalar.reflection.dart'; + + +/// Values of scalar type +mixin ScalarMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + String +> get oneOf0; + UndefinedWrapper< + num +> get oneOf1; + UndefinedWrapper< + bool +> get oneOf2; +} + +/// Values of scalar type +class Scalar with +$OpenApiObjectMixin, + +ScalarMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + String +> oneOf0; + + @override + UndefinedWrapper< + num +> oneOf1; + + @override + UndefinedWrapper< + bool +> oneOf2; + + + Scalar.$all({ + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + required this.oneOf2, + }); + + Scalar({ + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + this.oneOf2 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ScalarReflection.instance; + ScalarReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,oneOf2,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory Scalar.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Scalar clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar.reflection.dart new file mode 100644 index 000000000000..1f717b38843c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar.reflection.dart @@ -0,0 +1,340 @@ +// Model reflection + +part of 'scalar.dart'; + + +//class reflection + +class ScalarReflection extends ModelReflection { + static ScalarReflection instanceGetter() => instance; + static const instance = ScalarReflection._( + modelName: r'Scalar', + className: r'Scalar', + xml: XmlReflection( +), + + + oneOf0Part: ScalarOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: ScalarOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf2Part: ScalarOneOf2Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ScalarReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.oneOf2Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Scalar instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Scalar instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final ScalarOneOf0Part oneOf0Part; + + final ScalarOneOf1Part oneOf1Part; + + final ScalarOneOf2Part oneOf2Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part,oneOf2Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Scalar empty() { + return Scalar( + ); + } + + @override + bool operator ==(Object other) { + return other is ScalarReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class ScalarOneOf0Part extends OneOfReflection { + + const ScalarOneOf0Part({ + required ScalarReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Scalar> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + String +> _getter(Scalar src) { + return src.oneOf0; +} +static void _setter(Scalar src, UndefinedWrapper< + String +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + String +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + + + ), +); + + UndefinedWrapper< + String +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class ScalarOneOf1Part extends OneOfReflection { + + const ScalarOneOf1Part({ + required ScalarReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Scalar> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + num +> _getter(Scalar src) { + return src.oneOf1; +} +static void _setter(Scalar src, UndefinedWrapper< + num +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + num +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + + + ), +); + + UndefinedWrapper< + num +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class ScalarOneOf2Part extends OneOfReflection { + + const ScalarOneOf2Part({ + required ScalarReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Scalar> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + bool +> _getter(Scalar src) { + return src.oneOf2; +} +static void _setter(Scalar src, UndefinedWrapper< + bool +> value) { + src.oneOf2 = value; +} + +@override +UndefinedWrapperReflection< + bool +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + + + ), +); + + UndefinedWrapper< + bool +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar_any_of.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar_any_of.dart new file mode 100644 index 000000000000..925b3968b971 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar_any_of.dart @@ -0,0 +1,96 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'scalar_any_of.reflection.dart'; + + +/// Values of scalar type using anyOf +mixin ScalarAnyOfMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + String +> get anyOf0; + UndefinedWrapper< + num +> get anyOf1; + UndefinedWrapper< + bool +> get anyOf2; +} + +/// Values of scalar type using anyOf +class ScalarAnyOf with +$OpenApiObjectMixin, + +ScalarAnyOfMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + String +> anyOf0; + + @override + UndefinedWrapper< + num +> anyOf1; + + @override + UndefinedWrapper< + bool +> anyOf2; + + + ScalarAnyOf.$all({ + required this.additionalProperties, + + required this.anyOf0, + required this.anyOf1, + required this.anyOf2, + }); + + ScalarAnyOf({ + AdditionalProperties? additionalProperties, + + this.anyOf0 = const UndefinedWrapper.undefined(), + + this.anyOf1 = const UndefinedWrapper.undefined(), + + this.anyOf2 = const UndefinedWrapper.undefined(), + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ScalarAnyOfReflection.instance; + ScalarAnyOfReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory ScalarAnyOf.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ScalarAnyOf clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar_any_of.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar_any_of.reflection.dart new file mode 100644 index 000000000000..11595b8ca153 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalar_any_of.reflection.dart @@ -0,0 +1,313 @@ +// Model reflection + +part of 'scalar_any_of.dart'; + + +//class reflection + +class ScalarAnyOfReflection extends ModelReflection { + static ScalarAnyOfReflection instanceGetter() => instance; + static const instance = ScalarAnyOfReflection._( + modelName: r'ScalarAnyOf', + className: r'ScalarAnyOf', + xml: XmlReflection( +), + + + anyOf0Part: ScalarAnyOfAnyOf0Part( + parentReflectionGetter: instanceGetter, + ), + + anyOf1Part: ScalarAnyOfAnyOf1Part( + parentReflectionGetter: instanceGetter, + ), + + anyOf2Part: ScalarAnyOfAnyOf2Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ScalarAnyOfReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.anyOf0Part, + + required this.anyOf1Part, + + required this.anyOf2Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ScalarAnyOf instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ScalarAnyOf instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final ScalarAnyOfAnyOf0Part anyOf0Part; + + final ScalarAnyOfAnyOf1Part anyOf1Part; + + final ScalarAnyOfAnyOf2Part anyOf2Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + anyOf0Part,anyOf1Part,anyOf2Part, + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ScalarAnyOf empty() { + return ScalarAnyOf( + ); + } + + @override + bool operator ==(Object other) { + return other is ScalarAnyOfReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + +class ScalarAnyOfAnyOf0Part extends AnyOfReflection { + + const ScalarAnyOfAnyOf0Part({ + required ScalarAnyOfReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, ScalarAnyOf> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + String +> _getter(ScalarAnyOf src) { + return src.anyOf0; +} +static void _setter(ScalarAnyOf src, UndefinedWrapper< + String +> value) { + src.anyOf0 = value; +} + +@override +UndefinedWrapperReflection< + String +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + + + ), +); + + UndefinedWrapper< + String +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} +class ScalarAnyOfAnyOf1Part extends AnyOfReflection { + + const ScalarAnyOfAnyOf1Part({ + required ScalarAnyOfReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, ScalarAnyOf> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + num +> _getter(ScalarAnyOf src) { + return src.anyOf1; +} +static void _setter(ScalarAnyOf src, UndefinedWrapper< + num +> value) { + src.anyOf1 = value; +} + +@override +UndefinedWrapperReflection< + num +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + + + ), +); + + UndefinedWrapper< + num +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} +class ScalarAnyOfAnyOf2Part extends AnyOfReflection { + + const ScalarAnyOfAnyOf2Part({ + required ScalarAnyOfReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, ScalarAnyOf> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + bool +> _getter(ScalarAnyOf src) { + return src.anyOf2; +} +static void _setter(ScalarAnyOf src, UndefinedWrapper< + bool +> value) { + src.anyOf2 = value; +} + +@override +UndefinedWrapperReflection< + bool +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + + + ), +); + + UndefinedWrapper< + bool +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isNotEmpty) { + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + return UndefinedWrapper.undefined(); + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/scalene_triangle.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalene_triangle.dart new file mode 100644 index 000000000000..0f1d3fb56ba4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalene_triangle.dart @@ -0,0 +1,81 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'scalene_triangle.reflection.dart'; + + +/// ScaleneTriangleMixin +/// +/// Properties: +mixin ScaleneTriangleMixin on + ShapeInterfaceMixin, TriangleInterfaceMixin, $OpenApiObjectMixin { + +} + +/// ScaleneTriangle +/// +/// Properties: +/// * [shapeType] +/// * [triangleType] +class ScaleneTriangle with +$OpenApiObjectMixin, +ShapeInterfaceMixin,TriangleInterfaceMixin, +ScaleneTriangleMixin { + @override + + String + shapeType; + @override + + String + triangleType; + + AdditionalProperties additionalProperties; + + + + ScaleneTriangle.$all({ + required this.shapeType, + required this.triangleType, + required this.additionalProperties, + + }); + + ScaleneTriangle({ + required this.shapeType , +required this.triangleType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ScaleneTriangleReflection.instance; + ScaleneTriangleReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory ScaleneTriangle.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ScaleneTriangle clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/scalene_triangle.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalene_triangle.reflection.dart new file mode 100644 index 000000000000..ab22891d4251 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/scalene_triangle.reflection.dart @@ -0,0 +1,210 @@ +// Model reflection + +part of 'scalene_triangle.dart'; + + +//class reflection + +class ScaleneTriangleReflection extends ModelReflection { + static ScaleneTriangleReflection instanceGetter() => instance; + static const instance = ScaleneTriangleReflection._( + modelName: r'ScaleneTriangle', + className: r'ScaleneTriangle', + xml: XmlReflection( +), + shapeTypePart: PropertyReflection( + dartName: r'shapeType', + nullable: false, + required: true, + oasName: r'shapeType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_shapeTypeGetter), + setter: FunctionWrapper2(_shapeTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + triangleTypePart: PropertyReflection( + dartName: r'triangleType', + nullable: false, + required: true, + oasName: r'triangleType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_triangleTypeGetter), + setter: FunctionWrapper2(_triangleTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + allOfShapeInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: ShapeInterfaceReflection.instance, + ), +allOfTriangleInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: TriangleInterfaceReflection.instance, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ScaleneTriangleReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.shapeTypePart, + required this.triangleTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfShapeInterfacePart, +required this.allOfTriangleInterfacePart, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection shapeTypePart; + static + String + _shapeTypeGetter(ScaleneTriangle parent) { + return parent.shapeType; + } + static void _shapeTypeSetter(ScaleneTriangle parent, + String + value) { + parent.shapeType = value; + } + + final PropertyReflection triangleTypePart; + static + String + _triangleTypeGetter(ScaleneTriangle parent) { + return parent.triangleType; + } + static void _triangleTypeSetter(ScaleneTriangle parent, + String + value) { + parent.triangleType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + shapeTypePart, +triangleTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ScaleneTriangle instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ScaleneTriangle instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + final AllOfReflection allOfShapeInterfacePart; +final AllOfReflection allOfTriangleInterfacePart; + + + + @override + List> get allOfs => [ + allOfShapeInterfacePart,allOfTriangleInterfacePart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ScaleneTriangle empty() { + return ScaleneTriangle( + shapeType: shapeTypePart.reflection.emptyFunction(), + triangleType: triangleTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is ScaleneTriangleReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/shape.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape.dart new file mode 100644 index 000000000000..feeef603aca1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape.dart @@ -0,0 +1,88 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'shape.reflection.dart'; + + +/// ShapeMixin +mixin ShapeMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + Triangle +> get oneOf0; + UndefinedWrapper< + Quadrilateral +> get oneOf1; +} + +/// Shape +class Shape with +$OpenApiObjectMixin, + +ShapeMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + Triangle +> oneOf0; + + @override + UndefinedWrapper< + Quadrilateral +> oneOf1; + + + Shape.$all({ + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + Shape({ + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ShapeReflection.instance; + ShapeReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory Shape.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Shape clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/shape.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape.reflection.dart new file mode 100644 index 000000000000..6902cd2837fb --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape.reflection.dart @@ -0,0 +1,271 @@ +// Model reflection + +part of 'shape.dart'; + + +//class reflection + +class ShapeReflection extends ModelReflection { + static ShapeReflection instanceGetter() => instance; + static const instance = ShapeReflection._( + modelName: r'Shape', + className: r'Shape', + xml: XmlReflection( +), + discriminatorKey: r'shapeType', + discriminatorImplicitMappings: const { + r'Quadrilateral': QuadrilateralReflection.instance, + r'Triangle': TriangleReflection.instance, + }, + discriminatorMappings: const { + r'Quadrilateral': QuadrilateralReflection.instance, + r'Triangle': TriangleReflection.instance, + }, + + + oneOf0Part: ShapeOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: ShapeOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ShapeReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Shape instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Shape instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final ShapeOneOf0Part oneOf0Part; + + final ShapeOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Shape empty() { + return Shape( + ); + } + + @override + bool operator ==(Object other) { + return other is ShapeReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class ShapeOneOf0Part extends OneOfReflection { + + const ShapeOneOf0Part({ + required ShapeReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Shape> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Triangle +> _getter(Shape src) { + return src.oneOf0; +} +static void _setter(Shape src, UndefinedWrapper< + Triangle +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + Triangle +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Triangle.$reflection + + + ), +); + + UndefinedWrapper< + Triangle +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class ShapeOneOf1Part extends OneOfReflection { + + const ShapeOneOf1Part({ + required ShapeReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Shape> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Quadrilateral +> _getter(Shape src) { + return src.oneOf1; +} +static void _setter(Shape src, UndefinedWrapper< + Quadrilateral +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + Quadrilateral +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Quadrilateral.$reflection + + + ), +); + + UndefinedWrapper< + Quadrilateral +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_interface.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_interface.dart new file mode 100644 index 000000000000..fafc13b107d4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_interface.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'shape_interface.reflection.dart'; + + +/// ShapeInterfaceMixin +/// +/// Properties: +/// * [shapeType] +mixin ShapeInterfaceMixin on + $OpenApiObjectMixin { + + String + get shapeType; + +} + +/// ShapeInterface +/// +/// Properties: +/// * [shapeType] +class ShapeInterface with +$OpenApiObjectMixin, + +ShapeInterfaceMixin { + @override + + String + shapeType; + + AdditionalProperties additionalProperties; + + + + ShapeInterface.$all({ + required this.shapeType, + required this.additionalProperties, + + }); + + ShapeInterface({ + required this.shapeType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ShapeInterfaceReflection.instance; + ShapeInterfaceReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory ShapeInterface.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ShapeInterface clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_interface.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_interface.reflection.dart new file mode 100644 index 000000000000..dcb62cc5f79c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_interface.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'shape_interface.dart'; + + +//class reflection + +class ShapeInterfaceReflection extends ModelReflection { + static ShapeInterfaceReflection instanceGetter() => instance; + static const instance = ShapeInterfaceReflection._( + modelName: r'ShapeInterface', + className: r'ShapeInterface', + xml: XmlReflection( +), + shapeTypePart: PropertyReflection( + dartName: r'shapeType', + nullable: false, + required: true, + oasName: r'shapeType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_shapeTypeGetter), + setter: FunctionWrapper2(_shapeTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ShapeInterfaceReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.shapeTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection shapeTypePart; + static + String + _shapeTypeGetter(ShapeInterface parent) { + return parent.shapeType; + } + static void _shapeTypeSetter(ShapeInterface parent, + String + value) { + parent.shapeType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + shapeTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ShapeInterface instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ShapeInterface instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ShapeInterface empty() { + return ShapeInterface( + shapeType: shapeTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is ShapeInterfaceReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_or_null.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_or_null.dart new file mode 100644 index 000000000000..193dd803a46b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_or_null.dart @@ -0,0 +1,88 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'shape_or_null.reflection.dart'; + + +/// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. +mixin ShapeOrNullMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + Triangle +> get oneOf0; + UndefinedWrapper< + Quadrilateral +> get oneOf1; +} + +/// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. +class ShapeOrNull with +$OpenApiObjectMixin, + +ShapeOrNullMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + Triangle +> oneOf0; + + @override + UndefinedWrapper< + Quadrilateral +> oneOf1; + + + ShapeOrNull.$all({ + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + ShapeOrNull({ + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ShapeOrNullReflection.instance; + ShapeOrNullReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory ShapeOrNull.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + ShapeOrNull clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_or_null.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_or_null.reflection.dart new file mode 100644 index 000000000000..d6e9578a4fb8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/shape_or_null.reflection.dart @@ -0,0 +1,271 @@ +// Model reflection + +part of 'shape_or_null.dart'; + + +//class reflection + +class ShapeOrNullReflection extends ModelReflection { + static ShapeOrNullReflection instanceGetter() => instance; + static const instance = ShapeOrNullReflection._( + modelName: r'ShapeOrNull', + className: r'ShapeOrNull', + xml: XmlReflection( +), + discriminatorKey: r'shapeType', + discriminatorImplicitMappings: const { + r'Quadrilateral': QuadrilateralReflection.instance, + r'Triangle': TriangleReflection.instance, + }, + discriminatorMappings: const { + r'Quadrilateral': QuadrilateralReflection.instance, + r'Triangle': TriangleReflection.instance, + }, + + + oneOf0Part: ShapeOrNullOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: ShapeOrNullOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ShapeOrNullReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(ShapeOrNull instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(ShapeOrNull instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final ShapeOrNullOneOf0Part oneOf0Part; + + final ShapeOrNullOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + ShapeOrNull empty() { + return ShapeOrNull( + ); + } + + @override + bool operator ==(Object other) { + return other is ShapeOrNullReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class ShapeOrNullOneOf0Part extends OneOfReflection { + + const ShapeOrNullOneOf0Part({ + required ShapeOrNullReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, ShapeOrNull> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Triangle +> _getter(ShapeOrNull src) { + return src.oneOf0; +} +static void _setter(ShapeOrNull src, UndefinedWrapper< + Triangle +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + Triangle +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Triangle.$reflection + + + ), +); + + UndefinedWrapper< + Triangle +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class ShapeOrNullOneOf1Part extends OneOfReflection { + + const ShapeOrNullOneOf1Part({ + required ShapeOrNullReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, ShapeOrNull> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Quadrilateral +> _getter(ShapeOrNull src) { + return src.oneOf1; +} +static void _setter(ShapeOrNull src, UndefinedWrapper< + Quadrilateral +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + Quadrilateral +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Quadrilateral.$reflection + + + ), +); + + UndefinedWrapper< + Quadrilateral +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/simple_quadrilateral.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/simple_quadrilateral.dart new file mode 100644 index 000000000000..bc55c79a7772 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/simple_quadrilateral.dart @@ -0,0 +1,81 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'simple_quadrilateral.reflection.dart'; + + +/// SimpleQuadrilateralMixin +/// +/// Properties: +mixin SimpleQuadrilateralMixin on + QuadrilateralInterfaceMixin, ShapeInterfaceMixin, $OpenApiObjectMixin { + +} + +/// SimpleQuadrilateral +/// +/// Properties: +/// * [quadrilateralType] +/// * [shapeType] +class SimpleQuadrilateral with +$OpenApiObjectMixin, +QuadrilateralInterfaceMixin,ShapeInterfaceMixin, +SimpleQuadrilateralMixin { + @override + + String + quadrilateralType; + @override + + String + shapeType; + + AdditionalProperties additionalProperties; + + + + SimpleQuadrilateral.$all({ + required this.quadrilateralType, + required this.shapeType, + required this.additionalProperties, + + }); + + SimpleQuadrilateral({ + required this.quadrilateralType , +required this.shapeType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = SimpleQuadrilateralReflection.instance; + SimpleQuadrilateralReflection get $classReflection => $reflection; + + @override + bool validate() { + + return super.validate(); + } + + factory SimpleQuadrilateral.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + SimpleQuadrilateral clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/simple_quadrilateral.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/simple_quadrilateral.reflection.dart new file mode 100644 index 000000000000..ac9e8ade70c9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/simple_quadrilateral.reflection.dart @@ -0,0 +1,210 @@ +// Model reflection + +part of 'simple_quadrilateral.dart'; + + +//class reflection + +class SimpleQuadrilateralReflection extends ModelReflection { + static SimpleQuadrilateralReflection instanceGetter() => instance; + static const instance = SimpleQuadrilateralReflection._( + modelName: r'SimpleQuadrilateral', + className: r'SimpleQuadrilateral', + xml: XmlReflection( +), + quadrilateralTypePart: PropertyReflection( + dartName: r'quadrilateralType', + nullable: false, + required: true, + oasName: r'quadrilateralType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_quadrilateralTypeGetter), + setter: FunctionWrapper2(_quadrilateralTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + shapeTypePart: PropertyReflection( + dartName: r'shapeType', + nullable: false, + required: true, + oasName: r'shapeType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_shapeTypeGetter), + setter: FunctionWrapper2(_shapeTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + allOfQuadrilateralInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: QuadrilateralInterfaceReflection.instance, + ), +allOfShapeInterfacePart: AllOfReflection( + parentReflectionGetter: instanceGetter, + reflection: ShapeInterfaceReflection.instance, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const SimpleQuadrilateralReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.quadrilateralTypePart, + required this.shapeTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + required this.allOfQuadrilateralInterfacePart, +required this.allOfShapeInterfacePart, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection quadrilateralTypePart; + static + String + _quadrilateralTypeGetter(SimpleQuadrilateral parent) { + return parent.quadrilateralType; + } + static void _quadrilateralTypeSetter(SimpleQuadrilateral parent, + String + value) { + parent.quadrilateralType = value; + } + + final PropertyReflection shapeTypePart; + static + String + _shapeTypeGetter(SimpleQuadrilateral parent) { + return parent.shapeType; + } + static void _shapeTypeSetter(SimpleQuadrilateral parent, + String + value) { + parent.shapeType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + quadrilateralTypePart, +shapeTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(SimpleQuadrilateral instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(SimpleQuadrilateral instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + final AllOfReflection allOfQuadrilateralInterfacePart; +final AllOfReflection allOfShapeInterfacePart; + + + + @override + List> get allOfs => [ + allOfQuadrilateralInterfacePart,allOfShapeInterfacePart, + ]; + + @override + List> get oneOfs => [ + + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + SimpleQuadrilateral empty() { + return SimpleQuadrilateral( + quadrilateralType: quadrilateralTypePart.reflection.emptyFunction(), + shapeType: shapeTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is SimpleQuadrilateralReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/special_model_name.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/special_model_name.dart new file mode 100644 index 000000000000..9f2d88baf741 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/special_model_name.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'special_model_name.reflection.dart'; + + +/// SpecialModelNameMixin +/// +/// Properties: +/// * [$specialPropertyName] +/// * [specialModelName] +mixin SpecialModelNameMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get $specialPropertyName; +UndefinedWrapper< + String +> get specialModelName; + +} + +/// SpecialModelName +/// +/// Properties: +/// * [$specialPropertyName] +/// * [specialModelName] +class SpecialModelName with +$OpenApiObjectMixin, + +SpecialModelNameMixin { + @override + UndefinedWrapper< + int +> $specialPropertyName; + @override + UndefinedWrapper< + String +> specialModelName; + + AdditionalProperties additionalProperties; + + + + SpecialModelName.$all({ + required this.$specialPropertyName, + required this.specialModelName, + required this.additionalProperties, + + }); + + SpecialModelName({ + this.$specialPropertyName = const UndefinedWrapper + .undefined() +, + this.specialModelName = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = SpecialModelNameReflection.instance; + SpecialModelNameReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory SpecialModelName.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + SpecialModelName clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/special_model_name.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/special_model_name.reflection.dart new file mode 100644 index 000000000000..5a57ef171a6c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/special_model_name.reflection.dart @@ -0,0 +1,189 @@ +// Model reflection + +part of 'special_model_name.dart'; + + +//class reflection + +class SpecialModelNameReflection extends ModelReflection { + static SpecialModelNameReflection instanceGetter() => instance; + static const instance = SpecialModelNameReflection._( + modelName: r'_special_model.name_', + className: r'SpecialModelName', + xml: XmlReflection( + xmlName: r'$special[model.name]', +), + $specialPropertyNamePart: PropertyReflection>( + dartName: r'$specialPropertyName', + nullable: false, + required: false, + oasName: r'$special[property.name]', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_$specialPropertyNameGetter), + setter: FunctionWrapper2(_$specialPropertyNameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + specialModelNamePart: PropertyReflection>( + dartName: r'specialModelName', + nullable: false, + required: false, + oasName: r'_special_model.name_', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_specialModelNameGetter), + setter: FunctionWrapper2(_specialModelNameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const SpecialModelNameReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.$specialPropertyNamePart, + required this.specialModelNamePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> $specialPropertyNamePart; + static UndefinedWrapper< + int +> _$specialPropertyNameGetter(SpecialModelName parent) { + return parent.$specialPropertyName; + } + static void _$specialPropertyNameSetter(SpecialModelName parent, UndefinedWrapper< + int +> value) { + parent.$specialPropertyName = value; + } + + final PropertyReflection> specialModelNamePart; + static UndefinedWrapper< + String +> _specialModelNameGetter(SpecialModelName parent) { + return parent.specialModelName; + } + static void _specialModelNameSetter(SpecialModelName parent, UndefinedWrapper< + String +> value) { + parent.specialModelName = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + $specialPropertyNamePart, +specialModelNamePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(SpecialModelName instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(SpecialModelName instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + SpecialModelName empty() { + return SpecialModelName( + ); + } + + @override + bool operator ==(Object other) { + return other is SpecialModelNameReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/tag.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/tag.dart new file mode 100644 index 000000000000..b8ca923617e0 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/tag.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'tag.reflection.dart'; + + +/// TagMixin +/// +/// Properties: +/// * [id] +/// * [name] +mixin TagMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; +UndefinedWrapper< + String +> get name; + +} + +/// Tag +/// +/// Properties: +/// * [id] +/// * [name] +class Tag with +$OpenApiObjectMixin, + +TagMixin { + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + String +> name; + + AdditionalProperties additionalProperties; + + + + Tag.$all({ + required this.id, + required this.name, + required this.additionalProperties, + + }); + + Tag({ + this.id = const UndefinedWrapper + .undefined() +, + this.name = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = TagReflection.instance; + TagReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Tag.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Tag clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/tag.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/tag.reflection.dart new file mode 100644 index 000000000000..11fe5798da25 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/tag.reflection.dart @@ -0,0 +1,189 @@ +// Model reflection + +part of 'tag.dart'; + + +//class reflection + +class TagReflection extends ModelReflection { + static TagReflection instanceGetter() => instance; + static const instance = TagReflection._( + modelName: r'Tag', + className: r'Tag', + xml: XmlReflection( + xmlName: r'Tag', +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + namePart: PropertyReflection>( + dartName: r'name', + nullable: false, + required: false, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const TagReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.namePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(Tag parent) { + return parent.id; + } + static void _idSetter(Tag parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> namePart; + static UndefinedWrapper< + String +> _nameGetter(Tag parent) { + return parent.name; + } + static void _nameSetter(Tag parent, UndefinedWrapper< + String +> value) { + parent.name = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +namePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Tag instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Tag instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Tag empty() { + return Tag( + ); + } + + @override + bool operator ==(Object other) { + return other is TagReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/test_endpoint_parameters_request.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_endpoint_parameters_request.dart new file mode 100644 index 000000000000..7430ed34cdd7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_endpoint_parameters_request.dart @@ -0,0 +1,282 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'test_endpoint_parameters_request.reflection.dart'; + + +/// TestEndpointParametersRequestMixin +/// +/// Properties: +/// * [integer] - None +/// * [int32] - None +/// * [int64] - None +/// * [number] - None +/// * [float] - None +/// * [$double] - None +/// * [string] - None +/// * [patternWithoutDelimiter] - None +/// * [byte] - None +/// * [binary] - None +/// * [date] - None +/// * [dateTime] - None +/// * [password] - None +/// * [callback] - None +mixin TestEndpointParametersRequestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get integer; +UndefinedWrapper< + int +> get int32; +UndefinedWrapper< + int +> get int64; + + num + get number; +UndefinedWrapper< + double +> get float; + + double + get $double; +UndefinedWrapper< + String +> get string; + + String + get patternWithoutDelimiter; + + Uint8List + get byte; +UndefinedWrapper< + XFile +> get binary; +UndefinedWrapper< + DateTime +> get date; +UndefinedWrapper< + DateTime +> get dateTime; +UndefinedWrapper< + String +> get password; +UndefinedWrapper< + String +> get callback; + +} + +/// TestEndpointParametersRequest +/// +/// Properties: +/// * [integer] - None +/// * [int32] - None +/// * [int64] - None +/// * [number] - None +/// * [float] - None +/// * [$double] - None +/// * [string] - None +/// * [patternWithoutDelimiter] - None +/// * [byte] - None +/// * [binary] - None +/// * [date] - None +/// * [dateTime] - None +/// * [password] - None +/// * [callback] - None +class TestEndpointParametersRequest with +$OpenApiObjectMixin, + +TestEndpointParametersRequestMixin { + @override + UndefinedWrapper< + int +> integer; + @override + UndefinedWrapper< + int +> int32; + @override + UndefinedWrapper< + int +> int64; + @override + + num + number; + @override + UndefinedWrapper< + double +> float; + @override + + double + $double; + @override + UndefinedWrapper< + String +> string; + @override + + String + patternWithoutDelimiter; + @override + + Uint8List + byte; + @override + UndefinedWrapper< + XFile +> binary; + @override + UndefinedWrapper< + DateTime +> date; + @override + UndefinedWrapper< + DateTime +> dateTime; + @override + UndefinedWrapper< + String +> password; + @override + UndefinedWrapper< + String +> callback; + + AdditionalProperties additionalProperties; + + + + TestEndpointParametersRequest.$all({ + required this.integer, + required this.int32, + required this.int64, + required this.number, + required this.float, + required this.$double, + required this.string, + required this.patternWithoutDelimiter, + required this.byte, + required this.binary, + required this.date, + required this.dateTime, + required this.password, + required this.callback, + required this.additionalProperties, + + }); + + TestEndpointParametersRequest({ + this.integer = const UndefinedWrapper + .undefined() +, + this.int32 = const UndefinedWrapper + .undefined() +, + this.int64 = const UndefinedWrapper + .undefined() +, +required this.number , + this.float = const UndefinedWrapper + .undefined() +, +required this.$double , + this.string = const UndefinedWrapper + .undefined() +, +required this.patternWithoutDelimiter , +required this.byte , + this.binary = const UndefinedWrapper + .undefined() +, + this.date = const UndefinedWrapper + .undefined() +, + this.dateTime = const UndefinedWrapper + .undefined() +, + this.password = const UndefinedWrapper + .undefined() +, + this.callback = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = TestEndpointParametersRequestReflection.instance; + TestEndpointParametersRequestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory TestEndpointParametersRequest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + TestEndpointParametersRequest clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/test_endpoint_parameters_request.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_endpoint_parameters_request.reflection.dart new file mode 100644 index 000000000000..1402db2ed5c6 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_endpoint_parameters_request.reflection.dart @@ -0,0 +1,732 @@ +// Model reflection + +part of 'test_endpoint_parameters_request.dart'; + + +//class reflection + +class TestEndpointParametersRequestReflection extends ModelReflection { + static TestEndpointParametersRequestReflection instanceGetter() => instance; + static const instance = TestEndpointParametersRequestReflection._( + modelName: r'testEndpointParameters_request', + className: r'TestEndpointParametersRequest', + xml: XmlReflection( +), + integerPart: PropertyReflection>( + dartName: r'integer', + nullable: false, + required: false, + oasName: r'integer', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_integerGetter), + setter: FunctionWrapper2(_integerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + int32Part: PropertyReflection>( + dartName: r'int32', + nullable: false, + required: false, + oasName: r'int32', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_int32Getter), + setter: FunctionWrapper2(_int32Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + int64Part: PropertyReflection>( + dartName: r'int64', + nullable: false, + required: false, + oasName: r'int64', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_int64Getter), + setter: FunctionWrapper2(_int64Setter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + numberPart: PropertyReflection( + dartName: r'number', + nullable: false, + required: true, + oasName: r'number', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_numberGetter), + setter: FunctionWrapper2(_numberSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fornum + +, +) +, + ), + floatPart: PropertyReflection>( + dartName: r'float', + nullable: false, + required: false, + oasName: r'float', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_floatGetter), + setter: FunctionWrapper2(_floatSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fordouble + +, +) +), + ), + $doublePart: PropertyReflection( + dartName: r'$double', + nullable: false, + required: true, + oasName: r'double', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_$doubleGetter), + setter: FunctionWrapper2(_$doubleSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fordouble + +, +) +, + ), + stringPart: PropertyReflection>( + dartName: r'string', + nullable: false, + required: false, + oasName: r'string', + oasType: r'string', + pattern: r'/[a-z]/i', + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_stringGetter), + setter: FunctionWrapper2(_stringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + patternWithoutDelimiterPart: PropertyReflection( + dartName: r'patternWithoutDelimiter', + nullable: false, + required: true, + oasName: r'pattern_without_delimiter', + oasType: r'string', + pattern: r'/^[A-Z].*/', + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_patternWithoutDelimiterGetter), + setter: FunctionWrapper2(_patternWithoutDelimiterSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + bytePart: PropertyReflection( + dartName: r'byte', + nullable: false, + required: true, + oasName: r'byte', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_byteGetter), + setter: FunctionWrapper2(_byteSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forUint8List + +, +) +, + ), + binaryPart: PropertyReflection>( + dartName: r'binary', + nullable: false, + required: false, + oasName: r'binary', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_binaryGetter), + setter: FunctionWrapper2(_binarySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forXFile + +, +) +), + ), + datePart: PropertyReflection>( + dartName: r'date', + nullable: false, + required: false, + oasName: r'date', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_dateGetter), + setter: FunctionWrapper2(_dateSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +), + ), + dateTimePart: PropertyReflection>( + dartName: r'dateTime', + nullable: false, + required: false, + oasName: r'dateTime', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_dateTimeGetter), + setter: FunctionWrapper2(_dateTimeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forDateTime + +, +) +), + ), + passwordPart: PropertyReflection>( + dartName: r'password', + nullable: false, + required: false, + oasName: r'password', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_passwordGetter), + setter: FunctionWrapper2(_passwordSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + callbackPart: PropertyReflection>( + dartName: r'callback', + nullable: false, + required: false, + oasName: r'callback', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_callbackGetter), + setter: FunctionWrapper2(_callbackSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const TestEndpointParametersRequestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.integerPart, + required this.int32Part, + required this.int64Part, + required this.numberPart, + required this.floatPart, + required this.$doublePart, + required this.stringPart, + required this.patternWithoutDelimiterPart, + required this.bytePart, + required this.binaryPart, + required this.datePart, + required this.dateTimePart, + required this.passwordPart, + required this.callbackPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> integerPart; + static UndefinedWrapper< + int +> _integerGetter(TestEndpointParametersRequest parent) { + return parent.integer; + } + static void _integerSetter(TestEndpointParametersRequest parent, UndefinedWrapper< + int +> value) { + parent.integer = value; + } + + final PropertyReflection> int32Part; + static UndefinedWrapper< + int +> _int32Getter(TestEndpointParametersRequest parent) { + return parent.int32; + } + static void _int32Setter(TestEndpointParametersRequest parent, UndefinedWrapper< + int +> value) { + parent.int32 = value; + } + + final PropertyReflection> int64Part; + static UndefinedWrapper< + int +> _int64Getter(TestEndpointParametersRequest parent) { + return parent.int64; + } + static void _int64Setter(TestEndpointParametersRequest parent, UndefinedWrapper< + int +> value) { + parent.int64 = value; + } + + final PropertyReflection numberPart; + static + num + _numberGetter(TestEndpointParametersRequest parent) { + return parent.number; + } + static void _numberSetter(TestEndpointParametersRequest parent, + num + value) { + parent.number = value; + } + + final PropertyReflection> floatPart; + static UndefinedWrapper< + double +> _floatGetter(TestEndpointParametersRequest parent) { + return parent.float; + } + static void _floatSetter(TestEndpointParametersRequest parent, UndefinedWrapper< + double +> value) { + parent.float = value; + } + + final PropertyReflection $doublePart; + static + double + _$doubleGetter(TestEndpointParametersRequest parent) { + return parent.$double; + } + static void _$doubleSetter(TestEndpointParametersRequest parent, + double + value) { + parent.$double = value; + } + + final PropertyReflection> stringPart; + static UndefinedWrapper< + String +> _stringGetter(TestEndpointParametersRequest parent) { + return parent.string; + } + static void _stringSetter(TestEndpointParametersRequest parent, UndefinedWrapper< + String +> value) { + parent.string = value; + } + + final PropertyReflection patternWithoutDelimiterPart; + static + String + _patternWithoutDelimiterGetter(TestEndpointParametersRequest parent) { + return parent.patternWithoutDelimiter; + } + static void _patternWithoutDelimiterSetter(TestEndpointParametersRequest parent, + String + value) { + parent.patternWithoutDelimiter = value; + } + + final PropertyReflection bytePart; + static + Uint8List + _byteGetter(TestEndpointParametersRequest parent) { + return parent.byte; + } + static void _byteSetter(TestEndpointParametersRequest parent, + Uint8List + value) { + parent.byte = value; + } + + final PropertyReflection> binaryPart; + static UndefinedWrapper< + XFile +> _binaryGetter(TestEndpointParametersRequest parent) { + return parent.binary; + } + static void _binarySetter(TestEndpointParametersRequest parent, UndefinedWrapper< + XFile +> value) { + parent.binary = value; + } + + final PropertyReflection> datePart; + static UndefinedWrapper< + DateTime +> _dateGetter(TestEndpointParametersRequest parent) { + return parent.date; + } + static void _dateSetter(TestEndpointParametersRequest parent, UndefinedWrapper< + DateTime +> value) { + parent.date = value; + } + + final PropertyReflection> dateTimePart; + static UndefinedWrapper< + DateTime +> _dateTimeGetter(TestEndpointParametersRequest parent) { + return parent.dateTime; + } + static void _dateTimeSetter(TestEndpointParametersRequest parent, UndefinedWrapper< + DateTime +> value) { + parent.dateTime = value; + } + + final PropertyReflection> passwordPart; + static UndefinedWrapper< + String +> _passwordGetter(TestEndpointParametersRequest parent) { + return parent.password; + } + static void _passwordSetter(TestEndpointParametersRequest parent, UndefinedWrapper< + String +> value) { + parent.password = value; + } + + final PropertyReflection> callbackPart; + static UndefinedWrapper< + String +> _callbackGetter(TestEndpointParametersRequest parent) { + return parent.callback; + } + static void _callbackSetter(TestEndpointParametersRequest parent, UndefinedWrapper< + String +> value) { + parent.callback = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + integerPart, +int32Part, +int64Part, +numberPart, +floatPart, +$doublePart, +stringPart, +patternWithoutDelimiterPart, +bytePart, +binaryPart, +datePart, +dateTimePart, +passwordPart, +callbackPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(TestEndpointParametersRequest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(TestEndpointParametersRequest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + TestEndpointParametersRequest empty() { + return TestEndpointParametersRequest( + number: numberPart.reflection.emptyFunction(), + $double: $doublePart.reflection.emptyFunction(), + patternWithoutDelimiter: patternWithoutDelimiterPart.reflection.emptyFunction(), + byte: bytePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is TestEndpointParametersRequestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/test_enum_parameters_request.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_enum_parameters_request.dart new file mode 100644 index 000000000000..4516906c2eed --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_enum_parameters_request.dart @@ -0,0 +1,207 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'test_enum_parameters_request.reflection.dart'; + + +/// TestEnumParametersRequestMixin +/// +/// Properties: +/// * [enumFormStringArray] - Form parameter enum test (string array) +/// * [enumFormString] - Form parameter enum test (string) +mixin TestEnumParametersRequestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + List< + + TestEnumParametersRequestEnumFormStringArrayEnum +> +> get enumFormStringArray; +UndefinedWrapper< + TestEnumParametersRequestEnumFormStringEnum +> get enumFormString; + +} + +/// TestEnumParametersRequest +/// +/// Properties: +/// * [enumFormStringArray] - Form parameter enum test (string array) +/// * [enumFormString] - Form parameter enum test (string) +class TestEnumParametersRequest with +$OpenApiObjectMixin, + +TestEnumParametersRequestMixin { + @override + UndefinedWrapper< + List< + + TestEnumParametersRequestEnumFormStringArrayEnum +> +> enumFormStringArray; + @override + UndefinedWrapper< + TestEnumParametersRequestEnumFormStringEnum +> enumFormString; + + AdditionalProperties additionalProperties; + + + + TestEnumParametersRequest.$all({ + required this.enumFormStringArray, + required this.enumFormString, + required this.additionalProperties, + + }); + + TestEnumParametersRequest({ + this.enumFormStringArray = const UndefinedWrapper + .undefined() +, + this.enumFormString = const UndefinedWrapper + ( + TestEnumParametersRequestEnumFormStringEnum.$unsafe('-efg') + + ) + +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = TestEnumParametersRequestReflection.instance; + TestEnumParametersRequestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory TestEnumParametersRequest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + TestEnumParametersRequest clone() { + return $reflection.clone(this); + } +} + + +extension type const TestEnumParametersRequestEnumFormStringArrayEnum._(String value) implements String { + const TestEnumParametersRequestEnumFormStringArrayEnum.greaterThan() : this._(r'>'); + const TestEnumParametersRequestEnumFormStringArrayEnum.value() : this._(r'$'); + + /// Creates a [TestEnumParametersRequestEnumFormStringArrayEnum] enum from a value and safely checking if it exists. + factory TestEnumParametersRequestEnumFormStringArrayEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'greaterThan', oasValue: r'>', value: TestEnumParametersRequestEnumFormStringArrayEnum.greaterThan()), + + EnumMemberReflection(dartName: r'value', oasValue: r'$', value: TestEnumParametersRequestEnumFormStringArrayEnum.value()), + + ], + ); + + factory TestEnumParametersRequestEnumFormStringArrayEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [TestEnumParametersRequestEnumFormStringArrayEnum] enum from a value without checking if it exists. + const TestEnumParametersRequestEnumFormStringArrayEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + TestEnumParametersRequestEnumFormStringArrayEnum.greaterThan(), + TestEnumParametersRequestEnumFormStringArrayEnum.value(), + + ]; +} + + + + +extension type const TestEnumParametersRequestEnumFormStringEnum._(String value) implements String { + /// Form parameter enum test (string) + const TestEnumParametersRequestEnumFormStringEnum.abc() : this._(r'_abc'); + /// Form parameter enum test (string) + const TestEnumParametersRequestEnumFormStringEnum.efg() : this._(r'-efg'); + /// Form parameter enum test (string) + const TestEnumParametersRequestEnumFormStringEnum.xyz() : this._(r'(xyz)'); + + /// Creates a [TestEnumParametersRequestEnumFormStringEnum] enum from a value and safely checking if it exists. + factory TestEnumParametersRequestEnumFormStringEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'abc', oasValue: r'_abc', value: TestEnumParametersRequestEnumFormStringEnum.abc()), + + EnumMemberReflection(dartName: r'efg', oasValue: r'-efg', value: TestEnumParametersRequestEnumFormStringEnum.efg()), + + EnumMemberReflection(dartName: r'xyz', oasValue: r'(xyz)', value: TestEnumParametersRequestEnumFormStringEnum.xyz()), + + ], + ); + + factory TestEnumParametersRequestEnumFormStringEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [TestEnumParametersRequestEnumFormStringEnum] enum from a value without checking if it exists. + const TestEnumParametersRequestEnumFormStringEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + TestEnumParametersRequestEnumFormStringEnum.abc(), + TestEnumParametersRequestEnumFormStringEnum.efg(), + TestEnumParametersRequestEnumFormStringEnum.xyz(), + + ]; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/test_enum_parameters_request.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_enum_parameters_request.reflection.dart new file mode 100644 index 000000000000..3d73c9a55c96 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_enum_parameters_request.reflection.dart @@ -0,0 +1,201 @@ +// Model reflection + +part of 'test_enum_parameters_request.dart'; + + +//class reflection + +class TestEnumParametersRequestReflection extends ModelReflection { + static TestEnumParametersRequestReflection instanceGetter() => instance; + static const instance = TestEnumParametersRequestReflection._( + modelName: r'testEnumParameters_request', + className: r'TestEnumParametersRequest', + xml: XmlReflection( +), + enumFormStringArrayPart: PropertyReflection +>>( + dartName: r'enumFormStringArray', + nullable: false, + required: false, + oasName: r'enum_form_string_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_enumFormStringArrayGetter), + setter: FunctionWrapper2(_enumFormStringArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + TestEnumParametersRequestEnumFormStringArrayEnum.$reflection + + +, +) +) +, +) +), + ), + enumFormStringPart: PropertyReflection>( + dartName: r'enumFormString', + nullable: false, + required: false, + oasName: r'enum_form_string', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_enumFormStringGetter), + setter: FunctionWrapper2(_enumFormStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + TestEnumParametersRequestEnumFormStringEnum.$reflection + + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const TestEnumParametersRequestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.enumFormStringArrayPart, + required this.enumFormStringPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection +>> enumFormStringArrayPart; + static UndefinedWrapper< + List< + + TestEnumParametersRequestEnumFormStringArrayEnum +> +> _enumFormStringArrayGetter(TestEnumParametersRequest parent) { + return parent.enumFormStringArray; + } + static void _enumFormStringArraySetter(TestEnumParametersRequest parent, UndefinedWrapper< + List< + + TestEnumParametersRequestEnumFormStringArrayEnum +> +> value) { + parent.enumFormStringArray = value; + } + + final PropertyReflection> enumFormStringPart; + static UndefinedWrapper< + TestEnumParametersRequestEnumFormStringEnum +> _enumFormStringGetter(TestEnumParametersRequest parent) { + return parent.enumFormString; + } + static void _enumFormStringSetter(TestEnumParametersRequest parent, UndefinedWrapper< + TestEnumParametersRequestEnumFormStringEnum +> value) { + parent.enumFormString = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + enumFormStringArrayPart, +enumFormStringPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(TestEnumParametersRequest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(TestEnumParametersRequest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + TestEnumParametersRequest empty() { + return TestEnumParametersRequest( + ); + } + + @override + bool operator ==(Object other) { + return other is TestEnumParametersRequestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/test_inline_freeform_additional_properties_request.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_inline_freeform_additional_properties_request.dart new file mode 100644 index 000000000000..d6653d7ef58f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_inline_freeform_additional_properties_request.dart @@ -0,0 +1,82 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'test_inline_freeform_additional_properties_request.reflection.dart'; + + +/// TestInlineFreeformAdditionalPropertiesRequestMixin +/// +/// Properties: +/// * [someProperty] +mixin TestInlineFreeformAdditionalPropertiesRequestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get someProperty; + +} + +/// TestInlineFreeformAdditionalPropertiesRequest +/// +/// Properties: +/// * [someProperty] +class TestInlineFreeformAdditionalPropertiesRequest with +$OpenApiObjectMixin, + +TestInlineFreeformAdditionalPropertiesRequestMixin { + @override + UndefinedWrapper< + String +> someProperty; + + AdditionalProperties additionalProperties; + + + + TestInlineFreeformAdditionalPropertiesRequest.$all({ + required this.someProperty, + required this.additionalProperties, + + }); + + TestInlineFreeformAdditionalPropertiesRequest({ + this.someProperty = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = TestInlineFreeformAdditionalPropertiesRequestReflection.instance; + TestInlineFreeformAdditionalPropertiesRequestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory TestInlineFreeformAdditionalPropertiesRequest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + TestInlineFreeformAdditionalPropertiesRequest clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/test_inline_freeform_additional_properties_request.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_inline_freeform_additional_properties_request.reflection.dart new file mode 100644 index 000000000000..e23c7f24f353 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_inline_freeform_additional_properties_request.reflection.dart @@ -0,0 +1,143 @@ +// Model reflection + +part of 'test_inline_freeform_additional_properties_request.dart'; + + +//class reflection + +class TestInlineFreeformAdditionalPropertiesRequestReflection extends ModelReflection { + static TestInlineFreeformAdditionalPropertiesRequestReflection instanceGetter() => instance; + static const instance = TestInlineFreeformAdditionalPropertiesRequestReflection._( + modelName: r'testInlineFreeformAdditionalProperties_request', + className: r'TestInlineFreeformAdditionalPropertiesRequest', + xml: XmlReflection( +), + somePropertyPart: PropertyReflection>( + dartName: r'someProperty', + nullable: false, + required: false, + oasName: r'someProperty', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_somePropertyGetter), + setter: FunctionWrapper2(_somePropertySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const TestInlineFreeformAdditionalPropertiesRequestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.somePropertyPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> somePropertyPart; + static UndefinedWrapper< + String +> _somePropertyGetter(TestInlineFreeformAdditionalPropertiesRequest parent) { + return parent.someProperty; + } + static void _somePropertySetter(TestInlineFreeformAdditionalPropertiesRequest parent, UndefinedWrapper< + String +> value) { + parent.someProperty = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + somePropertyPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(TestInlineFreeformAdditionalPropertiesRequest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(TestInlineFreeformAdditionalPropertiesRequest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + TestInlineFreeformAdditionalPropertiesRequest empty() { + return TestInlineFreeformAdditionalPropertiesRequest( + ); + } + + @override + bool operator ==(Object other) { + return other is TestInlineFreeformAdditionalPropertiesRequestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/test_json_form_data_request.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_json_form_data_request.dart new file mode 100644 index 000000000000..d74dcd2bddf6 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_json_form_data_request.dart @@ -0,0 +1,94 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'test_json_form_data_request.reflection.dart'; + + +/// TestJsonFormDataRequestMixin +/// +/// Properties: +/// * [param] - field1 +/// * [param2] - field2 +mixin TestJsonFormDataRequestMixin on + $OpenApiObjectMixin { + + String + get param; + + String + get param2; + +} + +/// TestJsonFormDataRequest +/// +/// Properties: +/// * [param] - field1 +/// * [param2] - field2 +class TestJsonFormDataRequest with +$OpenApiObjectMixin, + +TestJsonFormDataRequestMixin { + @override + + String + param; + @override + + String + param2; + + AdditionalProperties additionalProperties; + + + + TestJsonFormDataRequest.$all({ + required this.param, + required this.param2, + required this.additionalProperties, + + }); + + TestJsonFormDataRequest({ + required this.param , +required this.param2 , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = TestJsonFormDataRequestReflection.instance; + TestJsonFormDataRequestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory TestJsonFormDataRequest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + TestJsonFormDataRequest clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/test_json_form_data_request.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_json_form_data_request.reflection.dart new file mode 100644 index 000000000000..f61e95dbc16d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/test_json_form_data_request.reflection.dart @@ -0,0 +1,190 @@ +// Model reflection + +part of 'test_json_form_data_request.dart'; + + +//class reflection + +class TestJsonFormDataRequestReflection extends ModelReflection { + static TestJsonFormDataRequestReflection instanceGetter() => instance; + static const instance = TestJsonFormDataRequestReflection._( + modelName: r'testJsonFormData_request', + className: r'TestJsonFormDataRequest', + xml: XmlReflection( +), + paramPart: PropertyReflection( + dartName: r'param', + nullable: false, + required: true, + oasName: r'param', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_paramGetter), + setter: FunctionWrapper2(_paramSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + param2Part: PropertyReflection( + dartName: r'param2', + nullable: false, + required: true, + oasName: r'param2', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_param2Getter), + setter: FunctionWrapper2(_param2Setter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const TestJsonFormDataRequestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.paramPart, + required this.param2Part, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection paramPart; + static + String + _paramGetter(TestJsonFormDataRequest parent) { + return parent.param; + } + static void _paramSetter(TestJsonFormDataRequest parent, + String + value) { + parent.param = value; + } + + final PropertyReflection param2Part; + static + String + _param2Getter(TestJsonFormDataRequest parent) { + return parent.param2; + } + static void _param2Setter(TestJsonFormDataRequest parent, + String + value) { + parent.param2 = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + paramPart, +param2Part, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(TestJsonFormDataRequest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(TestJsonFormDataRequest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + TestJsonFormDataRequest empty() { + return TestJsonFormDataRequest( + param: paramPart.reflection.emptyFunction(), + param2: param2Part.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is TestJsonFormDataRequestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle.dart new file mode 100644 index 000000000000..d7f99678fc0d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle.dart @@ -0,0 +1,116 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'triangle.reflection.dart'; + + +/// TriangleMixin +/// +/// Properties: +/// * [triangleType] +mixin TriangleMixin on + $OpenApiObjectMixin { + + String + get triangleType; + + UndefinedWrapper< + EquilateralTriangle +> get oneOf0; + UndefinedWrapper< + IsoscelesTriangle +> get oneOf1; + UndefinedWrapper< + ScaleneTriangle +> get oneOf2; +} + +/// Triangle +/// +/// Properties: +/// * [triangleType] +class Triangle with +$OpenApiObjectMixin, + +TriangleMixin { + @override + + String + triangleType; + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + EquilateralTriangle +> oneOf0; + + @override + UndefinedWrapper< + IsoscelesTriangle +> oneOf1; + + @override + UndefinedWrapper< + ScaleneTriangle +> oneOf2; + + + Triangle.$all({ + required this.triangleType, + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + required this.oneOf2, + }); + + Triangle({ + required this.triangleType , + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + this.oneOf2 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = TriangleReflection.instance; + TriangleReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,oneOf2,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory Triangle.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Triangle clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle.reflection.dart new file mode 100644 index 000000000000..86104e0d098a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle.reflection.dart @@ -0,0 +1,397 @@ +// Model reflection + +part of 'triangle.dart'; + + +//class reflection + +class TriangleReflection extends ModelReflection { + static TriangleReflection instanceGetter() => instance; + static const instance = TriangleReflection._( + modelName: r'Triangle', + className: r'Triangle', + xml: XmlReflection( +), + triangleTypePart: PropertyReflection( + dartName: r'triangleType', + nullable: false, + required: true, + oasName: r'triangleType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: true, + xml: XmlReflection( +), + getter: FunctionWrapper1(_triangleTypeGetter), + setter: FunctionWrapper2(_triangleTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + discriminatorKey: r'triangleType', + discriminatorImplicitMappings: const { + r'EquilateralTriangle': EquilateralTriangleReflection.instance, + r'IsoscelesTriangle': IsoscelesTriangleReflection.instance, + r'ScaleneTriangle': ScaleneTriangleReflection.instance, + }, + discriminatorMappings: const { + r'EquilateralTriangle': EquilateralTriangleReflection.instance, + r'IsoscelesTriangle': IsoscelesTriangleReflection.instance, + r'ScaleneTriangle': ScaleneTriangleReflection.instance, + }, + + + oneOf0Part: TriangleOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: TriangleOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf2Part: TriangleOneOf2Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const TriangleReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.triangleTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.oneOf2Part, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection triangleTypePart; + static + String + _triangleTypeGetter(Triangle parent) { + return parent.triangleType; + } + static void _triangleTypeSetter(Triangle parent, + String + value) { + parent.triangleType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + triangleTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Triangle instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Triangle instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final TriangleOneOf0Part oneOf0Part; + + final TriangleOneOf1Part oneOf1Part; + + final TriangleOneOf2Part oneOf2Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part,oneOf2Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Triangle empty() { + return Triangle( + triangleType: triangleTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is TriangleReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class TriangleOneOf0Part extends OneOfReflection { + + const TriangleOneOf0Part({ + required TriangleReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Triangle> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + EquilateralTriangle +> _getter(Triangle src) { + return src.oneOf0; +} +static void _setter(Triangle src, UndefinedWrapper< + EquilateralTriangle +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + EquilateralTriangle +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + EquilateralTriangle.$reflection + + + ), +); + + UndefinedWrapper< + EquilateralTriangle +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class TriangleOneOf1Part extends OneOfReflection { + + const TriangleOneOf1Part({ + required TriangleReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Triangle> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + IsoscelesTriangle +> _getter(Triangle src) { + return src.oneOf1; +} +static void _setter(Triangle src, UndefinedWrapper< + IsoscelesTriangle +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + IsoscelesTriangle +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + IsoscelesTriangle.$reflection + + + ), +); + + UndefinedWrapper< + IsoscelesTriangle +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class TriangleOneOf2Part extends OneOfReflection { + + const TriangleOneOf2Part({ + required TriangleReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Triangle> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + ScaleneTriangle +> _getter(Triangle src) { + return src.oneOf2; +} +static void _setter(Triangle src, UndefinedWrapper< + ScaleneTriangle +> value) { + src.oneOf2 = value; +} + +@override +UndefinedWrapperReflection< + ScaleneTriangle +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + ScaleneTriangle.$reflection + + + ), +); + + UndefinedWrapper< + ScaleneTriangle +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle_interface.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle_interface.dart new file mode 100644 index 000000000000..9290a176be04 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle_interface.dart @@ -0,0 +1,80 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'triangle_interface.reflection.dart'; + + +/// TriangleInterfaceMixin +/// +/// Properties: +/// * [triangleType] +mixin TriangleInterfaceMixin on + $OpenApiObjectMixin { + + String + get triangleType; + +} + +/// TriangleInterface +/// +/// Properties: +/// * [triangleType] +class TriangleInterface with +$OpenApiObjectMixin, + +TriangleInterfaceMixin { + @override + + String + triangleType; + + AdditionalProperties additionalProperties; + + + + TriangleInterface.$all({ + required this.triangleType, + required this.additionalProperties, + + }); + + TriangleInterface({ + required this.triangleType , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = TriangleInterfaceReflection.instance; + TriangleInterfaceReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory TriangleInterface.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + TriangleInterface clone() { + return $reflection.clone(this); + } +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle_interface.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle_interface.reflection.dart new file mode 100644 index 000000000000..3541941b5261 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/triangle_interface.reflection.dart @@ -0,0 +1,144 @@ +// Model reflection + +part of 'triangle_interface.dart'; + + +//class reflection + +class TriangleInterfaceReflection extends ModelReflection { + static TriangleInterfaceReflection instanceGetter() => instance; + static const instance = TriangleInterfaceReflection._( + modelName: r'TriangleInterface', + className: r'TriangleInterface', + xml: XmlReflection( +), + triangleTypePart: PropertyReflection( + dartName: r'triangleType', + nullable: false, + required: true, + oasName: r'triangleType', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_triangleTypeGetter), + setter: FunctionWrapper2(_triangleTypeSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const TriangleInterfaceReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.triangleTypePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection triangleTypePart; + static + String + _triangleTypeGetter(TriangleInterface parent) { + return parent.triangleType; + } + static void _triangleTypeSetter(TriangleInterface parent, + String + value) { + parent.triangleType = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + triangleTypePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(TriangleInterface instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(TriangleInterface instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + TriangleInterface empty() { + return TriangleInterface( + triangleType: triangleTypePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is TriangleInterfaceReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/update_pet_with_form_request.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/update_pet_with_form_request.dart new file mode 100644 index 000000000000..c682d5371591 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/update_pet_with_form_request.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'update_pet_with_form_request.reflection.dart'; + + +/// UpdatePetWithFormRequestMixin +/// +/// Properties: +/// * [name] - Updated name of the pet +/// * [status] - Updated status of the pet +mixin UpdatePetWithFormRequestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get name; +UndefinedWrapper< + String +> get status; + +} + +/// UpdatePetWithFormRequest +/// +/// Properties: +/// * [name] - Updated name of the pet +/// * [status] - Updated status of the pet +class UpdatePetWithFormRequest with +$OpenApiObjectMixin, + +UpdatePetWithFormRequestMixin { + @override + UndefinedWrapper< + String +> name; + @override + UndefinedWrapper< + String +> status; + + AdditionalProperties additionalProperties; + + + + UpdatePetWithFormRequest.$all({ + required this.name, + required this.status, + required this.additionalProperties, + + }); + + UpdatePetWithFormRequest({ + this.name = const UndefinedWrapper + .undefined() +, + this.status = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = UpdatePetWithFormRequestReflection.instance; + UpdatePetWithFormRequestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory UpdatePetWithFormRequest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + UpdatePetWithFormRequest clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/update_pet_with_form_request.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/update_pet_with_form_request.reflection.dart new file mode 100644 index 000000000000..309a64373487 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/update_pet_with_form_request.reflection.dart @@ -0,0 +1,188 @@ +// Model reflection + +part of 'update_pet_with_form_request.dart'; + + +//class reflection + +class UpdatePetWithFormRequestReflection extends ModelReflection { + static UpdatePetWithFormRequestReflection instanceGetter() => instance; + static const instance = UpdatePetWithFormRequestReflection._( + modelName: r'updatePetWithForm_request', + className: r'UpdatePetWithFormRequest', + xml: XmlReflection( +), + namePart: PropertyReflection>( + dartName: r'name', + nullable: false, + required: false, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + statusPart: PropertyReflection>( + dartName: r'status', + nullable: false, + required: false, + oasName: r'status', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_statusGetter), + setter: FunctionWrapper2(_statusSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const UpdatePetWithFormRequestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.namePart, + required this.statusPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> namePart; + static UndefinedWrapper< + String +> _nameGetter(UpdatePetWithFormRequest parent) { + return parent.name; + } + static void _nameSetter(UpdatePetWithFormRequest parent, UndefinedWrapper< + String +> value) { + parent.name = value; + } + + final PropertyReflection> statusPart; + static UndefinedWrapper< + String +> _statusGetter(UpdatePetWithFormRequest parent) { + return parent.status; + } + static void _statusSetter(UpdatePetWithFormRequest parent, UndefinedWrapper< + String +> value) { + parent.status = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + namePart, +statusPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(UpdatePetWithFormRequest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(UpdatePetWithFormRequest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + UpdatePetWithFormRequest empty() { + return UpdatePetWithFormRequest( + ); + } + + @override + bool operator ==(Object other) { + return other is UpdatePetWithFormRequestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_request.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_request.dart new file mode 100644 index 000000000000..23221faff9ce --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_request.dart @@ -0,0 +1,98 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'upload_file_request.reflection.dart'; + + +/// UploadFileRequestMixin +/// +/// Properties: +/// * [additionalMetadata] - Additional data to pass to server +/// * [file] - file to upload +mixin UploadFileRequestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get additionalMetadata; +UndefinedWrapper< + XFile +> get file; + +} + +/// UploadFileRequest +/// +/// Properties: +/// * [additionalMetadata] - Additional data to pass to server +/// * [file] - file to upload +class UploadFileRequest with +$OpenApiObjectMixin, + +UploadFileRequestMixin { + @override + UndefinedWrapper< + String +> additionalMetadata; + @override + UndefinedWrapper< + XFile +> file; + + AdditionalProperties additionalProperties; + + + + UploadFileRequest.$all({ + required this.additionalMetadata, + required this.file, + required this.additionalProperties, + + }); + + UploadFileRequest({ + this.additionalMetadata = const UndefinedWrapper + .undefined() +, + this.file = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = UploadFileRequestReflection.instance; + UploadFileRequestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory UploadFileRequest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + UploadFileRequest clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_request.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_request.reflection.dart new file mode 100644 index 000000000000..ff2f102bf698 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_request.reflection.dart @@ -0,0 +1,188 @@ +// Model reflection + +part of 'upload_file_request.dart'; + + +//class reflection + +class UploadFileRequestReflection extends ModelReflection { + static UploadFileRequestReflection instanceGetter() => instance; + static const instance = UploadFileRequestReflection._( + modelName: r'uploadFile_request', + className: r'UploadFileRequest', + xml: XmlReflection( +), + additionalMetadataPart: PropertyReflection>( + dartName: r'additionalMetadata', + nullable: false, + required: false, + oasName: r'additionalMetadata', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_additionalMetadataGetter), + setter: FunctionWrapper2(_additionalMetadataSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + filePart: PropertyReflection>( + dartName: r'file', + nullable: false, + required: false, + oasName: r'file', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_fileGetter), + setter: FunctionWrapper2(_fileSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forXFile + +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const UploadFileRequestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.additionalMetadataPart, + required this.filePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> additionalMetadataPart; + static UndefinedWrapper< + String +> _additionalMetadataGetter(UploadFileRequest parent) { + return parent.additionalMetadata; + } + static void _additionalMetadataSetter(UploadFileRequest parent, UndefinedWrapper< + String +> value) { + parent.additionalMetadata = value; + } + + final PropertyReflection> filePart; + static UndefinedWrapper< + XFile +> _fileGetter(UploadFileRequest parent) { + return parent.file; + } + static void _fileSetter(UploadFileRequest parent, UndefinedWrapper< + XFile +> value) { + parent.file = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + additionalMetadataPart, +filePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(UploadFileRequest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(UploadFileRequest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + UploadFileRequest empty() { + return UploadFileRequest( + ); + } + + @override + bool operator ==(Object other) { + return other is UploadFileRequestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_with_required_file_request.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_with_required_file_request.dart new file mode 100644 index 000000000000..b6378db9c41d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_with_required_file_request.dart @@ -0,0 +1,96 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'upload_file_with_required_file_request.reflection.dart'; + + +/// UploadFileWithRequiredFileRequestMixin +/// +/// Properties: +/// * [additionalMetadata] - Additional data to pass to server +/// * [requiredFile] - file to upload +mixin UploadFileWithRequiredFileRequestMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get additionalMetadata; + + XFile + get requiredFile; + +} + +/// UploadFileWithRequiredFileRequest +/// +/// Properties: +/// * [additionalMetadata] - Additional data to pass to server +/// * [requiredFile] - file to upload +class UploadFileWithRequiredFileRequest with +$OpenApiObjectMixin, + +UploadFileWithRequiredFileRequestMixin { + @override + UndefinedWrapper< + String +> additionalMetadata; + @override + + XFile + requiredFile; + + AdditionalProperties additionalProperties; + + + + UploadFileWithRequiredFileRequest.$all({ + required this.additionalMetadata, + required this.requiredFile, + required this.additionalProperties, + + }); + + UploadFileWithRequiredFileRequest({ + this.additionalMetadata = const UndefinedWrapper + .undefined() +, +required this.requiredFile , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = UploadFileWithRequiredFileRequestReflection.instance; + UploadFileWithRequiredFileRequestReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory UploadFileWithRequiredFileRequest.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + UploadFileWithRequiredFileRequest clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_with_required_file_request.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_with_required_file_request.reflection.dart new file mode 100644 index 000000000000..37fb28ef2124 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/upload_file_with_required_file_request.reflection.dart @@ -0,0 +1,189 @@ +// Model reflection + +part of 'upload_file_with_required_file_request.dart'; + + +//class reflection + +class UploadFileWithRequiredFileRequestReflection extends ModelReflection { + static UploadFileWithRequiredFileRequestReflection instanceGetter() => instance; + static const instance = UploadFileWithRequiredFileRequestReflection._( + modelName: r'uploadFileWithRequiredFile_request', + className: r'UploadFileWithRequiredFileRequest', + xml: XmlReflection( +), + additionalMetadataPart: PropertyReflection>( + dartName: r'additionalMetadata', + nullable: false, + required: false, + oasName: r'additionalMetadata', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_additionalMetadataGetter), + setter: FunctionWrapper2(_additionalMetadataSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + requiredFilePart: PropertyReflection( + dartName: r'requiredFile', + nullable: false, + required: true, + oasName: r'requiredFile', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_requiredFileGetter), + setter: FunctionWrapper2(_requiredFileSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forXFile + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const UploadFileWithRequiredFileRequestReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.additionalMetadataPart, + required this.requiredFilePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> additionalMetadataPart; + static UndefinedWrapper< + String +> _additionalMetadataGetter(UploadFileWithRequiredFileRequest parent) { + return parent.additionalMetadata; + } + static void _additionalMetadataSetter(UploadFileWithRequiredFileRequest parent, UndefinedWrapper< + String +> value) { + parent.additionalMetadata = value; + } + + final PropertyReflection requiredFilePart; + static + XFile + _requiredFileGetter(UploadFileWithRequiredFileRequest parent) { + return parent.requiredFile; + } + static void _requiredFileSetter(UploadFileWithRequiredFileRequest parent, + XFile + value) { + parent.requiredFile = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + additionalMetadataPart, +requiredFilePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(UploadFileWithRequiredFileRequest instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(UploadFileWithRequiredFileRequest instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + UploadFileWithRequiredFileRequest empty() { + return UploadFileWithRequiredFileRequest( + requiredFile: requiredFilePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is UploadFileWithRequiredFileRequestReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/user.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/user.dart new file mode 100644 index 000000000000..a3b9891ff445 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/user.dart @@ -0,0 +1,256 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'user.reflection.dart'; + + +/// UserMixin +/// +/// Properties: +/// * [id] +/// * [username] +/// * [firstName] +/// * [lastName] +/// * [email] +/// * [password] +/// * [phone] +/// * [userStatus] - User Status +/// * [objectWithNoDeclaredProps] - test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. +/// * [objectWithNoDeclaredPropsNullable] - test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. +/// * [anyTypeProp] - test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 +/// * [anyTypePropNullable] - test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. +mixin UserMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + int +> get id; +UndefinedWrapper< + String +> get username; +UndefinedWrapper< + String +> get firstName; +UndefinedWrapper< + String +> get lastName; +UndefinedWrapper< + String +> get email; +UndefinedWrapper< + String +> get password; +UndefinedWrapper< + String +> get phone; +UndefinedWrapper< + int +> get userStatus; +UndefinedWrapper< + $FreeFormObject +> get objectWithNoDeclaredProps; +UndefinedWrapper< + $FreeFormObject +?> get objectWithNoDeclaredPropsNullable; +UndefinedWrapper get anyTypeProp; +UndefinedWrapper< + $FreeFormObject +?> get anyTypePropNullable; + +} + +/// User +/// +/// Properties: +/// * [id] +/// * [username] +/// * [firstName] +/// * [lastName] +/// * [email] +/// * [password] +/// * [phone] +/// * [userStatus] - User Status +/// * [objectWithNoDeclaredProps] - test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. +/// * [objectWithNoDeclaredPropsNullable] - test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. +/// * [anyTypeProp] - test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 +/// * [anyTypePropNullable] - test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. +class User with +$OpenApiObjectMixin, + +UserMixin { + @override + UndefinedWrapper< + int +> id; + @override + UndefinedWrapper< + String +> username; + @override + UndefinedWrapper< + String +> firstName; + @override + UndefinedWrapper< + String +> lastName; + @override + UndefinedWrapper< + String +> email; + @override + UndefinedWrapper< + String +> password; + @override + UndefinedWrapper< + String +> phone; + @override + UndefinedWrapper< + int +> userStatus; + @override + UndefinedWrapper< + $FreeFormObject +> objectWithNoDeclaredProps; + @override + UndefinedWrapper< + $FreeFormObject +?> objectWithNoDeclaredPropsNullable; + @override + UndefinedWrapper anyTypeProp; + @override + UndefinedWrapper< + $FreeFormObject +?> anyTypePropNullable; + + AdditionalProperties additionalProperties; + + + + User.$all({ + required this.id, + required this.username, + required this.firstName, + required this.lastName, + required this.email, + required this.password, + required this.phone, + required this.userStatus, + required this.objectWithNoDeclaredProps, + required this.objectWithNoDeclaredPropsNullable, + required this.anyTypeProp, + required this.anyTypePropNullable, + required this.additionalProperties, + + }); + + User({ + this.id = const UndefinedWrapper + .undefined() +, + this.username = const UndefinedWrapper + .undefined() +, + this.firstName = const UndefinedWrapper + .undefined() +, + this.lastName = const UndefinedWrapper + .undefined() +, + this.email = const UndefinedWrapper + .undefined() +, + this.password = const UndefinedWrapper + .undefined() +, + this.phone = const UndefinedWrapper + .undefined() +, + this.userStatus = const UndefinedWrapper + .undefined() +, + this.objectWithNoDeclaredProps = const UndefinedWrapper + .undefined() +, + this.objectWithNoDeclaredPropsNullable = const UndefinedWrapper + .undefined() +, + this.anyTypeProp = const UndefinedWrapper + .undefined() +, + this.anyTypePropNullable = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = UserReflection.instance; + UserReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory User.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + User clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/user.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/user.reflection.dart new file mode 100644 index 000000000000..57d06a0e1f0e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/user.reflection.dart @@ -0,0 +1,629 @@ +// Model reflection + +part of 'user.dart'; + + +//class reflection + +class UserReflection extends ModelReflection { + static UserReflection instanceGetter() => instance; + static const instance = UserReflection._( + modelName: r'User', + className: r'User', + xml: XmlReflection( + xmlName: r'User', +), + idPart: PropertyReflection>( + dartName: r'id', + nullable: false, + required: false, + oasName: r'id', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_idGetter), + setter: FunctionWrapper2(_idSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + usernamePart: PropertyReflection>( + dartName: r'username', + nullable: false, + required: false, + oasName: r'username', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_usernameGetter), + setter: FunctionWrapper2(_usernameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + firstNamePart: PropertyReflection>( + dartName: r'firstName', + nullable: false, + required: false, + oasName: r'firstName', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_firstNameGetter), + setter: FunctionWrapper2(_firstNameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + lastNamePart: PropertyReflection>( + dartName: r'lastName', + nullable: false, + required: false, + oasName: r'lastName', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_lastNameGetter), + setter: FunctionWrapper2(_lastNameSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + emailPart: PropertyReflection>( + dartName: r'email', + nullable: false, + required: false, + oasName: r'email', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_emailGetter), + setter: FunctionWrapper2(_emailSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + passwordPart: PropertyReflection>( + dartName: r'password', + nullable: false, + required: false, + oasName: r'password', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_passwordGetter), + setter: FunctionWrapper2(_passwordSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + phonePart: PropertyReflection>( + dartName: r'phone', + nullable: false, + required: false, + oasName: r'phone', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_phoneGetter), + setter: FunctionWrapper2(_phoneSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + userStatusPart: PropertyReflection>( + dartName: r'userStatus', + nullable: false, + required: false, + oasName: r'userStatus', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_userStatusGetter), + setter: FunctionWrapper2(_userStatusSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + objectWithNoDeclaredPropsPart: PropertyReflection>( + dartName: r'objectWithNoDeclaredProps', + nullable: false, + required: false, + oasName: r'objectWithNoDeclaredProps', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_objectWithNoDeclaredPropsGetter), + setter: FunctionWrapper2(_objectWithNoDeclaredPropsSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.for$FreeFormObject + +, +) +), + ), + objectWithNoDeclaredPropsNullablePart: PropertyReflection>( + dartName: r'objectWithNoDeclaredPropsNullable', + nullable: true, + required: false, + oasName: r'objectWithNoDeclaredPropsNullable', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_objectWithNoDeclaredPropsNullableGetter), + setter: FunctionWrapper2(_objectWithNoDeclaredPropsNullableSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.for$FreeFormObject + +), +) +), + ), + anyTypePropPart: PropertyReflection>( + dartName: r'anyTypeProp', + nullable: true, + required: false, + oasName: r'anyTypeProp', + oasType: r'Object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_anyTypePropGetter), + setter: FunctionWrapper2(_anyTypePropSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +), + ), + anyTypePropNullablePart: PropertyReflection>( + dartName: r'anyTypePropNullable', + nullable: true, + required: false, + oasName: r'anyTypePropNullable', + oasType: r'object', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_anyTypePropNullableGetter), + setter: FunctionWrapper2(_anyTypePropNullableSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection( + + + + + PrimitiveReflection.for$FreeFormObject + +), +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const UserReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.idPart, + required this.usernamePart, + required this.firstNamePart, + required this.lastNamePart, + required this.emailPart, + required this.passwordPart, + required this.phonePart, + required this.userStatusPart, + required this.objectWithNoDeclaredPropsPart, + required this.objectWithNoDeclaredPropsNullablePart, + required this.anyTypePropPart, + required this.anyTypePropNullablePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> idPart; + static UndefinedWrapper< + int +> _idGetter(User parent) { + return parent.id; + } + static void _idSetter(User parent, UndefinedWrapper< + int +> value) { + parent.id = value; + } + + final PropertyReflection> usernamePart; + static UndefinedWrapper< + String +> _usernameGetter(User parent) { + return parent.username; + } + static void _usernameSetter(User parent, UndefinedWrapper< + String +> value) { + parent.username = value; + } + + final PropertyReflection> firstNamePart; + static UndefinedWrapper< + String +> _firstNameGetter(User parent) { + return parent.firstName; + } + static void _firstNameSetter(User parent, UndefinedWrapper< + String +> value) { + parent.firstName = value; + } + + final PropertyReflection> lastNamePart; + static UndefinedWrapper< + String +> _lastNameGetter(User parent) { + return parent.lastName; + } + static void _lastNameSetter(User parent, UndefinedWrapper< + String +> value) { + parent.lastName = value; + } + + final PropertyReflection> emailPart; + static UndefinedWrapper< + String +> _emailGetter(User parent) { + return parent.email; + } + static void _emailSetter(User parent, UndefinedWrapper< + String +> value) { + parent.email = value; + } + + final PropertyReflection> passwordPart; + static UndefinedWrapper< + String +> _passwordGetter(User parent) { + return parent.password; + } + static void _passwordSetter(User parent, UndefinedWrapper< + String +> value) { + parent.password = value; + } + + final PropertyReflection> phonePart; + static UndefinedWrapper< + String +> _phoneGetter(User parent) { + return parent.phone; + } + static void _phoneSetter(User parent, UndefinedWrapper< + String +> value) { + parent.phone = value; + } + + final PropertyReflection> userStatusPart; + static UndefinedWrapper< + int +> _userStatusGetter(User parent) { + return parent.userStatus; + } + static void _userStatusSetter(User parent, UndefinedWrapper< + int +> value) { + parent.userStatus = value; + } + + final PropertyReflection> objectWithNoDeclaredPropsPart; + static UndefinedWrapper< + $FreeFormObject +> _objectWithNoDeclaredPropsGetter(User parent) { + return parent.objectWithNoDeclaredProps; + } + static void _objectWithNoDeclaredPropsSetter(User parent, UndefinedWrapper< + $FreeFormObject +> value) { + parent.objectWithNoDeclaredProps = value; + } + + final PropertyReflection> objectWithNoDeclaredPropsNullablePart; + static UndefinedWrapper< + $FreeFormObject +?> _objectWithNoDeclaredPropsNullableGetter(User parent) { + return parent.objectWithNoDeclaredPropsNullable; + } + static void _objectWithNoDeclaredPropsNullableSetter(User parent, UndefinedWrapper< + $FreeFormObject +?> value) { + parent.objectWithNoDeclaredPropsNullable = value; + } + + final PropertyReflection> anyTypePropPart; + static UndefinedWrapper _anyTypePropGetter(User parent) { + return parent.anyTypeProp; + } + static void _anyTypePropSetter(User parent, UndefinedWrapper value) { + parent.anyTypeProp = value; + } + + final PropertyReflection> anyTypePropNullablePart; + static UndefinedWrapper< + $FreeFormObject +?> _anyTypePropNullableGetter(User parent) { + return parent.anyTypePropNullable; + } + static void _anyTypePropNullableSetter(User parent, UndefinedWrapper< + $FreeFormObject +?> value) { + parent.anyTypePropNullable = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + idPart, +usernamePart, +firstNamePart, +lastNamePart, +emailPart, +passwordPart, +phonePart, +userStatusPart, +objectWithNoDeclaredPropsPart, +objectWithNoDeclaredPropsNullablePart, +anyTypePropPart, +anyTypePropNullablePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(User instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(User instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + User empty() { + return User( + ); + } + + @override + bool operator ==(Object other) { + return other is UserReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/value.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/value.dart new file mode 100644 index 000000000000..a855ffc5d5a7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/value.dart @@ -0,0 +1,94 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'value.reflection.dart'; + + +/// ValueMixin +mixin ValueMixin on + $OpenApiObjectMixin { + + UndefinedWrapper< + Scalar +> get oneOf0; + UndefinedWrapper< + List< + + Scalar +> +> get oneOf1; +} + +/// Value +class Value with +$OpenApiObjectMixin, + +ValueMixin { + + AdditionalProperties additionalProperties; + + + @override + UndefinedWrapper< + Scalar +> oneOf0; + + @override + UndefinedWrapper< + List< + + Scalar +> +> oneOf1; + + + Value.$all({ + required this.additionalProperties, + + required this.oneOf0, + required this.oneOf1, + }); + + Value({ + AdditionalProperties? additionalProperties, + + this.oneOf0 = const UndefinedWrapper.undefined(), + this.oneOf1 = const UndefinedWrapper.undefined(), + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ValueReflection.instance; + ValueReflection get $classReflection => $reflection; + + @override + bool validate() { + final oneOfs = [oneOf0,oneOf1,].where((e) => e.isDefined).take(2); + if (oneOfs.length > 1) { + // there must be AT MOST one "oneOf" schema. + return false; + } + + return super.validate(); + } + + factory Value.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Value clone() { + return $reflection.clone(this); + } +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/value.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/value.reflection.dart new file mode 100644 index 000000000000..e727cddc52f1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/value.reflection.dart @@ -0,0 +1,290 @@ +// Model reflection + +part of 'value.dart'; + + +//class reflection + +class ValueReflection extends ModelReflection { + static ValueReflection instanceGetter() => instance; + static const instance = ValueReflection._( + modelName: r'Value', + className: r'Value', + xml: XmlReflection( +), + + + oneOf0Part: ValueOneOf0Part( + parentReflectionGetter: instanceGetter, + ), + + oneOf1Part: ValueOneOf1Part( + parentReflectionGetter: instanceGetter, + ), + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ValueReflection._({ + required this.modelName, + required this.className, + required this.xml, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.oneOf0Part, + + required this.oneOf1Part, + + required this.additionalPropertiesPart, + }); + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Value instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Value instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + final ValueOneOf0Part oneOf0Part; + + final ValueOneOf1Part oneOf1Part; + + + @override + List> get allOfs => [ + + ]; + + @override + List> get oneOfs => [ + oneOf0Part,oneOf1Part, + ]; + @override + List> get anyOfs => [ + + ]; + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Value empty() { + return Value( + ); + } + + @override + bool operator ==(Object other) { + return other is ValueReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + +class ValueOneOf0Part extends OneOfReflection { + + const ValueOneOf0Part({ + required ValueReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1, Value> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + Scalar +> _getter(Value src) { + return src.oneOf0; +} +static void _setter(Value src, UndefinedWrapper< + Scalar +> value) { + src.oneOf0 = value; +} + +@override +UndefinedWrapperReflection< + Scalar +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Scalar.$reflection + + + ), +); + + UndefinedWrapper< + Scalar +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + // An example SHOULD be generated + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + +class ValueOneOf1Part extends OneOfReflection +> { + + const ValueOneOf1Part({ + required ValueReflection Function() super.parentReflectionGetter, +}); +@override +FunctionWrapper1 +>, Value> get getter => FunctionWrapper1(_getter); +@override +FunctionWrapper2 +>> get setter => FunctionWrapper2(_setter); + +static UndefinedWrapper< + List< + + Scalar +> +> _getter(Value src) { + return src.oneOf1; +} +static void _setter(Value src, UndefinedWrapper< + List< + + Scalar +> +> value) { + src.oneOf1 = value; +} + +@override +UndefinedWrapperReflection< + List< + + Scalar +> +> get reflection => UndefinedWrapperReflection( + XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Scalar.$reflection + +, +) +) + + ), +); + + UndefinedWrapper< + List< + + Scalar +> +> example({ + required AggregatedDiscriminatorsResult discriminators, + required Map> discriminatorExampleResults, + required Map? fileCache, + }) { + if (discriminatorExampleResults.isEmpty) { + //return undefined for non-first oneOfs. + return UndefinedWrapper.undefined(); + } else { + // if this reflection wasn't a result of any property, don't generate an example. + + if (!discriminatorExampleResults.values + .any((e) => e.value == reflection.subReflection)) { + // if there are no discriminator examples targetting the current class: + return UndefinedWrapper.undefined(); + } else { + // An example SHOULD be generated + } + } + return reflection.example(); + } +} + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/variable.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/variable.dart new file mode 100644 index 000000000000..11999666d7a8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/variable.dart @@ -0,0 +1,94 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'variable.reflection.dart'; + + +/// Value object +/// +/// Properties: +/// * [name] +/// * [value] +mixin VariableMixin on + $OpenApiObjectMixin { + + String + get name; + + Value + get value; + +} + +/// Value object +/// +/// Properties: +/// * [name] +/// * [value] +class Variable with +$OpenApiObjectMixin, + +VariableMixin { + @override + + String + name; + @override + + Value + value; + + AdditionalProperties additionalProperties; + + + + Variable.$all({ + required this.name, + required this.value, + required this.additionalProperties, + + }); + + Variable({ + required this.name , +required this.value , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = VariableReflection.instance; + VariableReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Variable.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Variable clone() { + return $reflection.clone(this); + } +} + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/variable.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/variable.reflection.dart new file mode 100644 index 000000000000..69d64fbda7eb --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/variable.reflection.dart @@ -0,0 +1,190 @@ +// Model reflection + +part of 'variable.dart'; + + +//class reflection + +class VariableReflection extends ModelReflection { + static VariableReflection instanceGetter() => instance; + static const instance = VariableReflection._( + modelName: r'Variable', + className: r'Variable', + xml: XmlReflection( +), + namePart: PropertyReflection( + dartName: r'name', + nullable: false, + required: true, + oasName: r'name', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameGetter), + setter: FunctionWrapper2(_nameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + valuePart: PropertyReflection( + dartName: r'value', + nullable: false, + required: true, + oasName: r'value', + oasType: r'Value', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_valueGetter), + setter: FunctionWrapper2(_valueSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + Value.$reflection + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const VariableReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.namePart, + required this.valuePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection namePart; + static + String + _nameGetter(Variable parent) { + return parent.name; + } + static void _nameSetter(Variable parent, + String + value) { + parent.name = value; + } + + final PropertyReflection valuePart; + static + Value + _valueGetter(Variable parent) { + return parent.value; + } + static void _valueSetter(Variable parent, + Value + value) { + parent.value = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + namePart, +valuePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Variable instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Variable instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Variable empty() { + return Variable( + name: namePart.reflection.emptyFunction(), + value: valuePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is VariableReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/whale.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/whale.dart new file mode 100644 index 000000000000..cde4fe5dc36f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/whale.dart @@ -0,0 +1,112 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'whale.reflection.dart'; + + +/// WhaleMixin +/// +/// Properties: +/// * [hasBaleen] +/// * [hasTeeth] +/// * [className] +mixin WhaleMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + bool +> get hasBaleen; +UndefinedWrapper< + bool +> get hasTeeth; + + String + get className; + +} + +/// Whale +/// +/// Properties: +/// * [hasBaleen] +/// * [hasTeeth] +/// * [className] +class Whale with +$OpenApiObjectMixin, + +WhaleMixin { + @override + UndefinedWrapper< + bool +> hasBaleen; + @override + UndefinedWrapper< + bool +> hasTeeth; + @override + + String + className; + + AdditionalProperties additionalProperties; + + + + Whale.$all({ + required this.hasBaleen, + required this.hasTeeth, + required this.className, + required this.additionalProperties, + + }); + + Whale({ + this.hasBaleen = const UndefinedWrapper + .undefined() +, + this.hasTeeth = const UndefinedWrapper + .undefined() +, +required this.className , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = WhaleReflection.instance; + WhaleReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Whale.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Whale clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/whale.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/whale.reflection.dart new file mode 100644 index 000000000000..c6d122dac09b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/whale.reflection.dart @@ -0,0 +1,234 @@ +// Model reflection + +part of 'whale.dart'; + + +//class reflection + +class WhaleReflection extends ModelReflection { + static WhaleReflection instanceGetter() => instance; + static const instance = WhaleReflection._( + modelName: r'whale', + className: r'Whale', + xml: XmlReflection( +), + hasBaleenPart: PropertyReflection>( + dartName: r'hasBaleen', + nullable: false, + required: false, + oasName: r'hasBaleen', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_hasBaleenGetter), + setter: FunctionWrapper2(_hasBaleenSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + hasTeethPart: PropertyReflection>( + dartName: r'hasTeeth', + nullable: false, + required: false, + oasName: r'hasTeeth', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_hasTeethGetter), + setter: FunctionWrapper2(_hasTeethSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + classNamePart: PropertyReflection( + dartName: r'className', + nullable: false, + required: true, + oasName: r'className', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_classNameGetter), + setter: FunctionWrapper2(_classNameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const WhaleReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.hasBaleenPart, + required this.hasTeethPart, + required this.classNamePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> hasBaleenPart; + static UndefinedWrapper< + bool +> _hasBaleenGetter(Whale parent) { + return parent.hasBaleen; + } + static void _hasBaleenSetter(Whale parent, UndefinedWrapper< + bool +> value) { + parent.hasBaleen = value; + } + + final PropertyReflection> hasTeethPart; + static UndefinedWrapper< + bool +> _hasTeethGetter(Whale parent) { + return parent.hasTeeth; + } + static void _hasTeethSetter(Whale parent, UndefinedWrapper< + bool +> value) { + parent.hasTeeth = value; + } + + final PropertyReflection classNamePart; + static + String + _classNameGetter(Whale parent) { + return parent.className; + } + static void _classNameSetter(Whale parent, + String + value) { + parent.className = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + hasBaleenPart, +hasTeethPart, +classNamePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Whale instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Whale instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Whale empty() { + return Whale( + className: classNamePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is WhaleReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/xml_item.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/xml_item.dart new file mode 100644 index 000000000000..50c277a810c5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/xml_item.dart @@ -0,0 +1,602 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'xml_item.reflection.dart'; + + +/// XmlItemMixin +/// +/// Properties: +/// * [attributeString] +/// * [attributeNumber] +/// * [attributeInteger] +/// * [attributeBoolean] +/// * [wrappedArray] +/// * [nameString] +/// * [nameNumber] +/// * [nameInteger] +/// * [nameBoolean] +/// * [nameArray] +/// * [nameWrappedArray] +/// * [prefixString] +/// * [prefixNumber] +/// * [prefixInteger] +/// * [prefixBoolean] +/// * [prefixArray] +/// * [prefixWrappedArray] +/// * [namespaceString] +/// * [namespaceNumber] +/// * [namespaceInteger] +/// * [namespaceBoolean] +/// * [namespaceArray] +/// * [namespaceWrappedArray] +/// * [prefixNsString] +/// * [prefixNsNumber] +/// * [prefixNsInteger] +/// * [prefixNsBoolean] +/// * [prefixNsArray] +/// * [prefixNsWrappedArray] +mixin XmlItemMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + String +> get attributeString; +UndefinedWrapper< + num +> get attributeNumber; +UndefinedWrapper< + int +> get attributeInteger; +UndefinedWrapper< + bool +> get attributeBoolean; +UndefinedWrapper< + List< + + int +> +> get wrappedArray; +UndefinedWrapper< + String +> get nameString; +UndefinedWrapper< + num +> get nameNumber; +UndefinedWrapper< + int +> get nameInteger; +UndefinedWrapper< + bool +> get nameBoolean; +UndefinedWrapper< + List< + + int +> +> get nameArray; +UndefinedWrapper< + List< + + int +> +> get nameWrappedArray; +UndefinedWrapper< + String +> get prefixString; +UndefinedWrapper< + num +> get prefixNumber; +UndefinedWrapper< + int +> get prefixInteger; +UndefinedWrapper< + bool +> get prefixBoolean; +UndefinedWrapper< + List< + + int +> +> get prefixArray; +UndefinedWrapper< + List< + + int +> +> get prefixWrappedArray; +UndefinedWrapper< + String +> get namespaceString; +UndefinedWrapper< + num +> get namespaceNumber; +UndefinedWrapper< + int +> get namespaceInteger; +UndefinedWrapper< + bool +> get namespaceBoolean; +UndefinedWrapper< + List< + + int +> +> get namespaceArray; +UndefinedWrapper< + List< + + int +> +> get namespaceWrappedArray; +UndefinedWrapper< + String +> get prefixNsString; +UndefinedWrapper< + num +> get prefixNsNumber; +UndefinedWrapper< + int +> get prefixNsInteger; +UndefinedWrapper< + bool +> get prefixNsBoolean; +UndefinedWrapper< + List< + + int +> +> get prefixNsArray; +UndefinedWrapper< + List< + + int +> +> get prefixNsWrappedArray; + +} + +/// XmlItem +/// +/// Properties: +/// * [attributeString] +/// * [attributeNumber] +/// * [attributeInteger] +/// * [attributeBoolean] +/// * [wrappedArray] +/// * [nameString] +/// * [nameNumber] +/// * [nameInteger] +/// * [nameBoolean] +/// * [nameArray] +/// * [nameWrappedArray] +/// * [prefixString] +/// * [prefixNumber] +/// * [prefixInteger] +/// * [prefixBoolean] +/// * [prefixArray] +/// * [prefixWrappedArray] +/// * [namespaceString] +/// * [namespaceNumber] +/// * [namespaceInteger] +/// * [namespaceBoolean] +/// * [namespaceArray] +/// * [namespaceWrappedArray] +/// * [prefixNsString] +/// * [prefixNsNumber] +/// * [prefixNsInteger] +/// * [prefixNsBoolean] +/// * [prefixNsArray] +/// * [prefixNsWrappedArray] +class XmlItem with +$OpenApiObjectMixin, + +XmlItemMixin { + @override + UndefinedWrapper< + String +> attributeString; + @override + UndefinedWrapper< + num +> attributeNumber; + @override + UndefinedWrapper< + int +> attributeInteger; + @override + UndefinedWrapper< + bool +> attributeBoolean; + @override + UndefinedWrapper< + List< + + int +> +> wrappedArray; + @override + UndefinedWrapper< + String +> nameString; + @override + UndefinedWrapper< + num +> nameNumber; + @override + UndefinedWrapper< + int +> nameInteger; + @override + UndefinedWrapper< + bool +> nameBoolean; + @override + UndefinedWrapper< + List< + + int +> +> nameArray; + @override + UndefinedWrapper< + List< + + int +> +> nameWrappedArray; + @override + UndefinedWrapper< + String +> prefixString; + @override + UndefinedWrapper< + num +> prefixNumber; + @override + UndefinedWrapper< + int +> prefixInteger; + @override + UndefinedWrapper< + bool +> prefixBoolean; + @override + UndefinedWrapper< + List< + + int +> +> prefixArray; + @override + UndefinedWrapper< + List< + + int +> +> prefixWrappedArray; + @override + UndefinedWrapper< + String +> namespaceString; + @override + UndefinedWrapper< + num +> namespaceNumber; + @override + UndefinedWrapper< + int +> namespaceInteger; + @override + UndefinedWrapper< + bool +> namespaceBoolean; + @override + UndefinedWrapper< + List< + + int +> +> namespaceArray; + @override + UndefinedWrapper< + List< + + int +> +> namespaceWrappedArray; + @override + UndefinedWrapper< + String +> prefixNsString; + @override + UndefinedWrapper< + num +> prefixNsNumber; + @override + UndefinedWrapper< + int +> prefixNsInteger; + @override + UndefinedWrapper< + bool +> prefixNsBoolean; + @override + UndefinedWrapper< + List< + + int +> +> prefixNsArray; + @override + UndefinedWrapper< + List< + + int +> +> prefixNsWrappedArray; + + AdditionalProperties additionalProperties; + + + + XmlItem.$all({ + required this.attributeString, + required this.attributeNumber, + required this.attributeInteger, + required this.attributeBoolean, + required this.wrappedArray, + required this.nameString, + required this.nameNumber, + required this.nameInteger, + required this.nameBoolean, + required this.nameArray, + required this.nameWrappedArray, + required this.prefixString, + required this.prefixNumber, + required this.prefixInteger, + required this.prefixBoolean, + required this.prefixArray, + required this.prefixWrappedArray, + required this.namespaceString, + required this.namespaceNumber, + required this.namespaceInteger, + required this.namespaceBoolean, + required this.namespaceArray, + required this.namespaceWrappedArray, + required this.prefixNsString, + required this.prefixNsNumber, + required this.prefixNsInteger, + required this.prefixNsBoolean, + required this.prefixNsArray, + required this.prefixNsWrappedArray, + required this.additionalProperties, + + }); + + XmlItem({ + this.attributeString = const UndefinedWrapper + .undefined() +, + this.attributeNumber = const UndefinedWrapper + .undefined() +, + this.attributeInteger = const UndefinedWrapper + .undefined() +, + this.attributeBoolean = const UndefinedWrapper + .undefined() +, + this.wrappedArray = const UndefinedWrapper + .undefined() +, + this.nameString = const UndefinedWrapper + .undefined() +, + this.nameNumber = const UndefinedWrapper + .undefined() +, + this.nameInteger = const UndefinedWrapper + .undefined() +, + this.nameBoolean = const UndefinedWrapper + .undefined() +, + this.nameArray = const UndefinedWrapper + .undefined() +, + this.nameWrappedArray = const UndefinedWrapper + .undefined() +, + this.prefixString = const UndefinedWrapper + .undefined() +, + this.prefixNumber = const UndefinedWrapper + .undefined() +, + this.prefixInteger = const UndefinedWrapper + .undefined() +, + this.prefixBoolean = const UndefinedWrapper + .undefined() +, + this.prefixArray = const UndefinedWrapper + .undefined() +, + this.prefixWrappedArray = const UndefinedWrapper + .undefined() +, + this.namespaceString = const UndefinedWrapper + .undefined() +, + this.namespaceNumber = const UndefinedWrapper + .undefined() +, + this.namespaceInteger = const UndefinedWrapper + .undefined() +, + this.namespaceBoolean = const UndefinedWrapper + .undefined() +, + this.namespaceArray = const UndefinedWrapper + .undefined() +, + this.namespaceWrappedArray = const UndefinedWrapper + .undefined() +, + this.prefixNsString = const UndefinedWrapper + .undefined() +, + this.prefixNsNumber = const UndefinedWrapper + .undefined() +, + this.prefixNsInteger = const UndefinedWrapper + .undefined() +, + this.prefixNsBoolean = const UndefinedWrapper + .undefined() +, + this.prefixNsArray = const UndefinedWrapper + .undefined() +, + this.prefixNsWrappedArray = const UndefinedWrapper + .undefined() +, + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = XmlItemReflection.instance; + XmlItemReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory XmlItem.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + XmlItem clone() { + return $reflection.clone(this); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/xml_item.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/xml_item.reflection.dart new file mode 100644 index 000000000000..b5115757d152 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/xml_item.reflection.dart @@ -0,0 +1,1654 @@ +// Model reflection + +part of 'xml_item.dart'; + + +//class reflection + +class XmlItemReflection extends ModelReflection { + static XmlItemReflection instanceGetter() => instance; + static const instance = XmlItemReflection._( + modelName: r'XmlItem', + className: r'XmlItem', + xml: XmlReflection( + namespace: r'http://a.com/schema', + prefix: r'pre', +), + attributeStringPart: PropertyReflection>( + dartName: r'attributeString', + nullable: false, + required: false, + oasName: r'attribute_string', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + attribute: true, +), + getter: FunctionWrapper1(_attributeStringGetter), + setter: FunctionWrapper2(_attributeStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + attribute: true, +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + attributeNumberPart: PropertyReflection>( + dartName: r'attributeNumber', + nullable: false, + required: false, + oasName: r'attribute_number', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + attribute: true, +), + getter: FunctionWrapper1(_attributeNumberGetter), + setter: FunctionWrapper2(_attributeNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + attribute: true, +), + + + + + + PrimitiveReflection.fornum + +, +) +), + ), + attributeIntegerPart: PropertyReflection>( + dartName: r'attributeInteger', + nullable: false, + required: false, + oasName: r'attribute_integer', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + attribute: true, +), + getter: FunctionWrapper1(_attributeIntegerGetter), + setter: FunctionWrapper2(_attributeIntegerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + attribute: true, +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + attributeBooleanPart: PropertyReflection>( + dartName: r'attributeBoolean', + nullable: false, + required: false, + oasName: r'attribute_boolean', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + attribute: true, +), + getter: FunctionWrapper1(_attributeBooleanGetter), + setter: FunctionWrapper2(_attributeBooleanSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + attribute: true, +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + wrappedArrayPart: PropertyReflection +>>( + dartName: r'wrappedArray', + nullable: false, + required: false, + oasName: r'wrapped_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + wrapped: true, +), + getter: FunctionWrapper1(_wrappedArrayGetter), + setter: FunctionWrapper2(_wrappedArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +), + ), + nameStringPart: PropertyReflection>( + dartName: r'nameString', + nullable: false, + required: false, + oasName: r'name_string', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'xml_name_string', +), + getter: FunctionWrapper1(_nameStringGetter), + setter: FunctionWrapper2(_nameStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'xml_name_string', +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + nameNumberPart: PropertyReflection>( + dartName: r'nameNumber', + nullable: false, + required: false, + oasName: r'name_number', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'xml_name_number', +), + getter: FunctionWrapper1(_nameNumberGetter), + setter: FunctionWrapper2(_nameNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'xml_name_number', +), + + + + + + PrimitiveReflection.fornum + +, +) +), + ), + nameIntegerPart: PropertyReflection>( + dartName: r'nameInteger', + nullable: false, + required: false, + oasName: r'name_integer', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'xml_name_integer', +), + getter: FunctionWrapper1(_nameIntegerGetter), + setter: FunctionWrapper2(_nameIntegerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'xml_name_integer', +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + nameBooleanPart: PropertyReflection>( + dartName: r'nameBoolean', + nullable: false, + required: false, + oasName: r'name_boolean', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'xml_name_boolean', +), + getter: FunctionWrapper1(_nameBooleanGetter), + setter: FunctionWrapper2(_nameBooleanSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'xml_name_boolean', +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + nameArrayPart: PropertyReflection +>>( + dartName: r'nameArray', + nullable: false, + required: false, + oasName: r'name_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_nameArrayGetter), + setter: FunctionWrapper2(_nameArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'xml_name_array_item', +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +), + ), + nameWrappedArrayPart: PropertyReflection +>>( + dartName: r'nameWrappedArray', + nullable: false, + required: false, + oasName: r'name_wrapped_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + xmlName: r'xml_name_wrapped_array', + wrapped: true, +), + getter: FunctionWrapper1(_nameWrappedArrayGetter), + setter: FunctionWrapper2(_nameWrappedArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'xml_name_wrapped_array', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'xml_name_wrapped_array_item', +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +), + ), + prefixStringPart: PropertyReflection>( + dartName: r'prefixString', + nullable: false, + required: false, + oasName: r'prefix_string', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + prefix: r'ab', +), + getter: FunctionWrapper1(_prefixStringGetter), + setter: FunctionWrapper2(_prefixStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + prefix: r'ab', +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + prefixNumberPart: PropertyReflection>( + dartName: r'prefixNumber', + nullable: false, + required: false, + oasName: r'prefix_number', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + prefix: r'cd', +), + getter: FunctionWrapper1(_prefixNumberGetter), + setter: FunctionWrapper2(_prefixNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + prefix: r'cd', +), + + + + + + PrimitiveReflection.fornum + +, +) +), + ), + prefixIntegerPart: PropertyReflection>( + dartName: r'prefixInteger', + nullable: false, + required: false, + oasName: r'prefix_integer', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + prefix: r'ef', +), + getter: FunctionWrapper1(_prefixIntegerGetter), + setter: FunctionWrapper2(_prefixIntegerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + prefix: r'ef', +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + prefixBooleanPart: PropertyReflection>( + dartName: r'prefixBoolean', + nullable: false, + required: false, + oasName: r'prefix_boolean', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + prefix: r'gh', +), + getter: FunctionWrapper1(_prefixBooleanGetter), + setter: FunctionWrapper2(_prefixBooleanSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + prefix: r'gh', +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + prefixArrayPart: PropertyReflection +>>( + dartName: r'prefixArray', + nullable: false, + required: false, + oasName: r'prefix_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_prefixArrayGetter), + setter: FunctionWrapper2(_prefixArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + prefix: r'ij', +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +), + ), + prefixWrappedArrayPart: PropertyReflection +>>( + dartName: r'prefixWrappedArray', + nullable: false, + required: false, + oasName: r'prefix_wrapped_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + prefix: r'kl', + wrapped: true, +), + getter: FunctionWrapper1(_prefixWrappedArrayGetter), + setter: FunctionWrapper2(_prefixWrappedArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + prefix: r'kl', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + prefix: r'mn', +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +), + ), + namespaceStringPart: PropertyReflection>( + dartName: r'namespaceString', + nullable: false, + required: false, + oasName: r'namespace_string', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://a.com/schema', +), + getter: FunctionWrapper1(_namespaceStringGetter), + setter: FunctionWrapper2(_namespaceStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://a.com/schema', +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + namespaceNumberPart: PropertyReflection>( + dartName: r'namespaceNumber', + nullable: false, + required: false, + oasName: r'namespace_number', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://b.com/schema', +), + getter: FunctionWrapper1(_namespaceNumberGetter), + setter: FunctionWrapper2(_namespaceNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://b.com/schema', +), + + + + + + PrimitiveReflection.fornum + +, +) +), + ), + namespaceIntegerPart: PropertyReflection>( + dartName: r'namespaceInteger', + nullable: false, + required: false, + oasName: r'namespace_integer', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://c.com/schema', +), + getter: FunctionWrapper1(_namespaceIntegerGetter), + setter: FunctionWrapper2(_namespaceIntegerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://c.com/schema', +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + namespaceBooleanPart: PropertyReflection>( + dartName: r'namespaceBoolean', + nullable: false, + required: false, + oasName: r'namespace_boolean', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://d.com/schema', +), + getter: FunctionWrapper1(_namespaceBooleanGetter), + setter: FunctionWrapper2(_namespaceBooleanSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://d.com/schema', +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + namespaceArrayPart: PropertyReflection +>>( + dartName: r'namespaceArray', + nullable: false, + required: false, + oasName: r'namespace_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_namespaceArrayGetter), + setter: FunctionWrapper2(_namespaceArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://e.com/schema', +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +), + ), + namespaceWrappedArrayPart: PropertyReflection +>>( + dartName: r'namespaceWrappedArray', + nullable: false, + required: false, + oasName: r'namespace_wrapped_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://f.com/schema', + wrapped: true, +), + getter: FunctionWrapper1(_namespaceWrappedArrayGetter), + setter: FunctionWrapper2(_namespaceWrappedArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://f.com/schema', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://g.com/schema', +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +), + ), + prefixNsStringPart: PropertyReflection>( + dartName: r'prefixNsString', + nullable: false, + required: false, + oasName: r'prefix_ns_string', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://a.com/schema', + prefix: r'a', +), + getter: FunctionWrapper1(_prefixNsStringGetter), + setter: FunctionWrapper2(_prefixNsStringSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://a.com/schema', + prefix: r'a', +), + + + + + + PrimitiveReflection.forString + +, +) +), + ), + prefixNsNumberPart: PropertyReflection>( + dartName: r'prefixNsNumber', + nullable: false, + required: false, + oasName: r'prefix_ns_number', + oasType: r'number', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://b.com/schema', + prefix: r'b', +), + getter: FunctionWrapper1(_prefixNsNumberGetter), + setter: FunctionWrapper2(_prefixNsNumberSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://b.com/schema', + prefix: r'b', +), + + + + + + PrimitiveReflection.fornum + +, +) +), + ), + prefixNsIntegerPart: PropertyReflection>( + dartName: r'prefixNsInteger', + nullable: false, + required: false, + oasName: r'prefix_ns_integer', + oasType: r'integer', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://c.com/schema', + prefix: r'c', +), + getter: FunctionWrapper1(_prefixNsIntegerGetter), + setter: FunctionWrapper2(_prefixNsIntegerSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://c.com/schema', + prefix: r'c', +), + + + + + + PrimitiveReflection.forint + +, +) +), + ), + prefixNsBooleanPart: PropertyReflection>( + dartName: r'prefixNsBoolean', + nullable: false, + required: false, + oasName: r'prefix_ns_boolean', + oasType: r'boolean', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://d.com/schema', + prefix: r'd', +), + getter: FunctionWrapper1(_prefixNsBooleanGetter), + setter: FunctionWrapper2(_prefixNsBooleanSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://d.com/schema', + prefix: r'd', +), + + + + + + PrimitiveReflection.forbool + +, +) +), + ), + prefixNsArrayPart: PropertyReflection +>>( + dartName: r'prefixNsArray', + nullable: false, + required: false, + oasName: r'prefix_ns_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_prefixNsArrayGetter), + setter: FunctionWrapper2(_prefixNsArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://e.com/schema', + prefix: r'e', +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +), + ), + prefixNsWrappedArrayPart: PropertyReflection +>>( + dartName: r'prefixNsWrappedArray', + nullable: false, + required: false, + oasName: r'prefix_ns_wrapped_array', + oasType: r'array', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( + namespace: r'http://f.com/schema', + prefix: r'f', + wrapped: true, +), + getter: FunctionWrapper1(_prefixNsWrappedArrayGetter), + setter: FunctionWrapper2(_prefixNsWrappedArraySetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://f.com/schema', + prefix: r'f', + wrapped: true, +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( + namespace: r'http://g.com/schema', + prefix: r'g', +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +), + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const XmlItemReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.attributeStringPart, + required this.attributeNumberPart, + required this.attributeIntegerPart, + required this.attributeBooleanPart, + required this.wrappedArrayPart, + required this.nameStringPart, + required this.nameNumberPart, + required this.nameIntegerPart, + required this.nameBooleanPart, + required this.nameArrayPart, + required this.nameWrappedArrayPart, + required this.prefixStringPart, + required this.prefixNumberPart, + required this.prefixIntegerPart, + required this.prefixBooleanPart, + required this.prefixArrayPart, + required this.prefixWrappedArrayPart, + required this.namespaceStringPart, + required this.namespaceNumberPart, + required this.namespaceIntegerPart, + required this.namespaceBooleanPart, + required this.namespaceArrayPart, + required this.namespaceWrappedArrayPart, + required this.prefixNsStringPart, + required this.prefixNsNumberPart, + required this.prefixNsIntegerPart, + required this.prefixNsBooleanPart, + required this.prefixNsArrayPart, + required this.prefixNsWrappedArrayPart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> attributeStringPart; + static UndefinedWrapper< + String +> _attributeStringGetter(XmlItem parent) { + return parent.attributeString; + } + static void _attributeStringSetter(XmlItem parent, UndefinedWrapper< + String +> value) { + parent.attributeString = value; + } + + final PropertyReflection> attributeNumberPart; + static UndefinedWrapper< + num +> _attributeNumberGetter(XmlItem parent) { + return parent.attributeNumber; + } + static void _attributeNumberSetter(XmlItem parent, UndefinedWrapper< + num +> value) { + parent.attributeNumber = value; + } + + final PropertyReflection> attributeIntegerPart; + static UndefinedWrapper< + int +> _attributeIntegerGetter(XmlItem parent) { + return parent.attributeInteger; + } + static void _attributeIntegerSetter(XmlItem parent, UndefinedWrapper< + int +> value) { + parent.attributeInteger = value; + } + + final PropertyReflection> attributeBooleanPart; + static UndefinedWrapper< + bool +> _attributeBooleanGetter(XmlItem parent) { + return parent.attributeBoolean; + } + static void _attributeBooleanSetter(XmlItem parent, UndefinedWrapper< + bool +> value) { + parent.attributeBoolean = value; + } + + final PropertyReflection +>> wrappedArrayPart; + static UndefinedWrapper< + List< + + int +> +> _wrappedArrayGetter(XmlItem parent) { + return parent.wrappedArray; + } + static void _wrappedArraySetter(XmlItem parent, UndefinedWrapper< + List< + + int +> +> value) { + parent.wrappedArray = value; + } + + final PropertyReflection> nameStringPart; + static UndefinedWrapper< + String +> _nameStringGetter(XmlItem parent) { + return parent.nameString; + } + static void _nameStringSetter(XmlItem parent, UndefinedWrapper< + String +> value) { + parent.nameString = value; + } + + final PropertyReflection> nameNumberPart; + static UndefinedWrapper< + num +> _nameNumberGetter(XmlItem parent) { + return parent.nameNumber; + } + static void _nameNumberSetter(XmlItem parent, UndefinedWrapper< + num +> value) { + parent.nameNumber = value; + } + + final PropertyReflection> nameIntegerPart; + static UndefinedWrapper< + int +> _nameIntegerGetter(XmlItem parent) { + return parent.nameInteger; + } + static void _nameIntegerSetter(XmlItem parent, UndefinedWrapper< + int +> value) { + parent.nameInteger = value; + } + + final PropertyReflection> nameBooleanPart; + static UndefinedWrapper< + bool +> _nameBooleanGetter(XmlItem parent) { + return parent.nameBoolean; + } + static void _nameBooleanSetter(XmlItem parent, UndefinedWrapper< + bool +> value) { + parent.nameBoolean = value; + } + + final PropertyReflection +>> nameArrayPart; + static UndefinedWrapper< + List< + + int +> +> _nameArrayGetter(XmlItem parent) { + return parent.nameArray; + } + static void _nameArraySetter(XmlItem parent, UndefinedWrapper< + List< + + int +> +> value) { + parent.nameArray = value; + } + + final PropertyReflection +>> nameWrappedArrayPart; + static UndefinedWrapper< + List< + + int +> +> _nameWrappedArrayGetter(XmlItem parent) { + return parent.nameWrappedArray; + } + static void _nameWrappedArraySetter(XmlItem parent, UndefinedWrapper< + List< + + int +> +> value) { + parent.nameWrappedArray = value; + } + + final PropertyReflection> prefixStringPart; + static UndefinedWrapper< + String +> _prefixStringGetter(XmlItem parent) { + return parent.prefixString; + } + static void _prefixStringSetter(XmlItem parent, UndefinedWrapper< + String +> value) { + parent.prefixString = value; + } + + final PropertyReflection> prefixNumberPart; + static UndefinedWrapper< + num +> _prefixNumberGetter(XmlItem parent) { + return parent.prefixNumber; + } + static void _prefixNumberSetter(XmlItem parent, UndefinedWrapper< + num +> value) { + parent.prefixNumber = value; + } + + final PropertyReflection> prefixIntegerPart; + static UndefinedWrapper< + int +> _prefixIntegerGetter(XmlItem parent) { + return parent.prefixInteger; + } + static void _prefixIntegerSetter(XmlItem parent, UndefinedWrapper< + int +> value) { + parent.prefixInteger = value; + } + + final PropertyReflection> prefixBooleanPart; + static UndefinedWrapper< + bool +> _prefixBooleanGetter(XmlItem parent) { + return parent.prefixBoolean; + } + static void _prefixBooleanSetter(XmlItem parent, UndefinedWrapper< + bool +> value) { + parent.prefixBoolean = value; + } + + final PropertyReflection +>> prefixArrayPart; + static UndefinedWrapper< + List< + + int +> +> _prefixArrayGetter(XmlItem parent) { + return parent.prefixArray; + } + static void _prefixArraySetter(XmlItem parent, UndefinedWrapper< + List< + + int +> +> value) { + parent.prefixArray = value; + } + + final PropertyReflection +>> prefixWrappedArrayPart; + static UndefinedWrapper< + List< + + int +> +> _prefixWrappedArrayGetter(XmlItem parent) { + return parent.prefixWrappedArray; + } + static void _prefixWrappedArraySetter(XmlItem parent, UndefinedWrapper< + List< + + int +> +> value) { + parent.prefixWrappedArray = value; + } + + final PropertyReflection> namespaceStringPart; + static UndefinedWrapper< + String +> _namespaceStringGetter(XmlItem parent) { + return parent.namespaceString; + } + static void _namespaceStringSetter(XmlItem parent, UndefinedWrapper< + String +> value) { + parent.namespaceString = value; + } + + final PropertyReflection> namespaceNumberPart; + static UndefinedWrapper< + num +> _namespaceNumberGetter(XmlItem parent) { + return parent.namespaceNumber; + } + static void _namespaceNumberSetter(XmlItem parent, UndefinedWrapper< + num +> value) { + parent.namespaceNumber = value; + } + + final PropertyReflection> namespaceIntegerPart; + static UndefinedWrapper< + int +> _namespaceIntegerGetter(XmlItem parent) { + return parent.namespaceInteger; + } + static void _namespaceIntegerSetter(XmlItem parent, UndefinedWrapper< + int +> value) { + parent.namespaceInteger = value; + } + + final PropertyReflection> namespaceBooleanPart; + static UndefinedWrapper< + bool +> _namespaceBooleanGetter(XmlItem parent) { + return parent.namespaceBoolean; + } + static void _namespaceBooleanSetter(XmlItem parent, UndefinedWrapper< + bool +> value) { + parent.namespaceBoolean = value; + } + + final PropertyReflection +>> namespaceArrayPart; + static UndefinedWrapper< + List< + + int +> +> _namespaceArrayGetter(XmlItem parent) { + return parent.namespaceArray; + } + static void _namespaceArraySetter(XmlItem parent, UndefinedWrapper< + List< + + int +> +> value) { + parent.namespaceArray = value; + } + + final PropertyReflection +>> namespaceWrappedArrayPart; + static UndefinedWrapper< + List< + + int +> +> _namespaceWrappedArrayGetter(XmlItem parent) { + return parent.namespaceWrappedArray; + } + static void _namespaceWrappedArraySetter(XmlItem parent, UndefinedWrapper< + List< + + int +> +> value) { + parent.namespaceWrappedArray = value; + } + + final PropertyReflection> prefixNsStringPart; + static UndefinedWrapper< + String +> _prefixNsStringGetter(XmlItem parent) { + return parent.prefixNsString; + } + static void _prefixNsStringSetter(XmlItem parent, UndefinedWrapper< + String +> value) { + parent.prefixNsString = value; + } + + final PropertyReflection> prefixNsNumberPart; + static UndefinedWrapper< + num +> _prefixNsNumberGetter(XmlItem parent) { + return parent.prefixNsNumber; + } + static void _prefixNsNumberSetter(XmlItem parent, UndefinedWrapper< + num +> value) { + parent.prefixNsNumber = value; + } + + final PropertyReflection> prefixNsIntegerPart; + static UndefinedWrapper< + int +> _prefixNsIntegerGetter(XmlItem parent) { + return parent.prefixNsInteger; + } + static void _prefixNsIntegerSetter(XmlItem parent, UndefinedWrapper< + int +> value) { + parent.prefixNsInteger = value; + } + + final PropertyReflection> prefixNsBooleanPart; + static UndefinedWrapper< + bool +> _prefixNsBooleanGetter(XmlItem parent) { + return parent.prefixNsBoolean; + } + static void _prefixNsBooleanSetter(XmlItem parent, UndefinedWrapper< + bool +> value) { + parent.prefixNsBoolean = value; + } + + final PropertyReflection +>> prefixNsArrayPart; + static UndefinedWrapper< + List< + + int +> +> _prefixNsArrayGetter(XmlItem parent) { + return parent.prefixNsArray; + } + static void _prefixNsArraySetter(XmlItem parent, UndefinedWrapper< + List< + + int +> +> value) { + parent.prefixNsArray = value; + } + + final PropertyReflection +>> prefixNsWrappedArrayPart; + static UndefinedWrapper< + List< + + int +> +> _prefixNsWrappedArrayGetter(XmlItem parent) { + return parent.prefixNsWrappedArray; + } + static void _prefixNsWrappedArraySetter(XmlItem parent, UndefinedWrapper< + List< + + int +> +> value) { + parent.prefixNsWrappedArray = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + attributeStringPart, +attributeNumberPart, +attributeIntegerPart, +attributeBooleanPart, +wrappedArrayPart, +nameStringPart, +nameNumberPart, +nameIntegerPart, +nameBooleanPart, +nameArrayPart, +nameWrappedArrayPart, +prefixStringPart, +prefixNumberPart, +prefixIntegerPart, +prefixBooleanPart, +prefixArrayPart, +prefixWrappedArrayPart, +namespaceStringPart, +namespaceNumberPart, +namespaceIntegerPart, +namespaceBooleanPart, +namespaceArrayPart, +namespaceWrappedArrayPart, +prefixNsStringPart, +prefixNsNumberPart, +prefixNsIntegerPart, +prefixNsBooleanPart, +prefixNsArrayPart, +prefixNsWrappedArrayPart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(XmlItem instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(XmlItem instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + XmlItem empty() { + return XmlItem( + ); + } + + @override + bool operator ==(Object other) { + return other is XmlItemReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/zebra.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/zebra.dart new file mode 100644 index 000000000000..501f1a2ca617 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/zebra.dart @@ -0,0 +1,145 @@ +// Model def + +import 'package:petstore_api/_internal.dart'; + + +part 'zebra.reflection.dart'; + + +/// ZebraMixin +/// +/// Properties: +/// * [type] +/// * [className] +mixin ZebraMixin on + $OpenApiObjectMixin { + UndefinedWrapper< + ZebraTypeEnum +> get type; + + String + get className; + +} + +/// Zebra +/// +/// Properties: +/// * [type] +/// * [className] +class Zebra with +$OpenApiObjectMixin, + +ZebraMixin { + @override + UndefinedWrapper< + ZebraTypeEnum +> type; + @override + + String + className; + + AdditionalProperties additionalProperties; + + + + Zebra.$all({ + required this.type, + required this.className, + required this.additionalProperties, + + }); + + Zebra({ + this.type = const UndefinedWrapper + .undefined() +, +required this.className , + AdditionalProperties? additionalProperties, + + }) : additionalProperties = additionalProperties ?? {}; + + static const $reflection = ZebraReflection.instance; + ZebraReflection get $classReflection => $reflection; + + @override + bool validate() { + return super.validate(); + } + + factory Zebra.deserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.deserialize(src, context); + } + + static bool canDeserialize(Object? src, [SerializationContext context = const SerializationContext.json(),]) { + return $reflection.canDeserialize(src, context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json(),]) { + return $reflection.serialize(this, context); + } + + Zebra clone() { + return $reflection.clone(this); + } +} + + +extension type const ZebraTypeEnum._(String value) implements String { + const ZebraTypeEnum.plains() : this._(r'plains'); + const ZebraTypeEnum.mountain() : this._(r'mountain'); + const ZebraTypeEnum.grevys() : this._(r'grevys'); + + /// Creates a [ZebraTypeEnum] enum from a value and safely checking if it exists. + factory ZebraTypeEnum.$safe(String value) { + final res = values.where((element) => element.value == value).firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res; + } + + static const $reflection = EnumReflection( + PrimitiveReflection.forString, + members: [ + + EnumMemberReflection(dartName: r'plains', oasValue: r'plains', value: ZebraTypeEnum.plains()), + + EnumMemberReflection(dartName: r'mountain', oasValue: r'mountain', value: ZebraTypeEnum.mountain()), + + EnumMemberReflection(dartName: r'grevys', oasValue: r'grevys', value: ZebraTypeEnum.grevys()), + + ], + ); + + factory ZebraTypeEnum.deserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.deserializeFunction(value, context); + } + + static bool canDeserialize(Object? value, [SerializationContext context = const SerializationContext.json()]) { + return $reflection.canDeserializeFunction(value,context); + } + + Object? serialize([SerializationContext context = const SerializationContext.json()]) { + return $reflection.serializeFunction(this, context); + } + + /// Creates a [ZebraTypeEnum] enum from a value without checking if it exists. + const ZebraTypeEnum.$unsafe(String value) : this._(value); + + /// All possible values of the enum. + static const List values = [ + ZebraTypeEnum.plains(), + ZebraTypeEnum.mountain(), + ZebraTypeEnum.grevys(), + + ]; +} + + + + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/models/zebra.reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/models/zebra.reflection.dart new file mode 100644 index 000000000000..150d5e7184f1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/models/zebra.reflection.dart @@ -0,0 +1,186 @@ +// Model reflection + +part of 'zebra.dart'; + + +//class reflection + +class ZebraReflection extends ModelReflection { + static ZebraReflection instanceGetter() => instance; + static const instance = ZebraReflection._( + modelName: r'zebra', + className: r'Zebra', + xml: XmlReflection( +), + typePart: PropertyReflection>( + dartName: r'type', + nullable: false, + required: false, + oasName: r'type', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_typeGetter), + setter: FunctionWrapper2(_typeSetter), + reflection: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ZebraTypeEnum.$reflection + + +, +) +), + ), + classNamePart: PropertyReflection( + dartName: r'className', + nullable: false, + required: true, + oasName: r'className', + oasType: r'string', + pattern: null, + parentReflectionGetter: instanceGetter, + isDiscriminator: false, + xml: XmlReflection( +), + getter: FunctionWrapper1(_classNameGetter), + setter: FunctionWrapper2(_classNameSetter), + reflection: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +, + ), + + + additionalPropertiesPart: AdditionalPropertiesPart( + parentReflectionGetter: instanceGetter, + itemReflection: XmlReflectionWrapper( + xml: XmlReflection( +), + NullableReflection(ObjectReflection() +), +) +, + getter: FunctionWrapper1(_AdditionalPropertiesGetter), + setter: FunctionWrapper2(_AdditionalPropertiesSetter), + ), + ); + const ZebraReflection._({ + required this.modelName, + required this.className, + required this.xml, + required this.typePart, + required this.classNamePart, + this.discriminatorKey, + this.discriminatorMappings = const {}, + this.discriminatorImplicitMappings = const {}, + + required this.additionalPropertiesPart, + }); + + final PropertyReflection> typePart; + static UndefinedWrapper< + ZebraTypeEnum +> _typeGetter(Zebra parent) { + return parent.type; + } + static void _typeSetter(Zebra parent, UndefinedWrapper< + ZebraTypeEnum +> value) { + parent.type = value; + } + + final PropertyReflection classNamePart; + static + String + _classNameGetter(Zebra parent) { + return parent.className; + } + static void _classNameSetter(Zebra parent, + String + value) { + parent.className = value; + } + + + @override + final Map discriminatorMappings; + @override + final Map discriminatorImplicitMappings; + @override + final String? discriminatorKey; + @override + final String modelName; + @override + final String className; + @override + final XmlReflection xml; + + @override + List> get properties => [ + typePart, +classNamePart, + ]; + + @override + final AdditionalPropertiesPart? additionalPropertiesPart; + + static AdditionalProperties _AdditionalPropertiesGetter(Zebra instance) { + return instance.additionalProperties; + } + static void _AdditionalPropertiesSetter(Zebra instance, AdditionalProperties additionalProperties) { + instance.additionalProperties = additionalProperties; + } + + + + + @override + List> get allOfs => [ + + ]; + + + + /// Creates an empty instance used as a starting point for deserialization. + @override + Zebra empty() { + return Zebra( + className: classNamePart.reflection.emptyFunction(), + ); + } + + @override + bool operator ==(Object other) { + return other is ZebraReflection && oasName == other.oasName; + } + + @override + int get hashCode => oasName.hashCode; +} + + diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/networking/_exports.dart b/samples/openapi3/client/petstore/dart/next/lib/src/networking/_exports.dart new file mode 100644 index 000000000000..e84060708f8d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/networking/_exports.dart @@ -0,0 +1,4 @@ +export 'package_http_client.dart'; +export 'property_encoding_rule.dart'; +export 'multipart.dart'; +export 'wire_serialization_options.dart'; \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/networking/_internal.dart b/samples/openapi3/client/petstore/dart/next/lib/src/networking/_internal.dart new file mode 100644 index 000000000000..48a03674a96b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/networking/_internal.dart @@ -0,0 +1,3 @@ +export '_exports.dart'; + +export 'helpers.dart'; \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/networking/helpers.dart b/samples/openapi3/client/petstore/dart/next/lib/src/networking/helpers.dart new file mode 100644 index 000000000000..70d10311efde --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/networking/helpers.dart @@ -0,0 +1,211 @@ +import 'package:collection/collection.dart'; +import 'package:petstore_api/_internal.dart'; + +enum PatternMatchResult { + exact, + partial, + fail, +} + +extension PatternMatchResultHelper on Iterable<(PatternMatchResult, T)> { + T? pickPrioritized() { + return this + .where((a) => a.$1 != PatternMatchResult.fail) + .sortedByCompare((x) => x.$1, Enum.compareByIndex) + .firstOrNull + ?.$2; + } +} + + +class OASNetworkingUtils { + /// Serializes dart primitives into a byte stream based on mime type. + /// + /// This is an opinionated best-effort function that will try to serialize + /// common objects into common mime type formats. + /// + /// If the target mime type is a text-based mime type (e.g. application/json + /// or application/xml), then the [src] object will be serialized to string + /// and then encoded based on [targetMediaType]'s `charset` parameter. + /// + /// If the target mime type is NOT a text-based mime type, then the [src] object + /// MUST be either a Stream> or [Uint8List] or [XFile] and it will be + /// sent as-is. + static Stream> serializeToWire( + Object? src, + MediaType targetMediaType, { + WireSerializationOptions? options, + }) async* { + options ??= WireSerializationOptions(); + if (options.isTextBased(targetMediaType, options)) { + final string = + await serializeToString(src, targetMediaType, options: options); + final encoding = getEncodingOrDefault(targetMediaType); + yield encoding.encode(string); + } else { + if (src is Stream>) { + yield* src; + } else if (src is Uint8List) { + yield src; + } else if (src is XFile) { + yield* src.openRead(); + } else { + throw UnsupportedError( + 'Object of type $src can not be serialized to mime type ($targetMediaType)', + ); + } + } + } + + static Future serializeToString( + Object? src, + MediaType targetMediaType, { + WireSerializationOptions? options, + }) async { + options ??= WireSerializationOptions(); + if (options.isXml(targetMediaType)) { + if (src is! XmlHasWriter) { + throw ArgumentError.value( + src, + 'src', + 'only XmlNode can be serialized to xml.', + ); + } + return src.toXmlString(); + } else if (options.isJson(targetMediaType)) { + return jsonEncode(src, toEncodable: options.toEncodable); + } else if (options.isFormUrlEncoded(targetMediaType)) { + if (src is! Map) { + throw ArgumentError.value( + src, + 'src', + 'Only Map can be serializd ' + 'to application/x-www-form-urlencoded', + ); + } + return formUrlEncoded(src, options.encodingRules ?? {}); + } else { + // by default, call toString. + return src?.toString() ?? ''; + } + } + + /// Deserializes a byte stream to dart primitives based on mime type. + /// + /// if the deserialization is not possible, returns a Stream. + static Future deserializeFromWire( + Stream src, + MediaType targetMediaType, { + WireSerializationOptions? options, + }) async { + options ??= WireSerializationOptions(); + if (options.isTextBased(targetMediaType, options)) { + final encoding = getEncodingOrDefault(targetMediaType); + final decoded = await encoding.decodeStream(src); + return await deserializeFromString(decoded, targetMediaType); + } else { + return src; + } + } + + static Future deserializeFromString( + String src, + MediaType targetMediaType, { + WireSerializationOptions? options, + }) async { + // + options ??= WireSerializationOptions(); + if (options.isXml(targetMediaType)) { + return XmlDocumentFragment.parse(src); + } else if (options.isJson(targetMediaType)) { + return jsonDecode(src); + } else if (options.isFormUrlEncoded(targetMediaType)) { + return Uri(query: src).queryParametersAll; + } else { + // by default, return src as is. + return src; + } + } + + static bool isMediaTypeSerializable(MediaType mediaType) { + if (mediaType + case MediaType(type: 'application', subtype: 'json') || + MediaType(type: 'application', subtype: 'xml') || + MediaType(type: 'text') || + MediaType(type: 'application', subtype: 'x-www-form-urlencoded')) { + return true; + } + return false; + } + + static String formUrlEncoded(Map serialized, + Map encodingRules) { + var result = Uri(); + + for (var e in serialized.entries) { + final rule = encodingRules[e.key]; + final style = rule?.style ?? 'form'; + final explode = rule?.explode ?? (style == 'form'); + result = OpenApiParameterSerializationQuery.fromStyle( + style, + explode: explode, + parameterName: e.key, + allowEmptyValue: false, + ).expandUri(result, e.value); + } + var resultString = result.query.toString(); + if (resultString.startsWith('?')) { + resultString = resultString.substring(1); + } + return resultString; + } + + static Encoding getEncodingOrDefault(MediaType contentType) { + final charset = contentType.parameters['charset'] ?? 'utf-8'; + return Encoding.getByName(charset) ?? utf8; + } + + static PatternMatchResult matchesStatusCodePattern( + int statusCode, + String pattern, + ) { + // Normalize the pattern + pattern = pattern.toUpperCase(); + if (pattern == 'DEFAULT') { + return PatternMatchResult.partial; + } + final parsedPattern = int.tryParse(pattern); + if (parsedPattern != null) { + return parsedPattern == statusCode + ? PatternMatchResult.exact + : PatternMatchResult.fail; + } + final removePlaceHolders = pattern.replaceAll('X', ''); + return statusCode.toString().startsWith(removePlaceHolders) + ? PatternMatchResult.partial + : PatternMatchResult.fail; + } + + static PatternMatchResult matchesContentTypePattern( + MediaType contentType, + MediaType pattern, + ) { + switch (pattern) { + case MediaType(type: '*', subtype: '*'): + return PatternMatchResult.partial; + case MediaType(type: final type, subtype: '*'): + if (type == contentType.type) { + return PatternMatchResult.partial; + } + case MediaType(type: '*', subtype: final subtype): + if (subtype == contentType.subtype) { + return PatternMatchResult.partial; + } + case MediaType(type: final type, subtype: final subtype): + if (contentType.type == type && contentType.subtype == subtype) { + return PatternMatchResult.exact; + } + } + return PatternMatchResult.fail; + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/networking/multipart.dart b/samples/openapi3/client/petstore/dart/next/lib/src/networking/multipart.dart new file mode 100644 index 000000000000..c8a42ad8f3dc --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/networking/multipart.dart @@ -0,0 +1,171 @@ +import 'package:petstore_api/_internal.dart'; + +typedef UnknownMediaTypeHandler = Stream> Function(MediaType mediaType, Object? serialized, Encoding encoding, Map encodingRules); + +typedef AppendFormDataPartHandler = Stream Function( + String fieldName, + Object? value, + MediaType? contentType, + Map? headers, +); +typedef AppendPartHandler = Stream Function( + Object? value, + MediaType? contentType, + Map? headers, +); + +Stream defaultAppendFormDataPart( + String fieldName, + Object? value, + MediaType? contentType, + Map? headers, +) async* { + yield MultiPartFormDataFieldHttpPacket( + field: fieldName, + value: value.toString(), + extraHeaders: headers, + ); +} +Stream defaultAppendPart( + Object? value, + MediaType? contentType, + Map? headers, +) async* { + yield HttpPacketMixin.memory( + bodyBytes: utf8.encode(jsonEncode(value)), + headers: { + 'Content-Type': 'application/json', + ...?headers, + }, + ); +} + +Stream appendFormDataValue( + String fieldName, + Object? value, + MediaType? contentType, + Map? headers, { + AppendFormDataPartHandler unkownHandler = defaultAppendFormDataPart, +}) async* { + switch (value) { + case Uint8List(): + yield MultiPartFormDataFileHttpPacket( + field: fieldName, + bodyBytesStream: Stream.value(value), + mimeType: contentType?.toString(), + fileSize: value.lengthInBytes, + extraHeaders: headers, + ); + case XFile(): + yield MultiPartFormDataFileHttpPacket( + field: fieldName, + bodyBytesStream: value.openRead(), + mimeType: contentType?.toString() ?? value.mimeType, + fileSize: await value.length(), + fileName: value.name, + extraHeaders: headers, + ); + + case String(): + case num(): + yield MultiPartFormDataFieldHttpPacket( + field: fieldName, + value: value.toString(), + extraHeaders: headers, + ); + case Iterable(): + for (var child in value) { + yield* appendFormDataValue( + fieldName + '[]', + child, + contentType, + headers, + unkownHandler: unkownHandler, + ); + } + case Map(): + for (var entry in value.entries) { + // We can either serialize the value as json, or flatten it as a form data. + yield* appendFormDataValue( + fieldName + '[' + entry.key + ']', + entry.value, + contentType, + headers, + unkownHandler: unkownHandler, + ); + } + // DateTime implementation is left to the user in the unkownHandler. + case DateTime(): + default: + yield* unkownHandler( + fieldName, + value, + contentType, + headers, + ); + } +} + +Stream appendPartValue( + Object? value, + MediaType? contentType, + Map? headers, { + AppendPartHandler unkownHandler = defaultAppendPart, +}) async* { + switch (value) { + case Uint8List(): + yield HttpPacketMixin.memory( + bodyBytes: value, + headers: { + 'Content-Type': contentType?.toString() ?? 'application/octet-stream', + ...?headers + }, + ); + case XFile(): + yield HttpPacketMixin.stream( + bodyBytesStream: value.openRead(), + headers: { + 'Content-Disposition': 'attachment; filename="${value.name}"', + 'Content-Type': contentType?.toString() ?? value.mimeType ?? 'application/octet-stream', + ...?headers, + }, + contentLength: await value.length(), + ); + case String(): + case num(): + yield HttpPacketMixin.memory( + bodyBytes: utf8.encode(value.toString()), + headers: { + 'Content-Type': contentType?.toString() ?? 'text/plain', + ...?headers + }, + ); + case Iterable(): + for (var child in value) { + yield* appendPartValue( + child, + contentType, + headers, + unkownHandler: unkownHandler, + ); + } + case Map(): + for (var entry in value.entries) { + // We can either serialize the value as json, or flatten it as a form data. + yield* appendPartValue( + entry.value, + contentType, + headers, + unkownHandler: unkownHandler, + ); + } + // DateTime implementation is left to the user in the unkownHandler. + case DateTime(): + default: + yield* unkownHandler( + value, + contentType, + headers, + ); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/networking/package_http_client.dart b/samples/openapi3/client/petstore/dart/next/lib/src/networking/package_http_client.dart new file mode 100644 index 000000000000..f3d9edb7d9d7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/networking/package_http_client.dart @@ -0,0 +1,45 @@ +import 'package:openapi_infrastructure/openapi_infrastructure.dart'; +import 'package:http/http.dart' as http; + + +class PackageHttpNetworkingClient extends NetworkingClientBase { + final http.Client client; + + PackageHttpNetworkingClient({ + http.Client? client, + }) : client = client ?? http.Client(); + + @override + Future sendRequest(HttpRequestBase request) async { + final mappedRequest = _BaseRequestWrapper(request); + final response = await client.send(mappedRequest); + + return HttpResponseBase.stream( + originalRequest: request, + context: request.context, + headers: request.headers, + bodyBytesStream: response.stream, + statusCode: response.statusCode, + reasonPhrase: response.reasonPhrase, + ); + } +} + +class _BaseRequestWrapper extends http.BaseRequest { + _BaseRequestWrapper(this.request) : super(request.method, request.url) { + for (var element in request.headers.entries) { + headers[element.key] = element.value; + } + if (request is MemoryHttpRequest) { + contentLength = (request as MemoryHttpRequest).bodyBytes.length; + } + } + + final HttpRequestBase request; + + @override + http.ByteStream finalize() { + super.finalize(); + return http.ByteStream(request.bodyBytesStream); + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/networking/property_encoding_rule.dart b/samples/openapi3/client/petstore/dart/next/lib/src/networking/property_encoding_rule.dart new file mode 100644 index 000000000000..8940f3fbfaee --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/networking/property_encoding_rule.dart @@ -0,0 +1,17 @@ +import 'package:petstore_api/_internal.dart'; + +class PropertyEncodingRule { + final String? style; + final bool? explode; + final bool? allowReserved; + final MediaType? contentType; + final Map headers; + + const PropertyEncodingRule({ + this.style, + this.explode, + this.allowReserved, + this.contentType, + this.headers = const {} + }); +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/networking/wire_serialization_options.dart b/samples/openapi3/client/petstore/dart/next/lib/src/networking/wire_serialization_options.dart new file mode 100644 index 000000000000..c56d7038c496 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/networking/wire_serialization_options.dart @@ -0,0 +1,226 @@ +import 'package:petstore_api/_internal.dart'; + +/// Options to control serialization of dart objects to wire formats. +/// The main target of this class is figuring out what wire format and serialization context to use +/// for a given mime type. +class WireSerializationOptions { + const WireSerializationOptions({ + this.isJson = defaultIsJson, + this.isXml = defaultIsXml, + this.isFormUrlEncoded = defaultIsFormUrlEncoded, + this.isMultiPart = defaultIsMultiPart, + this.isMultiPartFormData = defaultIsMultiPartFormData, + this.isTextBased = defaultIsTextBased, + this.toEncodable, + this.encodingRules = const {}, + this.handleUnkownMediaType, + this.appendUnkownPart = defaultAppendPart, + this.appendUnkownFormDataPart = defaultAppendFormDataPart, + }); + + final Object? Function(Object? src)? toEncodable; + final Map encodingRules; + final bool Function(MediaType mediaType) isJson; + final bool Function(MediaType mediaType) isXml; + final bool Function(MediaType mediaType) isFormUrlEncoded; + final bool Function(MediaType mediaType) isMultiPart; + final bool Function(MediaType mediaType) isMultiPartFormData; + final bool Function(MediaType mediaType, WireSerializationOptions options) + isTextBased; + + /// Pass this to handle serialization and encoding of unkown media types yourself. + final UnknownMediaTypeHandler? handleUnkownMediaType; + + /// Only useful in multipart requests. + /// + /// Pass this to handle serialization of unkown parts yourself. + /// A value can result in one or more parts. + /// returning an empty iterable will skip the part entirely. + /// + /// The default behavior is to call [defaultAppendPart] which will call `jsonEncode` + /// to stringify the value. + final AppendPartHandler appendUnkownPart; + + /// Only useful in multipart formdata requests. + /// + /// Pass this to handle serialization of unkown form data values yourself. + /// A value can result in one or more parts. + /// returning an empty iterable will skip the field entirely. + /// + /// The default behavior is to call [defaultAppendFormDataPart] which will call `.toString` + /// to stringify the value. + final AppendFormDataPartHandler appendUnkownFormDataPart; + + WireSerializationOptions withEncodingRules( + Map rules) { + return copyWith(encodingRules: rules); + } + + WireSerializationOptions copyWith({ + Object? Function(Object? src)? toEncodable, + Map? encodingRules, + bool Function(MediaType mediaType)? isJson, + bool Function(MediaType mediaType)? isXml, + bool Function(MediaType mediaType)? isFormUrlEncoded, + bool Function(MediaType mediaType)? isMultiPart, + bool Function(MediaType mediaType)? isMultiPartFormData, + bool Function(MediaType mediaType, WireSerializationOptions options)? + isTextBased, + AppendPartHandler? appendUnkownPart = defaultAppendPart, + AppendFormDataPartHandler? appendUnkownFormDataPart, + }) { + return WireSerializationOptions( + toEncodable: toEncodable ?? this.toEncodable, + encodingRules: encodingRules ?? this.encodingRules, + isJson: isJson ?? this.isJson, + isXml: isXml ?? this.isXml, + isFormUrlEncoded: isFormUrlEncoded ?? this.isFormUrlEncoded, + isMultiPart: isMultiPart ?? this.isMultiPart, + isMultiPartFormData: isMultiPartFormData ?? this.isMultiPartFormData, + isTextBased: isTextBased ?? this.isTextBased, + appendUnkownPart: appendUnkownPart ?? this.appendUnkownPart, + appendUnkownFormDataPart: + appendUnkownFormDataPart ?? this.appendUnkownFormDataPart, + ); + } + + SerializationContext createSerializationContext(MediaType mediaType) { + if (isXml(mediaType)) { + return SerializationContext.xml(); + } + return SerializationContext.json(); + } + + /// True if the entire message can be represented textually. + static bool defaultIsTextBased( + MediaType mediaType, WireSerializationOptions options) { + return mediaType.type == 'text' || + options.isJson(mediaType) || + options.isXml(mediaType) || + options.isFormUrlEncoded(mediaType); + } + + static bool defaultIsJson(MediaType mediaType) { + if (mediaType case MediaType(subtype: 'json')) { + return true; + } + + if (mediaType.subtype.endsWith('+json')) { + return true; + } + return false; + } + + static bool defaultIsXml(MediaType mediaType) { + // covers text/xml and application/xml + if (mediaType case MediaType(subtype: 'xml')) { + return true; + } + if (mediaType.subtype.endsWith('+xml')) { + return true; + } + return false; + } + + static bool defaultIsFormUrlEncoded(MediaType mediaType) { + if (mediaType + case MediaType(type: 'application', subtype: 'x-www-form-urlencoded')) { + return true; + } + return false; + } + + static bool defaultIsMultiPart(MediaType mediaType) { + return mediaType.type == 'multipart'; + } + + static bool defaultIsMultiPartFormData(MediaType mediaType) { + return mediaType.type == 'multipart' && mediaType.subtype == 'form-data'; + } + + Stream> getBodyFromSerialized({ + required Map headers, + required Object? serialized, + required MediaType resolvedMediaType, + }) async* { + final encoding = OASNetworkingUtils.getEncodingOrDefault(resolvedMediaType); + Stream> _stringResult(String? src) { + if (src == null) { + return Stream.empty(); + } + return Stream.value(encoding.encode(src)); + } + + if (isJson(resolvedMediaType)) { + yield* _stringResult(json.encode(serialized, toEncodable: toEncodable)); + } else if (isXml(resolvedMediaType)) { + if (serialized is XmlHasWriter) { + yield* _stringResult(serialized.toXmlString()); + } + } else if (isFormUrlEncoded(resolvedMediaType)) { + if (serialized is! Map) { + yield* _stringResult(serialized.toString()); + return; + } + yield* _stringResult( + OASNetworkingUtils.formUrlEncoded(serialized, encodingRules)); + } else if (isMultiPart(resolvedMediaType)) { + if (serialized is! Map) { + throw ArgumentError( + 'The serialized data must be a map in a multipart request.'); + } + + Stream getParts() async* { + if (isMultiPartFormData(resolvedMediaType)) { + for (final e in serialized.entries) { + final fieldName = e.key; + final rule = encodingRules[e.key]; + final value = e.value; + final contentType = rule?.contentType; + final headers = rule?.headers; + yield* appendFormDataValue(fieldName, value, contentType, headers, + unkownHandler: appendUnkownFormDataPart); + } + } else { + for (final e in serialized.entries) { + final key = e.key; + final value = e.value; + final rule = encodingRules[key]; + final contentType = rule?.contentType; + final headers = rule?.headers; + //key is meaningless here + yield* appendPartValue(value, contentType, headers, + unkownHandler: appendUnkownPart); + } + } + } + + final bodySerializer = MultiPartBodySerializer( + boundary: resolvedMediaType.parameters['boundary'], + parts: getParts(), + ); + final result = await bodySerializer.serialize(); + yield* result.bodyBytesStream; + } else { + if (serialized is Stream>) { + yield* serialized; + return; + } + if (serialized is Uint8List) { + yield* Stream.value(serialized); + return; + } + if (serialized is XFile) { + yield* serialized.openRead(); + return; + } + final handleUnkownMediaType = this.handleUnkownMediaType; + if (handleUnkownMediaType != null) { + yield* handleUnkownMediaType( + resolvedMediaType, serialized, encoding, encodingRules); + return; + } + yield* _stringResult(serialized.toString()); + } + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/_exports.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/_exports.dart new file mode 100644 index 000000000000..6ed187f69f7a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/_exports.dart @@ -0,0 +1,3 @@ +export 'additional_properties.dart'; +export 'open_api_object.dart'; +export 'parameter_serialization.dart'; \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/_internal.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/_internal.dart new file mode 100644 index 000000000000..d2c030169004 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/_internal.dart @@ -0,0 +1,28 @@ +export '_exports.dart'; + +export 'reflection.dart'; +export 'xml_reflection.dart'; +export 'context.dart'; +export 'json_extensions.dart'; +export 'xml_extensions.dart'; +export 'examples.dart'; +export 'primitive_reflection.dart'; +export 'model_reflection.dart'; +export 'container_reflection.dart'; +export 'generated_reflections.dart'; + +Never throwArgumentMismatch(Type type, Object? value) { + throw ArgumentError.value(value, 'value', + 'Value was expected to be of type ($type), but instead was of type (${value.runtimeType})'); +} + +Never throwArgumentRequired(String name) { + throw ArgumentError.value(name, 'name', 'Value was required, but its value was undefined'); +} + +TOther? ifNotNull(T? src, TOther? Function(T) fn) { + if (src == null) { + return null; + } + return fn(src); +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/additional_properties.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/additional_properties.dart new file mode 100644 index 000000000000..868a4f89e3e9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/additional_properties.dart @@ -0,0 +1,122 @@ +import 'package:petstore_api/_internal.dart'; +typedef $FreeFormObject = Map; +typedef AdditionalProperties = Map; + +extension OASMapExtensions on Map { + Map except(Set toRemove) => + Map.fromEntries(entries.where((e) => !toRemove.contains(e.key))); +} + +/// Mixin to mark objects as having additional properties. +mixin AdditionalPropertiesMixin on $OpenApiObjectMixin { + /// A special field containing properties that are not explicitly defined by the schema, + /// but are included in the serialization process. + /// + /// These are NOT considered a separate field, but rather an extension of the schema. + AdditionalProperties get additionalProperties; +} + +/// An openapi object that has no known properties. +class UnknownOpenApiObject + with $OpenApiObjectMixin, AdditionalPropertiesMixin { + UnknownOpenApiObject({ + AdditionalProperties? additionalProperties, + }) : additionalProperties = additionalProperties ?? {}; + + AdditionalProperties additionalProperties; + + Object? serialize([ + SerializationContext context = const SerializationContext.json(), + ]) { + return $classReflection.serialize(this); + } + + @override + UnknownOpenApiObjectReflection get $classReflection => + const UnknownOpenApiObjectReflection(); + + static Object? serializeInstance( + UnknownOpenApiObject src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src.serialize(context); + } + + static bool canDeserialize( + Object? src, [ + SerializationContext = const SerializationContext.json(), + ]) { + return true; + } + + static UnknownOpenApiObject deserialize( + Object? src, [ + SerializationContext = const SerializationContext.json(), + ]) { + return UnknownOpenApiObject( + additionalProperties: src is Map ? src : {}, + ); + } +} + +class UnknownOpenApiObjectReflection + extends ModelReflection { + const UnknownOpenApiObjectReflection(); + + @override + String get className => 'UnkownOpenApiObject'; + + @override + AdditionalPropertiesPart? + get additionalPropertiesPart => AdditionalPropertiesPart( + getter: FunctionWrapper1(additionalPropertiesGetter), + setter: FunctionWrapper2(additionalPropertiesSetter), + itemReflection: NullableReflection(ObjectReflection()), + parentReflectionGetter: () => this, + ); + + Map additionalPropertiesGetter(UnknownOpenApiObject src) { + return src.additionalProperties; + } + + void additionalPropertiesSetter( + UnknownOpenApiObject src, + Map value, + ) { + src.additionalProperties = value; + } + + @override + Map get discriminatorImplicitMappings => {}; + + @override + String? get discriminatorKey => null; + + @override + Map get discriminatorMappings => {}; + + @override + UnknownOpenApiObject empty() { + return UnknownOpenApiObject( + additionalProperties: {}, + ); + } + + @override + UnknownOpenApiObject example([ExampleContext? context]) { + return UnknownOpenApiObject( + additionalProperties: + const MapReflection(NullableReflection(ObjectReflection())).example(context), + ); + } + + @override + String get modelName => ''; + + @override + List> get properties => + const []; + + @override + XmlReflection get xml => XmlReflection(); +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/container_reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/container_reflection.dart new file mode 100644 index 000000000000..67feb5869e57 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/container_reflection.dart @@ -0,0 +1,658 @@ +import 'package:petstore_api/_internal.dart'hide e; + +import 'package:collection/collection.dart'; + +const $FreeFormObjectReflection = + MapReflection(NullableReflection(ObjectReflection())); + +extension SerializationReflectionExtensions on SerializationReflection { + ModelReflection? getNearestModelReflection({ + bool Function(ContainerReflection reflection) shouldVisitChildOf = + defaultShouldVisitChildOf, + }) { + return getNearestReflectionOfType(shouldVisitChildOf: shouldVisitChildOf); + } + /// searches serialization reflection tree to find a reflection that matches a given type. + TReflection? getNearestReflectionOfType< + TReflection extends SerializationReflection>({ + bool Function(ContainerReflection reflection) shouldVisitChildOf = + defaultShouldVisitChildOf, + }) { + return getNearestReflectionWhere( + (reflection) => reflection is TReflection, + shouldVisitChildOf: shouldVisitChildOf, + ) as TReflection?; + } + + static bool defaultShouldVisitChildOf( + ContainerReflection containerReflection) { + return containerReflection is! ListReflection && + containerReflection is! SetReflection && + containerReflection is! MapReflection; + } + + SerializationReflection? getNearestReflectionWhere( + bool Function(SerializationReflection reflection) predicate, { + bool Function(ContainerReflection reflection) shouldVisitChildOf = + defaultShouldVisitChildOf, + }) { + SerializationReflection current = this; + while (true) { + if (predicate(current)) { + return current; + } + if (current is ContainerReflection && shouldVisitChildOf(current)) { + current = current.subReflection; + continue; + } + return null; + } + } +} + +abstract class ContainerReflection extends PrimitiveReflection { + const ContainerReflection(this.subReflection); + + final SerializationReflection subReflection; +} + +class MapReflection extends ContainerReflection, T> { + const MapReflection(super.subReflection); + + @override + Equality> get equality => MapEquality( + keys: PrimitiveReflection.forString.equality, + values: subReflection.equality, + ); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is Map && + src.values + .every((v) => subReflection.canDeserializeFunction(v, context)), + onXml: (context) { + if (src is! XmlNode) { + return false; + } + final srcNormalized = src.readNormalized(); + return srcNormalized.entries + .where( + (element) => element.key != null, + ) + .every( + (element) => subReflection.canDeserializeFunction( + element.value, + context.withOasNameContainer( + OasNameWrapper(oasName: element.key!), + ), + ), + ); + }, + ); + } + + @override + Map deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => (src as Map).map((key, value) => + MapEntry(key, subReflection.deserializeFunction(value, context))), + onXml: (context) { + final srcNormalized = (src as XmlNode).readNormalized(); + return Map.fromEntries( + srcNormalized.entries + .where( + (element) => element.key != null, + ) + .map( + (e) => MapEntry( + e.key!, + subReflection.deserializeFunction( + e.value, + context + .withOasNameContainer(OasNameWrapper(oasName: e.key!)), + ), + ), + ) + .where((e) => e.value != UndefinedWrapper.$undefinedToken), + ); + }, + ); + } + + @override + Object? serialize( + Map src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) { + return Map.fromEntries( + src.entries + .where((e) => e.value != UndefinedWrapper.$undefinedToken) + .map( + (e) => MapEntry( + e.key, + subReflection.serializeFunction(e.value, context), + ), + ), + ); + }, + onXml: (context) { + final wrapped = src.entries + .where((e) => e.value != UndefinedWrapper.$undefinedToken) + .map( + (e) => MapEntry( + e.key, + subReflection.serializeFunction( + e.value, + context.withOasNameContainer(OasNameWrapper(oasName: e.key)), + ), + ), + ) + .map( + (e) => context.wrapSerializedValue( + keyReflection: null, + XmlName( + e.key, + ), + e.value, + ), + ); + + return XmlDocumentFragment(wrapped); + }, + ); + } + + @override + Map empty() => {}; + + @override + Map example([ExampleContext? context]) { + context ??= ExampleContext(); + return Map.fromEntries( + (ListReflection(subReflection).exampleFunction(context)) + .map((e) => MapEntry(const StringReflection().example(context), e)), + ); + } + + @override + Map clone(Map src) { + return Map.of(src); + } +} + +class ListReflection extends ContainerReflection, T> { + const ListReflection(super.subReflection); + @override + Equality> get equality => ListEquality(subReflection.equality); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is Iterable && + src.every((v) => subReflection.canDeserializeFunction(v, context)), + onXml: (context) => (src is XmlNode && + src.childElements.every( + (v) => subReflection.canDeserializeFunction(v, context), + )), + ); + } + + @override + List deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => (src as Iterable) + .map((value) => subReflection.deserializeFunction(value, context)) + .where((x) => x != UndefinedWrapper.$undefinedToken) + .toList(), + onXml: (context) { + final node = src as XmlNode; + final children = node.children; + return children + .map((v) => subReflection.deserializeFunction(v, context)) + .where((x) => x != UndefinedWrapper.$undefinedToken) + .toList(); + }, + ); + } + + @override + Object? serialize( + List src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final mapped = src + .where((x) => x != UndefinedWrapper.$undefinedToken) + .map((value) => subReflection.serializeFunction(value, context)); + return context.split( + onJson: (context) { + return mapped.toList(); + }, + onXml: (context) { + final xml = context.xmlContainer?.xml ?? XmlReflection(); + final listName = + xml.getQualifiedName(context.oasNameContainer?.oasName ?? 'list'); + final wrapped = mapped.map( + (e) => context.wrapSerializedValue( + keyReflection: xml, + listName, + e, + ), + ); + return XmlDocumentFragment(wrapped); + }, + ); + } + + @override + List empty() => []; + + @override + List example([ExampleContext? context]) { + context ??= ExampleContext(); + return List.generate( + context.random.nextInt(10), + (_) => subReflection.exampleFunction(context), + ); + } + + @override + List clone(Iterable src) { + return List.of(src); + } +} + +class SetReflection extends ContainerReflection, T> { + const SetReflection(super.subReflection); + + @override + Equality> get equality => SetEquality(subReflection.equality); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return ListReflection(subReflection).canDeserialize(src, context); + } + + @override + Set deserialize(Object? src, + [SerializationContext context = const SerializationContext.json()]) { + return ListReflection(subReflection).deserialize(src, context).toSet(); + } + + @override + Object? serialize( + Set src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return ListReflection(subReflection).serialize(src.toList(), context); + } + + @override + Set empty() => {}; + + @override + Set example([ExampleContext? context]) => + ListReflection(subReflection).example(context).toSet(); + + @override + Set clone(Iterable src) { + return Set.of(src); + } +} + +class NullableReflection extends ContainerReflection + implements Equality { + const NullableReflection(super.subReflection); + + @override + Equality get equality => this; + + bool isNull(Object? src, SerializationContext context) { + return context.split( + onJson: (context) => src == null, + onXml: (context) => + src == null || + // if src is a node called xsi:nil + (src is XmlHasName && + xmlNameEquals(src.name, XmlSerializationContext.nilXmlName)) || + (src is XmlNode && + ( + // if src is a node that contains xsi:nil attribute + (src + .getAttributeOrUndefinedMapped( + XmlSerializationContext.nilXmlName.local, + (value) => bool.tryParse(value.value) ?? false, + namespace: XmlSerializationContext + .nilXmlName.namespaceUri, + ) + .valueOrNull ?? + false) || + // if src is a node that contains xsi:nil element + src.childElements.any( + (element) => xmlNameEquals( + element.name, + XmlSerializationContext.nilXmlName, + ), + ))), + ); + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return isNull(src, context) || + subReflection.canDeserializeFunction(src, context); + } + + @override + T? deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return isNull(src, context) + ? null + : subReflection.deserializeFunction(src, context); + } + + @override + Object? serialize( + T? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src == null ? null : subReflection.serializeFunction(src, context); + } + + @override + T? empty() => null; + + @override + T? example([ExampleContext? context]) { + context ??= ExampleContext(); + return context.random.nextBool() + ? subReflection.exampleFunction(context) + : null; + } + + @override + bool equals(T? e1, T? e2) { + if (e1 == null || e2 == null) { + return e1 == e2; + } + return subReflection.equality.equals(e1, e2); + } + + @override + int hash(T? e) { + if (e == null) { + return null.hashCode; + } + return subReflection.equality.hash(e); + } + + @override + bool isValidKey(Object? o) { + return o == null || subReflection.equality.isValidKey(o); + } + + @override + T? clone(T? src) { + return src == null ? null : subReflection.cloneFunction(src); + } +} + +class UndefinedWrapperReflection + extends ContainerReflection, T> + implements Equality> { + const UndefinedWrapperReflection(super.subReflection); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src == UndefinedWrapper.$undefinedToken || + subReflection.canDeserializeFunction(src, context); + } + + @override + UndefinedWrapper deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src == UndefinedWrapper.$undefinedToken + ? UndefinedWrapper.undefined() + : UndefinedWrapper(subReflection.deserializeFunction(src, context)); + } + + @override + Object? serialize( + UndefinedWrapper src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return src.map( + (src) => subReflection.serializeFunction(src, context), + ); + } + + @override + UndefinedWrapper empty() => const UndefinedWrapper.undefined(); + + @override + UndefinedWrapper example([ExampleContext? context]) { + context ??= ExampleContext(); + return context.random.nextBool() + ? UndefinedWrapper(subReflection.exampleFunction(context)) + : const UndefinedWrapper.undefined(); + } + + @override + Equality> get equality => this; + + @override + bool equals(UndefinedWrapper e1, UndefinedWrapper e2) { + if (e1.isDefined && e2.isDefined) { + return subReflection.equality.equals(e1.source as T, e2.source as T); + } + return e1.isDefined == e2.isDefined; + } + + @override + int hash(UndefinedWrapper e) { + return e.split( + defined: (src) => subReflection.equality.hash(src), + unDefined: () => UndefinedWrapper.$undefinedToken.hashCode, + ); + } + + @override + bool isValidKey(Object? o) => true; + + @override + UndefinedWrapper clone(UndefinedWrapper src) { + return src.map( + (src) => subReflection.cloneFunction(src), + ); + } +} + +class XmlReflectionWrapper extends ContainerReflection + with HasXmlReflection { + const XmlReflectionWrapper( + super.subReflection, { + required this.xml, + }); + + final XmlReflection xml; + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => subReflection.canDeserializeFunction(src, context), + onXml: (context) { + if (src is MapEntry) { + return subReflection.canDeserializeFunction( + src.value, + context.withXmlContainer(this), + ); + } + return subReflection.canDeserializeFunction( + src, + context.withXmlContainer(this), + ); + }, + ); + } + + @override + T deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) { + return subReflection.deserializeFunction(src, context); + }, + onXml: (context) { + if (src is MapEntry) { + return subReflection.deserializeFunction( + src.value, + context.withXmlContainer(this), + ); + } + return subReflection.deserializeFunction( + src, + context.withXmlContainer(this), + ); + }, + ); + } + + @override + Object? serialize( + T src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => subReflection.serializeFunction(src, context), + onXml: (context) { + return MapEntry( + xml, + subReflection.serializeFunction( + src, + context.withXmlContainer(this), + ), + ); + }, + ); + } + + @override + T empty() { + return subReflection.emptyFunction(); + } + + @override + T example([ExampleContext? context]) { + return subReflection.exampleFunction(context); + } + + @override + T clone(T src) { + return subReflection.cloneFunction(src); + } + + @override + Equality get equality => subReflection.equality; +} + +class EnumReflection + extends ContainerReflection { + const EnumReflection( + super.subReflection, { + required this.members, + }); + + final List> members; + + @override + T deserialize(Object? value, + [SerializationContext context = const SerializationContext.json()]) { + final deserialized = subReflection.deserializeFunction(value); + final res = members + .where((element) => element.oasValue == deserialized) + .firstOrNull; + if (res == null) { + throw 'Invalid enum value $value'; + } + return res.value; + } + + @override + bool canDeserialize(Object? value, + [SerializationContext context = const SerializationContext.json()]) { + if (!subReflection.canDeserializeFunction(value, context)) { + return false; + } + final deserialized = subReflection.deserializeFunction(value, context); + return members.any((element) => element.oasValue == deserialized); + } + + @override + Object? serialize(T value, + [SerializationContext context = const SerializationContext.json()]) { + return subReflection.serializeFunction(value as TDataType, context); + } + + @override + T empty() { + return subReflection.emptyFunction() as T; + } + + @override + T example([ExampleContext? context]) { + context ??= ExampleContext(); + final member = members.elementAt(context.random.nextInt(members.length)); + return member.value; + } + + @override + T clone(T src) { + return subReflection.cloneFunction(src as TDataType) as T; + } +} + +class EnumMemberReflection { + const EnumMemberReflection({ + required this.dartName, + required this.oasValue, + required this.value, + }); + + final String dartName; + final TDataType oasValue; + final T value; +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/context.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/context.dart new file mode 100644 index 000000000000..076f91cbd66c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/context.dart @@ -0,0 +1,283 @@ +import 'package:petstore_api/_internal.dart'; + +enum SupportedWireTypes { + other, + json, + xml, +} + +int xmlNameHashcode(XmlName a) { + return Object.hash(a.local, a.namespaceUri, a.prefix); +} + +bool xmlNameEquals(XmlName a, XmlName b) { + return a.local == b.local && + a.namespaceUri == b.namespaceUri && + a.prefix == b.prefix; +} + +typedef SerializeReflectionResolver = SerializationReflection? Function( + Object src, +); +typedef DeserializeReflectionResolver = SerializationReflection? + Function( + Object? src, +); +typedef ValueConverterFunction = Object? Function(Object? value); +typedef ValueConverterCheckerFunction = bool Function(Object? value); +typedef FileBytesSyncResolver = Uint8List? Function(XFile file); + +/// This function is used to check if a generic type T1 can be assigned to a generic type T2. +/// +/// e.g. a value of type int can be assigned to a value of type num +/// isOfType() == true +/// but not the opposite +/// isOfType() == true +/// +/// This also works for deeply nested objects +/// isOfType>, List>>() == true +bool isOfType() { + return (_fakeFunction) is T2 Function(); +} + +TItem Function() extractIterableType, TItem>() { + return _fakeFunction; +} + +/// This function is used to check if a generic type T can accept a null value. +bool isNullableType() { + return null is T; +} + +/// This function will NEVER be called. +T _fakeFunction() { + return null as T; +} + +abstract class SerializationContext { + const SerializationContext({ + this.serializeReflectionResolver, + this.deserializeReflectionResolver, + this.fileBytesResolver, + }); + + SerializationContext copyWith({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + }); + + /// Creates a json serialization context, where the target is to output + /// types that can be passed to jsonEncode and jsonDecode. + /// + /// You can completely control the serialization and deserialization process + /// for unknown objects by passing [serializeReflectionResolver] and [deserializeReflectionResolver]. + const factory SerializationContext.json({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + }) = JsonSerializationContext; + + /// Creates an XML serialization context, where the target is to output + /// an XmlNode. + /// + /// You can completely control the serialization and deserialization process + /// for unknown objects by passing [serializeReflectionResolver] and [deserializeReflectionResolver]. + /// + /// [xmlContainer] and [oasNameContainer] are required here due to the nature + /// of XML, since serializing a value requires information about the property + /// name, namespace, prefix, wrapped, etc... + const factory SerializationContext.xml({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + HasXmlReflection? xmlContainer, + HasOasName? oasNameContainer, + }) = XmlSerializationContext; + + // used when serializing an unknown value to discover its reflection. + final SerializeReflectionResolver? serializeReflectionResolver; + // used when deserializing an unknown value to discover its reflection. + final DeserializeReflectionResolver? deserializeReflectionResolver; + + /// Try to resolve the bytes of a file synchronously, if not possible, return null. + final FileBytesSyncResolver? fileBytesResolver; + + SupportedWireTypes get wireType; + bool get isJson => wireType == SupportedWireTypes.json; + bool get isXml => wireType == SupportedWireTypes.xml; + + T split({ + required T Function(JsonSerializationContext context) onJson, + required T Function(XmlSerializationContext context) onXml, + T Function(SerializationContext context)? onOther, + }) { + return switch (this) { + JsonSerializationContext json => onJson(json), + XmlSerializationContext xml => onXml(xml), + _ => onOther == null ? throw UnimplementedError() : onOther(this), + }; + } +} + +class JsonSerializationContext extends SerializationContext { + const JsonSerializationContext({ + super.serializeReflectionResolver, + super.deserializeReflectionResolver, + super.fileBytesResolver, + }); + + @override + SupportedWireTypes get wireType => SupportedWireTypes.json; + + @override + JsonSerializationContext copyWith({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + }) => + JsonSerializationContext( + serializeReflectionResolver: + serializeReflectionResolver ?? this.serializeReflectionResolver, + deserializeReflectionResolver: + deserializeReflectionResolver ?? this.deserializeReflectionResolver, + fileBytesResolver: fileBytesResolver ?? this.fileBytesResolver, + ); +} + +class XmlSerializationContext extends SerializationContext { + const XmlSerializationContext({ + super.serializeReflectionResolver, + super.deserializeReflectionResolver, + super.fileBytesResolver, + this.xmlContainer, + this.oasNameContainer, + }); + + static final xmlnsAttribute = XmlAttribute( + XmlName("xmlns"), + 'http://www.w3.org/2001/XMLSchema', + ); + static final xsiNamespaceAttribute = XmlAttribute( + XmlName("xsi", "xmlns"), + 'http://www.w3.org/2001/XMLSchema-instance', + ); + static final nilXmlName = XmlName("nil", "xsi"); + static final nilXmlAttribute = XmlAttribute(nilXmlName, 'true'); + static final nilXmlElement = XmlElement(nilXmlName, [], [XmlText("true")]); + + @override + SupportedWireTypes get wireType => SupportedWireTypes.xml; + + final HasXmlReflection? xmlContainer; + final HasOasName? oasNameContainer; + + XmlSerializationContext withXmlContainer(HasXmlReflection? xmlContainer) { + return XmlSerializationContext( + serializeReflectionResolver: serializeReflectionResolver, + deserializeReflectionResolver: deserializeReflectionResolver, + fileBytesResolver: fileBytesResolver, + xmlContainer: xmlContainer, + oasNameContainer: oasNameContainer, + ); + } + + XmlSerializationContext withOasNameContainer(HasOasName? oasNameContainer) { + return XmlSerializationContext( + serializeReflectionResolver: serializeReflectionResolver, + deserializeReflectionResolver: deserializeReflectionResolver, + fileBytesResolver: fileBytesResolver, + xmlContainer: xmlContainer, + oasNameContainer: oasNameContainer, + ); + } + + @override + XmlSerializationContext copyWith({ + SerializeReflectionResolver? serializeReflectionResolver, + DeserializeReflectionResolver? deserializeReflectionResolver, + FileBytesSyncResolver? fileBytesResolver, + HasXmlReflection? xmlContainer, + HasOasName? oasNameContainer, + }) => + XmlSerializationContext( + serializeReflectionResolver: + serializeReflectionResolver ?? this.serializeReflectionResolver, + deserializeReflectionResolver: + deserializeReflectionResolver ?? this.deserializeReflectionResolver, + fileBytesResolver: fileBytesResolver ?? this.fileBytesResolver, + xmlContainer: xmlContainer ?? this.xmlContainer, + oasNameContainer: oasNameContainer ?? this.oasNameContainer, + ); + + + XmlNode wrapSerializedValue( + XmlName key, + Object? value, { + XmlReflection? keyReflection, + }) { + key = key.copy(); + final keyXmlns = keyReflection?.getXmlNamespaceAttribute(); + switch (value) { + case null: + return XmlElement(key, [ + XmlSerializationContext.nilXmlAttribute.copy(), + if (keyXmlns != null) keyXmlns, + ]); + case XmlNode node: + return XmlElement(key, [ + if (keyXmlns != null) keyXmlns, + ], [ + node.copy() + ]); + case MapEntry nodeEntry: + final subXml = nodeEntry.key; + var item = nodeEntry.value; + if (item is XmlNode && item.hasParent) { + item = item.copy(); + } + final itemXmlnsAttr = subXml.getXmlNamespaceAttribute() ?? keyXmlns; + final newItemName = + XmlName(subXml.xmlName ?? key.local, subXml.prefix ?? key.prefix); + + // non-wrapped lists and maps do not require returning an XML element, + // and should be returned as is. + if (item is XmlDocumentFragment) { + if (!subXml.wrapped) { + return item; + } + } + return XmlElement( + newItemName, + [ + if (item == null) + XmlSerializationContext.nilXmlAttribute.copy() + else if (item is XmlAttribute) + item, + if (itemXmlnsAttr != null) itemXmlnsAttr, + ], + [if (item is XmlNode && item is! XmlAttribute) item], + ); + default: + return XmlElement(key); + } + } + + XmlNode handleAttributes(XmlReflection xml, XmlNode node) { + if (xml.attribute) { + if (node is XmlAttribute) { + return node; + } + if (node case XmlHasName namedNode) { + return XmlAttribute( + namedNode.name.copy(), + node.value ?? node.innerText, + ); + } else { + return node; + } + } else { + return node; + } + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/examples.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/examples.dart new file mode 100644 index 000000000000..60eea4792112 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/examples.dart @@ -0,0 +1,44 @@ +import 'package:petstore_api/_internal.dart'; + +var $examplesRandom = Random(123); + +class ExampleContext { + ExampleContext({ + Random? random, + AggregatedDiscriminatorsResult? discriminators, + Map? fileCache, + Map>? + discriminatorExampleResults, + }) : discriminators = discriminators ?? {}, + fileCache = fileCache ?? {}, + discriminatorExampleResults = discriminatorExampleResults ?? {}, + random = random ?? $examplesRandom; + + final Random random; + final AggregatedDiscriminatorsResult discriminators; + final Map fileCache; + final Map> + discriminatorExampleResults; + + T exampleEnum(List values) { + return values.elementAt(random.nextInt(values.length)); + } + + int exampleCode(int min, int max) { + return random.nextInt(max - min) + min; + } + + String exampleMimeType(String pattern) { + return MediaType.parse(pattern).fillDefaults().toString(); + } + + MapEntry? exampleDiscriminator( + Map discriminatorMappings, + ) { + if (discriminatorMappings.isEmpty) { + return null; + } + final pickResult = random.nextInt(discriminatorMappings.length); + return discriminatorMappings.entries.elementAt(pickResult); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/generated_reflections.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/generated_reflections.dart new file mode 100644 index 000000000000..66e1bb7f2744 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/generated_reflections.dart @@ -0,0 +1,482 @@ +import 'package:petstore_api/_internal.dart'; +// All the model reflections that were generated. + +const generatedClassReflectionsList = >[ + + $200ResponseReflection.instance, + + $ListReflection.instance, + + $ReturnReflection.instance, + + AdditionalPropertiesClassReflection.instance, + + AllOfModelArrayAnyOfReflection.instance, + + AllOfModelArrayAnyOfAllOfAttributesReflection.instance, + + AllOfModelArrayAnyOfAllOfAttributesCReflection.instance, + + AllOfModelArrayAnyOfAllOfLinkListColumn1Reflection.instance, + + AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection.instance, + + AnimalReflection.instance, + + ApiResponseReflection.instance, + + AppleReflection.instance, + + AppleReqReflection.instance, + + ArrayAnyOfReflection.instance, + + ArrayDefaultReflection.instance, + + ArrayOfArrayOfNumberOnlyReflection.instance, + + ArrayOfInlineAllOfReflection.instance, + + ArrayOfInlineAllOfArrayAllofDogPropertyInnerReflection.instance, + + ArrayOfNumberOnlyReflection.instance, + + ArrayOneOfReflection.instance, + + ArrayTestReflection.instance, + + BananaReflection.instance, + + BananaReqReflection.instance, + + BasquePigReflection.instance, + + CapitalizationReflection.instance, + + CatReflection.instance, + + CategoryReflection.instance, + + ClassModelReflection.instance, + + ClientReflection.instance, + + ComplexQuadrilateralReflection.instance, + + DanishPigReflection.instance, + + DeprecatedObjectReflection.instance, + + DogReflection.instance, + + DrawingReflection.instance, + + EnumArraysReflection.instance, + + EnumStringDiscriminatorReflection.instance, + + EnumTestReflection.instance, + + EquilateralTriangleReflection.instance, + + FakeAnyOfWIthSameErasureGet200ResponseReflection.instance, + + FakeOneOfWIthSameErasureGet200ResponseReflection.instance, + + FileReflection.instance, + + FileSchemaTestClassReflection.instance, + + FooReflection.instance, + + FooGetDefaultResponseReflection.instance, + + FormatTestReflection.instance, + + FreeFormObjectTestClassReflection.instance, + + FreeFormObjectTestClassPropertiesReflection.instance, + + FruitReflection.instance, + + FruitReqReflection.instance, + + GmFruitReflection.instance, + + GrandparentAnimalReflection.instance, + + HasOnlyReadOnlyReflection.instance, + + HealthCheckResultReflection.instance, + + IsoscelesTriangleReflection.instance, + + MammalReflection.instance, + + MapTestReflection.instance, + + MixedPropertiesAndAdditionalPropertiesClassReflection.instance, + + MixedTypeOneOfNumberReflection.instance, + + MixedTypeOneOfObjectReflection.instance, + + MixedTypeOneOfObjectAnyOfReflection.instance, + + MixedTypeOneOfObjectAnyOf1Reflection.instance, + + MixedTypeOneOfObjectOneOfReflection.instance, + + MixedTypeOneOfObjectOneOf1Reflection.instance, + + ModelWithOneOfAnyOfPropertiesReflection.instance, + + NameReflection.instance, + + NewPetReflection.instance, + + NewPetCategoryInlineAllofReflection.instance, + + NewPetCategoryInlineAllofAllOfCategoryTagReflection.instance, + + NullableClassReflection.instance, + + NullableShapeReflection.instance, + + NumberOnlyReflection.instance, + + ObjectWithDeprecatedFieldsReflection.instance, + + OrderReflection.instance, + + OuterCompositeReflection.instance, + + ParentPetReflection.instance, + + PetReflection.instance, + + PetCompositionReflection.instance, + + PetRefReflection.instance, + + PetUsingAllOfReflection.instance, + + PetWithRequiredTagsReflection.instance, + + PetsMulticontentTestPostRequestReflection.instance, + + PetsMulticontentTestPostRequestAddressReflection.instance, + + PigReflection.instance, + + PropertyNameCollisionReflection.instance, + + QuadrilateralReflection.instance, + + QuadrilateralInterfaceReflection.instance, + + ReadOnlyFirstReflection.instance, + + ScalarReflection.instance, + + ScalarAnyOfReflection.instance, + + ScaleneTriangleReflection.instance, + + ShapeReflection.instance, + + ShapeInterfaceReflection.instance, + + ShapeOrNullReflection.instance, + + SimpleQuadrilateralReflection.instance, + + SpecialModelNameReflection.instance, + + TagReflection.instance, + + TestEndpointParametersRequestReflection.instance, + + TestEnumParametersRequestReflection.instance, + + TestInlineFreeformAdditionalPropertiesRequestReflection.instance, + + TestJsonFormDataRequestReflection.instance, + + TriangleReflection.instance, + + TriangleInterfaceReflection.instance, + + UpdatePetWithFormRequestReflection.instance, + + UploadFileRequestReflection.instance, + + UploadFileWithRequiredFileRequestReflection.instance, + + UserReflection.instance, + + ValueReflection.instance, + + VariableReflection.instance, + + WhaleReflection.instance, + + XmlItemReflection.instance, + + ZebraReflection.instance, + +]; +/// This does NOT include inline enums. +const generatedEnumReflectionsList = >[ + + EnumClass.$reflection, + + OuterEnum.$reflection, + + OuterEnumDefaultValue.$reflection, + + OuterEnumInteger.$reflection, + + OuterEnumIntegerDefaultValue.$reflection, + +]; + + +const generatedClassReflectionsMap = >{ + + r'200_response': $200ResponseReflection.instance, + + r'List': $ListReflection.instance, + + r'Return': $ReturnReflection.instance, + + r'AdditionalPropertiesClass': AdditionalPropertiesClassReflection.instance, + + r'AllOfModelArrayAnyOf': AllOfModelArrayAnyOfReflection.instance, + + r'AllOfModelArrayAnyOf_allOf_attributes': AllOfModelArrayAnyOfAllOfAttributesReflection.instance, + + r'AllOfModelArrayAnyOf_allOf_attributes_C': AllOfModelArrayAnyOfAllOfAttributesCReflection.instance, + + r'AllOfModelArrayAnyOf_allOf_linkListColumn1': AllOfModelArrayAnyOfAllOfLinkListColumn1Reflection.instance, + + r'AllOfModelArrayAnyOf_allOf_linkListColumn1_value': AllOfModelArrayAnyOfAllOfLinkListColumn1ValueReflection.instance, + + r'Animal': AnimalReflection.instance, + + r'ApiResponse': ApiResponseReflection.instance, + + r'apple': AppleReflection.instance, + + r'appleReq': AppleReqReflection.instance, + + r'ArrayAnyOf': ArrayAnyOfReflection.instance, + + r'ArrayDefault': ArrayDefaultReflection.instance, + + r'ArrayOfArrayOfNumberOnly': ArrayOfArrayOfNumberOnlyReflection.instance, + + r'ArrayOfInlineAllOf': ArrayOfInlineAllOfReflection.instance, + + r'ArrayOfInlineAllOf_array_allof_dog_property_inner': ArrayOfInlineAllOfArrayAllofDogPropertyInnerReflection.instance, + + r'ArrayOfNumberOnly': ArrayOfNumberOnlyReflection.instance, + + r'ArrayOneOf': ArrayOneOfReflection.instance, + + r'ArrayTest': ArrayTestReflection.instance, + + r'banana': BananaReflection.instance, + + r'bananaReq': BananaReqReflection.instance, + + r'BasquePig': BasquePigReflection.instance, + + r'Capitalization': CapitalizationReflection.instance, + + r'Cat': CatReflection.instance, + + r'Category': CategoryReflection.instance, + + r'ClassModel': ClassModelReflection.instance, + + r'Client': ClientReflection.instance, + + r'ComplexQuadrilateral': ComplexQuadrilateralReflection.instance, + + r'DanishPig': DanishPigReflection.instance, + + r'DeprecatedObject': DeprecatedObjectReflection.instance, + + r'Dog': DogReflection.instance, + + r'Drawing': DrawingReflection.instance, + + r'EnumArrays': EnumArraysReflection.instance, + + r'EnumStringDiscriminator': EnumStringDiscriminatorReflection.instance, + + r'Enum_Test': EnumTestReflection.instance, + + r'EquilateralTriangle': EquilateralTriangleReflection.instance, + + r'_fake_anyOfWIthSameErasure_get_200_response': FakeAnyOfWIthSameErasureGet200ResponseReflection.instance, + + r'_fake_oneOfWIthSameErasure_get_200_response': FakeOneOfWIthSameErasureGet200ResponseReflection.instance, + + r'File': FileReflection.instance, + + r'FileSchemaTestClass': FileSchemaTestClassReflection.instance, + + r'Foo': FooReflection.instance, + + r'_foo_get_default_response': FooGetDefaultResponseReflection.instance, + + r'format_test': FormatTestReflection.instance, + + r'FreeFormObjectTestClass': FreeFormObjectTestClassReflection.instance, + + r'FreeFormObjectTestClass_properties': FreeFormObjectTestClassPropertiesReflection.instance, + + r'fruit': FruitReflection.instance, + + r'fruitReq': FruitReqReflection.instance, + + r'gmFruit': GmFruitReflection.instance, + + r'GrandparentAnimal': GrandparentAnimalReflection.instance, + + r'hasOnlyReadOnly': HasOnlyReadOnlyReflection.instance, + + r'HealthCheckResult': HealthCheckResultReflection.instance, + + r'IsoscelesTriangle': IsoscelesTriangleReflection.instance, + + r'mammal': MammalReflection.instance, + + r'MapTest': MapTestReflection.instance, + + r'MixedPropertiesAndAdditionalPropertiesClass': MixedPropertiesAndAdditionalPropertiesClassReflection.instance, + + r'MixedTypeOneOfNumber': MixedTypeOneOfNumberReflection.instance, + + r'MixedTypeOneOfObject': MixedTypeOneOfObjectReflection.instance, + + r'MixedTypeOneOfObject_anyOf': MixedTypeOneOfObjectAnyOfReflection.instance, + + r'MixedTypeOneOfObject_anyOf_1': MixedTypeOneOfObjectAnyOf1Reflection.instance, + + r'MixedTypeOneOfObject_oneOf': MixedTypeOneOfObjectOneOfReflection.instance, + + r'MixedTypeOneOfObject_oneOf_1': MixedTypeOneOfObjectOneOf1Reflection.instance, + + r'ModelWithOneOfAnyOfProperties': ModelWithOneOfAnyOfPropertiesReflection.instance, + + r'Name': NameReflection.instance, + + r'NewPet': NewPetReflection.instance, + + r'NewPet_category_inline_allof': NewPetCategoryInlineAllofReflection.instance, + + r'NewPet_category_inline_allof_allOf_category_tag': NewPetCategoryInlineAllofAllOfCategoryTagReflection.instance, + + r'NullableClass': NullableClassReflection.instance, + + r'NullableShape': NullableShapeReflection.instance, + + r'NumberOnly': NumberOnlyReflection.instance, + + r'ObjectWithDeprecatedFields': ObjectWithDeprecatedFieldsReflection.instance, + + r'Order': OrderReflection.instance, + + r'OuterComposite': OuterCompositeReflection.instance, + + r'ParentPet': ParentPetReflection.instance, + + r'Pet': PetReflection.instance, + + r'PetComposition': PetCompositionReflection.instance, + + r'PetRef': PetRefReflection.instance, + + r'PetUsingAllOf': PetUsingAllOfReflection.instance, + + r'PetWithRequiredTags': PetWithRequiredTagsReflection.instance, + + r'_pets_multicontent_test_post_request': PetsMulticontentTestPostRequestReflection.instance, + + r'_pets_multicontent_test_post_request_address': PetsMulticontentTestPostRequestAddressReflection.instance, + + r'Pig': PigReflection.instance, + + r'PropertyNameCollision': PropertyNameCollisionReflection.instance, + + r'Quadrilateral': QuadrilateralReflection.instance, + + r'QuadrilateralInterface': QuadrilateralInterfaceReflection.instance, + + r'ReadOnlyFirst': ReadOnlyFirstReflection.instance, + + r'Scalar': ScalarReflection.instance, + + r'ScalarAnyOf': ScalarAnyOfReflection.instance, + + r'ScaleneTriangle': ScaleneTriangleReflection.instance, + + r'Shape': ShapeReflection.instance, + + r'ShapeInterface': ShapeInterfaceReflection.instance, + + r'ShapeOrNull': ShapeOrNullReflection.instance, + + r'SimpleQuadrilateral': SimpleQuadrilateralReflection.instance, + + r'_special_model.name_': SpecialModelNameReflection.instance, + + r'Tag': TagReflection.instance, + + r'testEndpointParameters_request': TestEndpointParametersRequestReflection.instance, + + r'testEnumParameters_request': TestEnumParametersRequestReflection.instance, + + r'testInlineFreeformAdditionalProperties_request': TestInlineFreeformAdditionalPropertiesRequestReflection.instance, + + r'testJsonFormData_request': TestJsonFormDataRequestReflection.instance, + + r'Triangle': TriangleReflection.instance, + + r'TriangleInterface': TriangleInterfaceReflection.instance, + + r'updatePetWithForm_request': UpdatePetWithFormRequestReflection.instance, + + r'uploadFile_request': UploadFileRequestReflection.instance, + + r'uploadFileWithRequiredFile_request': UploadFileWithRequiredFileRequestReflection.instance, + + r'User': UserReflection.instance, + + r'Value': ValueReflection.instance, + + r'Variable': VariableReflection.instance, + + r'whale': WhaleReflection.instance, + + r'XmlItem': XmlItemReflection.instance, + + r'zebra': ZebraReflection.instance, + +}; +const generatedEnumReflectionsMap = >{ + + r'EnumClass': EnumClass.$reflection, + + r'OuterEnum': OuterEnum.$reflection, + + r'OuterEnumDefaultValue': OuterEnumDefaultValue.$reflection, + + r'OuterEnumInteger': OuterEnumInteger.$reflection, + + r'OuterEnumIntegerDefaultValue': OuterEnumIntegerDefaultValue.$reflection, + +}; \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/json_extensions.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/json_extensions.dart new file mode 100644 index 000000000000..4de6afd8dcb3 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/json_extensions.dart @@ -0,0 +1,34 @@ +import 'package:openapi_infrastructure/openapi_infrastructure.dart'; + +extension UndefinedWrapperMapExtensions on Map { + UndefinedWrapper getOrUndefined( + TKey key, + ) { + if (!containsKey(key)) { + return UndefinedWrapper.undefined(); + } else { + return UndefinedWrapper(this[key] as TValue); + } + } + + UndefinedWrapper getOrUndefinedMapped( + TKey key, + T Function(TValue src) mapper, + ) { + return getOrUndefined(key).map(mapper); + } + + T getRequiredMapped( + TKey key, + T Function(TValue src) mapper, + ) { + if (!containsKey(key)) { + throw ArgumentError( + 'key ($key) is not present in the source Map, but it is required.', + 'key', + ); + } else { + return mapper(this[key] as TValue); + } + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/model_reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/model_reflection.dart new file mode 100644 index 000000000000..85a02539cdce --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/model_reflection.dart @@ -0,0 +1,1032 @@ +import 'package:petstore_api/_internal.dart'; + +import 'package:collection/collection.dart'; + +extension type DiscriminatorKey(String key) {} +extension type DiscriminatorValue(String key) {} + +typedef AggregatedDiscriminatorsResult + = Map>; + +abstract class ModelReflection + with + HasXmlReflection, + HasOasName, + SerializationReflection, + InheritanceBasedSerializationReflection + implements Equality { + const ModelReflection(); + + String get modelName; + + @override + String get oasName => modelName; + String get className; + XmlReflection get xml; + String? get discriminatorKey; + Map get discriminatorMappings; + Map get discriminatorImplicitMappings; + + AdditionalPropertiesPart? get additionalPropertiesPart => null; + List> get oneOfs => []; + List> get anyOfs => []; + List> get allOfs => []; + + ModelReflection? tryGetDiscriminatorModel(String? discriminatorValue) { + if (discriminatorValue == null) { + return null; + } + return discriminatorMappings[discriminatorValue] ?? + discriminatorImplicitMappings[discriminatorValue]; + } + + static final _cachedAggregatedDiscriminators = + Expando(); + + AggregatedDiscriminatorsResult get aggregatedDiscriminators { + final cached = _cachedAggregatedDiscriminators[this]; + if (cached != null) { + return cached; + } + final result = + >{}; + _aggregatedDiscriminators(this, result); + return _cachedAggregatedDiscriminators[this] = result; + } + + static void _aggregatedDiscriminators( + ModelReflection reflection, + AggregatedDiscriminatorsResult result, + ) { + if (reflection.discriminatorKey case String discriminatorKey) { + final discriminatorMapping = + result[DiscriminatorKey(discriminatorKey)] ??= {}; + discriminatorMapping.addAll( + reflection.discriminatorImplicitMappings + .map((key, value) => MapEntry(DiscriminatorValue(key), value)), + ); + discriminatorMapping.addAll( + reflection.discriminatorMappings + .map((key, value) => MapEntry(DiscriminatorValue(key), value)), + ); + } + for (final OneOfReflection( + reflection: UndefinedWrapperReflection(subReflection: classReflection) + ) in reflection.oneOfs) { + final modelReflection = classReflection.getNearestModelReflection(); + if (modelReflection == null) { + continue; + } + _aggregatedDiscriminators(modelReflection, result); + } + for (final AnyOfReflection( + reflection: UndefinedWrapperReflection(subReflection: classReflection) + ) in reflection.anyOfs) { + final modelReflection = classReflection.getNearestModelReflection(); + if (modelReflection == null) { + continue; + } + _aggregatedDiscriminators(modelReflection, result); + } + } + + /// Aggregates properties from anyof and oneof as well. + static final _cachedAggregatedProperties = + Expando>(); + + Map get aggregatedProperties { + final cached = _cachedAggregatedProperties[this]; + if (cached != null) { + return cached; + } + + final result = {}; + _aggregateProperties(this, result); + return _cachedAggregatedProperties[this] = result; + } + + static void _aggregateProperties( + ModelReflection reflection, + Map result, + ) { + // + for (var element in reflection.properties) { + result[element.oasName] = element; + } + for (var oneOf in reflection.oneOfs) { + final modelReflection = oneOf.reflection.getNearestModelReflection(); + if (modelReflection == null) { + continue; + } + _aggregateProperties(modelReflection, result); + } + for (var anyOf in reflection.anyOfs) { + final modelReflection = anyOf.reflection.getNearestModelReflection(); + if (modelReflection == null) { + continue; + } + _aggregateProperties(modelReflection, result); + } + } + + List> get parts => [ + ...oneOfs, + ...anyOfs, + ...allOfs, + ...properties, + if (additionalPropertiesPart != null) additionalPropertiesPart!, + ]; + List> get properties; + Set get knownKeys => aggregatedProperties.keys.toSet(); + + T example([ExampleContext? context]) { + context ??= ExampleContext(discriminators: aggregatedDiscriminators); + for (final MapEntry(key: propName, value: mappings) + in context.discriminators.entries) { + if (context.discriminatorExampleResults.containsKey(propName)) { + continue; + } + final r = context.exampleDiscriminator(mappings); + if (r != null) { + context.discriminatorExampleResults[propName] = r; + } + } + + final exampleResult = empty(); + for (var propPart in properties) { + var propExample = propPart.reflection.exampleFunction(context); + final preSelectedResult = + context.discriminatorExampleResults[propPart.oasName]?.key.key; + if (preSelectedResult != null) { + propExample = preSelectedResult; + } + propPart.setter(exampleResult, propExample); + } + if (additionalPropertiesPart + case AdditionalPropertiesPart( + setter: final additionalPropertiesPartSetter, + reflection: final additionalPropertiesPartReflection, + )) { + additionalPropertiesPartSetter( + exampleResult, + additionalPropertiesPartReflection.exampleFunction(context), + ); + } + for (var element in [...oneOfs, ...anyOfs]) { + element.setter( + exampleResult, element.reflection.exampleFunction(context)); + } + return exampleResult; + } + + @override + Object? serialize( + T instance, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final reflection = this; + return context.split( + onJson: (context) { + // Logic is: + // 1. Start with oneof and anyof serialization + // 2. The output of the serialization is either a Map, null or a scalar. + // 3. If it is a Map or null, then we need to add the vars from allVars + // 4. If it is a non-null value, return it. + Object? result; + // 1. Handle oneof serialization + final oneOfResult = reflection.oneOfs + .where((oneof) => oneof.getter(instance).isDefined) + .firstOrNull; + if (oneOfResult != null) { + result = oneOfResult.reflection.serializeFunction( + oneOfResult.getter(instance), + context, + ); + } + // 2. Handle anyof serialization + final anyOfResults = reflection.anyOfs + .where((anyOf) => anyOf.getter(instance).isDefined) + .toList(); + if (anyOfResults.isNotEmpty) { + final serializedAnyOfs = anyOfResults + .map( + (anyOf) => anyOf.reflection.serializeFunction!( + anyOf.getter(instance), + context, + ), + ) + .toList(); + for (var anyOf in serializedAnyOfs) { + if (anyOf is Map) { + result ??= {}; + if (result is Map) { + result.addAll(anyOf); + } else { + // Model is trying to mix scalar and non-scalar properties via anyof + } + } else { + if (result == null) { + result = anyOf; + } else { + // If the anyOfs are scalars, then we only pick the first one, since it's not possible to mix them. + } + } + } + } + result ??= {}; + // 3. Handle properties + if (result is Map) { + result = { + ...result, + // we give priority to self properties over oneOf/anyOf. + ...Map.fromEntries( + reflection.properties + .where((x) => + x.getter(instance) != UndefinedWrapper.$undefinedToken) + .map( + (x) => MapEntry( + x.oasName, + x.reflection + .serializeFunction(x.getter(instance), context), + ), + ), + ), + }; + // Put additional properties last so that users can override any existing property value. + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final additionalProperties = + additionalPropertiesPart.getter(instance); + final serializedAdditionalPropertiesEntries = additionalProperties + .entries + //ignore undefined + .where( + (e) => e.value != UndefinedWrapper.$undefinedToken, + ) + .map( + (e) => MapEntry( + e.key, + additionalPropertiesPart.itemReflection.serializeFunction!( + e.value, + context, + ), + ), + ); + result.addEntries(serializedAdditionalPropertiesEntries); + } + } + return result; + }, + onXml: (context) { + final xmlReflection = context.xmlContainer?.xml ?? reflection.xml; + // if the result of serialization outputs an XmlElement (or multiple elements), this will be its name. + final elementName = + xmlReflection.getQualifiedName(reflection.modelName); + // Logic is: + // 1. Start with oneof and anyof serialization + // 2. The output of the serialization is either a Map, null or a scalar. + // 3. If it is a Map or null, then we need to add the vars from allVars + // 4. If it is a non-null value, return it. + XmlNode? result; + // 1. Handle oneof serialization + final oneOfResult = reflection.oneOfs + .where((oneof) => oneof.getter(instance).isDefined) + .firstOrNull; + if (oneOfResult != null) { + result = oneOfResult.reflection.serializeFunction!( + oneOfResult.getter(instance), + context, + ) as XmlNode?; + } + // 2. Handle anyof serialization + final anyOfResults = reflection.anyOfs + .where((anyOf) => anyOf.getter(instance).isDefined) + .toList(); + if (anyOfResults.isNotEmpty) { + final serializedAnyOfs = anyOfResults + .map( + (anyOf) => anyOf.reflection.serializeFunction!( + anyOf.getter(instance), + context, + ), + ) + .whereType() + .toList(); + // XmlElement(elementName, [XmlAttribute(name, value)]); + for (var anyOf in serializedAnyOfs) { + if (anyOf is XmlDocumentFragment) { + result ??= XmlDocumentFragment([]); + if (result is XmlDocumentFragment) { + result.children.addAll(anyOf.children); + } else { + // Model is trying to mix scalar and non-scalar properties via anyof + } + } else { + if (result == null) { + result = anyOf; + } else { + // If the anyOfs are scalars, then we only pick the first one, since it's not possible to mix them. + } + } + } + } + result ??= XmlElement( + elementName, + [ + XmlSerializationContext.xsiNamespaceAttribute.copy(), + XmlSerializationContext.xmlnsAttribute.copy() + ], + [], + ); + // 3. Handle properties + if (result is XmlElement) { + final namespaceAttribute = xmlReflection.getXmlNamespaceAttribute(); + if (namespaceAttribute != null) { + result.attributes.add(namespaceAttribute); + } + final definedProps = reflection.properties.where( + (x) => x.getter(instance) != UndefinedWrapper.$undefinedToken, + ); + final serializedProps = Map.fromEntries(definedProps.map( + (propPart) => MapEntry( + propPart.oasName, + context.handleAttributes( + propPart.xml, + context.wrapSerializedValue( + propPart.xml.getQualifiedName(propPart.oasName), + propPart.reflection.serializeFunction( + propPart.getter(instance), + context.withOasNameContainer(propPart), + ), + ), + ), + ), + )); + + final attributesToAdd = Map.fromEntries( + serializedProps.entries + .where( + (element) => element.value is XmlAttribute, + ) + .map( + (e) => MapEntry(e.key, e.value as XmlAttribute), + ), + ); + final childrenToAdd = Map.fromEntries( + serializedProps.entries.where( + (element) => element.value is! XmlAttribute, + ), + ); + + // Put additional properties last so that users can override any existing property value. + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final additionalProperties = + additionalPropertiesPart.getter(instance); + final serializedAdditionalPropertiesEntries = Map.fromEntries( + additionalProperties.entries + .where( + (e) => e.value != UndefinedWrapper.$undefinedToken, + ) + .map( + (e) => MapEntry( + e.key, + context.handleAttributes( + additionalPropertiesPart.xml, + context.wrapSerializedValue( + additionalPropertiesPart.xml.getQualifiedName(e.key), + additionalPropertiesPart + .itemReflection.serializeFunction!( + e.value, + context.withOasNameContainer( + OasNameWrapper(oasName: e.key), + ), + ), + ), + ), + ), + ), + ); + attributesToAdd.addEntries( + serializedAdditionalPropertiesEntries.entries + .where((e) => e.value is XmlAttribute) + .cast>(), + ); + childrenToAdd.addEntries( + serializedAdditionalPropertiesEntries.entries + .where((e) => e.value is! XmlAttribute), + ); + } + result.children.addAll(childrenToAdd.values.map((e) => e.copy())); + result.attributes.addAll(attributesToAdd.values.map((e) => e.copy())); + } + return result; + }, + ); + } + + @override + T deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final reflection = this; + return context.split( + onJson: (context) { + final result = reflection.empty(); + final discriminatorKey = reflection.discriminatorKey; + ModelReflection? discriminatedReflection; + if (src is Map) { + final discriminatorValue = discriminatorKey == null + ? null + : src[discriminatorKey]?.toString(); + discriminatedReflection = discriminatorValue == null + ? null + : reflection.tryGetDiscriminatorModel(discriminatorValue); + for (final prop in reflection.properties) { + final value = src.getOrUndefined(prop.oasName); + + prop.setter( + result, + prop.reflection.deserializeFunction( + value, + context, + ), + ); + } + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + additionalPropertiesPart.setter( + result, + src.except(reflection.knownKeys).map( + (key, v) => MapEntry( + key, + additionalPropertiesPart + .itemReflection.deserializeFunction!(v, context), + ), + ), + ); + } + } + final selectedOneOf = reflection.oneOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + if (selectedOneOf != null) { + selectedOneOf.setter( + result, + selectedOneOf.reflection.deserializeFunction!(src, context), + ); + } else { + for (var element in reflection.oneOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + element.setter( + result, + element.reflection.deserializeFunction!(src, context), + ); + } + } + } + + final selectedAnyOf = reflection.anyOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + + if (selectedAnyOf != null) { + selectedAnyOf.setter( + result, + selectedAnyOf.reflection.deserializeFunction!(src, context), + ); + } else { + for (var element in reflection.anyOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + element.setter( + result, + element.reflection.deserializeFunction!(src, context), + ); + } + } + } + return result; + }, + onXml: (context) { + if (src is! XmlNode) { + throw UnimplementedError('Can only deserialize xml nodes'); + } + final result = reflection.empty(); + final discriminatorKey = reflection.discriminatorKey; + final discriminatorName = discriminatorKey == null + ? null + : XmlName.fromString(discriminatorKey); + XmlNode? discriminatorValue; + + final srcNormalized = src.readNormalized(); + + discriminatorValue = + discriminatorName == null ? null : srcNormalized[discriminatorName]; + final discriminatedReflection = + reflection.tryGetDiscriminatorModel(discriminatorValue?.value); + + for (final property in reflection.properties) { + final propertyName = property.xml.getQualifiedName(property.oasName); + final rawNode = srcNormalized.getOrUndefined(propertyName.qualified); + if (property.required && !rawNode.isDefined) { + throwArgumentRequired(propertyName.qualified); + } + if (rawNode.isUndefined) { + //skip non-required undefined properties + continue; + } + + final node = rawNode.valueRequired; + if (property.xml.attribute) { + if (node is! XmlAttribute) { + throw ArgumentError( + 'Trying to deserialize an XML attribute, but instead found a (${node.nodeType}).', + ); + } + } + final propContext = context.withOasNameContainer(property); + if (property.reflection.canDeserializeFunction(node, propContext)) { + final propertyValue = property.reflection.deserializeFunction( + node, + propContext, + ); + property.setter(result, propertyValue); + } else { + throw UnsupportedError( + 'Not possible to deserialize the property ${property.oasName}', + ); + } + } + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final additionalProperties = + additionalPropertiesPart.reflection.emptyFunction(); + final knownKeys = reflection.properties + .map((e) => e.xml.getQualifiedName(e.oasName)) + .toSet(); + for (final MapEntry(key: keyRaw, value: node) + in srcNormalized.entries) { + if (keyRaw == null) { + continue; + } + if (knownKeys.contains(keyRaw)) { + continue; + } + final key = XmlName.fromString(keyRaw); + + if (key.prefix != additionalPropertiesPart.xml.prefix) { + continue; + } + if (additionalPropertiesPart.xml.prefix != null && + additionalPropertiesPart.xml.namespace != null) { + if (key.namespaceUri != additionalPropertiesPart.xml.namespace) { + // skip if the namespace is not correct + continue; + } + } + + additionalProperties[key.local] = + additionalPropertiesPart.itemReflection.deserializeFunction!( + node, + context.withOasNameContainer( + OasNameWrapper(oasName: key.local), + ), + ); + } + additionalPropertiesPart.setter(result, additionalProperties); + } + + final selectedOneOf = reflection.oneOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + if (selectedOneOf != null) { + selectedOneOf.setter( + result, + selectedOneOf.reflection.deserializeFunction!(src, context), + ); + } else { + for (var element in reflection.oneOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + element.setter(result, + element.reflection.deserializeFunction!(src, context)); + } + } + } + + final selectedAnyOf = reflection.anyOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + + if (selectedAnyOf != null) { + selectedAnyOf.setter( + result, + selectedAnyOf.reflection.deserializeFunction!(src, context), + ); + } else { + for (var element in reflection.anyOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + element.setter(result, + element.reflection.deserializeFunction!(src, context)); + } + } + } + return result; + }, + ); + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final reflection = this; + return context.split( + onJson: (context) { + final discriminatorKey = reflection.discriminatorKey; + Object? discriminatorValue; + ModelReflection? discriminatedReflection; + + if (src is Map) { + discriminatorValue = + discriminatorKey == null ? null : src[discriminatorKey]; + discriminatedReflection = reflection + .tryGetDiscriminatorModel(discriminatorValue?.toString()); + + for (final propPart in reflection.properties) { + final value = src.getOrUndefined(propPart.oasName); + if (value.isUndefined && propPart.required) { + return false; + } + if (!propPart.reflection.canDeserializeFunction!( + value, + context, + )) { + return false; + } + } + if (reflection.additionalPropertiesPart != null) { + final additionalProps = src.except(reflection.knownKeys); + final badEntries = additionalProps.entries.where( + (e) => !reflection.additionalPropertiesPart!.itemReflection + .canDeserializeFunction!(e.value, context), + ); + if (badEntries.isNotEmpty) { + return false; + } + } + } else { + if (reflection.properties.any((e) => e.required)) { + return false; + } + } + + final selectedOneOf = discriminatedReflection == null + ? null + : reflection.oneOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + if (selectedOneOf != null) { + if (!selectedOneOf.reflection.canDeserializeFunction!(src, context)) { + return false; + } + } else { + int counter = 0; + for (var element in reflection.oneOfs) { + if (element.reflection.canDeserializeFunction!(src, context)) { + counter++; + } + } + if (counter > 1) { + return false; + } + } + + return true; + }, + onXml: (context) { + if (src is! XmlNode) { + return false; + } + + final discriminatorKey = reflection.discriminatorKey; + final discriminatorName = discriminatorKey == null + ? null + : XmlName.fromString(discriminatorKey); + XmlNode? discriminatorValue; + // step 1: prepare the src object by grouping it into a srcMap where the key + // is the fully qualified name of the node and the value is a list of nodes + // or attributes with the same name. + final srcNormalized = src.readNormalized(); + discriminatorValue = discriminatorName == null + ? null + : srcNormalized[discriminatorName.qualified]; + final discriminatedReflection = + reflection.tryGetDiscriminatorModel(discriminatorValue?.value); + for (final property in reflection.properties) { + final propertyName = property.xml.getQualifiedName(property.oasName); + final rawNode = srcNormalized.getOrUndefined(propertyName.qualified); + if (property.required && !rawNode.isDefined) { + return false; + } + if (rawNode.isUndefined) { + //skip non-required undefined properties + continue; + } + + final node = rawNode.valueRequired; + if (property.xml.attribute) { + if (node is! XmlAttribute) { + return false; + } + } + if (!property.reflection.canDeserializeFunction( + node, + context.withOasNameContainer(property), + )) { + return false; + } + } + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final knownKeys = reflection.properties + .map((e) => e.xml.getQualifiedName(e.oasName).qualified) + .toSet(); + for (final MapEntry(key: keyRaw, value: node) + in srcNormalized.entries) { + if (keyRaw == null) { + continue; + } + if (knownKeys.contains(keyRaw)) { + continue; + } + final key = XmlName.fromString(keyRaw); + + if (key.prefix != additionalPropertiesPart.xml.prefix) { + continue; + } + if (additionalPropertiesPart.xml.prefix != null && + additionalPropertiesPart.xml.namespace != null) { + if (key.namespaceUri != additionalPropertiesPart.xml.namespace) { + // skip if the namespace is not correct + continue; + } + } + + if (!additionalPropertiesPart + .itemReflection.canDeserializeFunction!( + node, + context.withOasNameContainer( + OasNameWrapper(oasName: key.local), + ), + )) { + return false; + } + } + } + + final selectedOneOf = reflection.oneOfs.firstWhereOrNull( + (element) => element.reflection == discriminatedReflection, + ); + if (selectedOneOf != null) { + if (!selectedOneOf.reflection.canDeserializeFunction!(src, context)) { + return false; + } + } else { + int counter = 0; + for (var element in reflection.oneOfs) { + if (element.reflection.canDeserializeFunction(src, context)) { + counter++; + } + } + if (counter > 1) { + return false; + } + } + + return true; + }, + ); + } + + @override + int hash(T e) { + const propEq = MapEquality( + keys: const StrictEquality(), + values: const StrictEquality(), + ); + + final toHash = {}; + + toHash.addEntries(properties.map( + (prop) => + MapEntry(prop.oasName, prop.reflection.equality.hash(prop.getter(e))), + )); + + int additionalPropsHash = 0; + final additionalPropertiesPart = this.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final additionalProps = additionalPropertiesPart.getter(e); + additionalPropsHash = + additionalPropertiesPart.reflection.equality.hash(additionalProps); + } + + final oneOfsHash = Object.hashAll( + this.oneOfs.map((o) => o.reflection.equality.hash(o.getter(e))), + ); + final anyOfsHash = Object.hashAll( + this.anyOfs.map((o) => o.reflection.equality.hash(o.getter(e))), + ); + return Object.hash( + // include model name in the hash + this.oasName, + propEq.hash(toHash), + additionalPropsHash, + oneOfsHash, + anyOfsHash, + ); + } + + @override + bool equals(T e1, T e2) { + for (final prop in properties) { + final e1Value = prop.getter(e1); + final e2Value = prop.getter(e2); + final eq = prop.reflection.equality; + if (!eq.equals(e1Value, e2Value)) { + return false; + } + } + final additionalPropertiesPart = this.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final e1Additional = additionalPropertiesPart.getter(e1); + final e2Additional = additionalPropertiesPart.getter(e2); + if (!additionalPropertiesPart.reflection.equality + .equals(e1Additional, e2Additional)) { + return false; + } + } + for (var oneof in oneOfs) { + final e1Value = oneof.getter(e1); + final e2Value = oneof.getter(e2); + if (!oneof.reflection.equality.equals(e1Value, e2Value)) { + return false; + } + } + for (var anyof in anyOfs) { + final e1Value = anyof.getter(e1); + final e2Value = anyof.getter(e2); + if (!anyof.reflection.equality.equals(e1Value, e2Value)) { + return false; + } + } + return true; + } + + @override + bool isValidKey(Object? o) { + return o is T; + } + + @override + T clone(T src) { + final res = empty(); + for (var props in properties) { + props.setter(res, props.reflection.cloneFunction(props.getter(src))); + } + for (var oneOf in oneOfs) { + oneOf.setter(res, oneOf.reflection.cloneFunction(oneOf.getter(src))); + } + for (var anyOf in anyOfs) { + anyOf.setter(res, anyOf.reflection.cloneFunction(anyOf.getter(src))); + } + final additionalPropertiesPart = this.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + additionalPropertiesPart.setter( + res, + additionalPropertiesPart.reflection + .cloneFunction(additionalPropertiesPart.getter(src)), + ); + } + return res; + } +} + +mixin PartReflectionMixin { + SerializationReflection get reflection; + ModelReflection Function() get parentReflectionGetter; + + FunctionWrapper1 get getter; + FunctionWrapper2 get setter; +} + +abstract class PartReflection + with PartReflectionMixin { + const PartReflection({ + required this.parentReflectionGetter, + }); + + final ModelReflection Function() parentReflectionGetter; +} + +class PropertyReflection + extends PartReflection with HasXmlReflection, HasOasName { + const PropertyReflection({ + required this.dartName, + required this.oasName, + required this.oasType, + required this.required, + required this.nullable, + required this.reflection, + required super.parentReflectionGetter, + this.$default, + this.pattern, + this.xml = const XmlReflection(), + required this.getter, + required this.setter, + required this.isDiscriminator, + }); + + @override + final SerializationReflection reflection; + + @override + final XmlReflection xml; + final String dartName; + @override + final String oasName; + final String oasType; + final bool required; + final bool nullable; + final Object? $default; + final String? pattern; + + @override + final FunctionWrapper1 getter; + @override + final FunctionWrapper2 setter; + final bool isDiscriminator; +} + +class AdditionalPropertiesPart + extends PartReflection> with HasXmlReflection { + const AdditionalPropertiesPart({ + required this.getter, + required this.setter, + required super.parentReflectionGetter, + required this.itemReflection, + this.xml = const XmlReflection(), + }); + + final SerializationReflection itemReflection; + + @override + SerializationReflection> get reflection => + MapReflection(itemReflection); + + final XmlReflection xml; + @override + final FunctionWrapper1, TParent> getter; + @override + final FunctionWrapper2> setter; +} + +abstract class OneOfReflection + extends PartReflection> { + const OneOfReflection({ + required super.parentReflectionGetter, + }); + + @override + UndefinedWrapperReflection get reflection; +} + +abstract class AnyOfReflection + extends PartReflection> { + const AnyOfReflection({ + required super.parentReflectionGetter, + }); + + @override + UndefinedWrapperReflection get reflection; +} + +class AllOfReflection + with PartReflectionMixin { + const AllOfReflection({ + required this.parentReflectionGetter, + required ModelReflection this.reflection, + }); + @override + final ModelReflection reflection; + final ModelReflection Function() parentReflectionGetter; + + @override + FunctionWrapper1 get getter => + FunctionWrapper1((TParent src) => src); + + @override + FunctionWrapper2 get setter => + FunctionWrapper2((a, b) => null); +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/open_api_object.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/open_api_object.dart new file mode 100644 index 000000000000..639487e1c66e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/open_api_object.dart @@ -0,0 +1,23 @@ +import 'package:petstore_api/_internal.dart'; + +/// A marker mixin to be the base class for all openapi schemas of type `object` or schemas containing `oneof`, `anyof`. +/// +/// Where an `object` is a value that can be serialized/deserialized from a json map. +/// +/// Every openapi object MUST implement `$classReflection`, and optionally implement validate. +mixin $OpenApiObjectMixin { + @mustCallSuper + bool validate() => true; + + ModelReflection get $classReflection; + + @override + bool operator ==(Object other) { + return identical(this, other) || + ($classReflection.isValidKey(other) && + $classReflection.equals(this, other)); + } + + @override + int get hashCode => $classReflection.hash(this); +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/parameter_serialization.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/parameter_serialization.dart new file mode 100644 index 000000000000..6e93a9080a9f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/parameter_serialization.dart @@ -0,0 +1,257 @@ +import 'package:std_uritemplate/std_uritemplate.dart'; + +abstract class OpenApiParameterSerialization { + final bool explode; + final String parameterName; + + const OpenApiParameterSerialization({ + required this.parameterName, + required this.explode, + }); + + String get appendExplode => explode ? '*' : ''; + + String get oldParameterPlaceHolder => '{$parameterName}'; +} + +// in: path ------------------ + +abstract class OpenApiParameterSerializationPath + extends OpenApiParameterSerialization { + const OpenApiParameterSerializationPath({ + required super.explode, + required super.parameterName, + }); + + String modifyTemplateToRFC6570(String template); + + String expand(String template, Object? value) { + final modified = modifyTemplateToRFC6570(template); + return StdUriTemplate.expand(modified, { + parameterName: value, + }); + } + + factory OpenApiParameterSerializationPath.fromStyle(String style, { + required bool explode, + required String parameterName, + }) { + return switch (style) { + 'simple' => OpenApiParameterSerializationPathSimple(parameterName: parameterName, explode: explode), + 'label' => OpenApiParameterSerializationPathLabel(parameterName: parameterName, explode: explode), + 'matrix' => OpenApiParameterSerializationPathMatrix(parameterName: parameterName, explode: explode), + _ => throw UnimplementedError('Invalid style value for path.') + }; + } +} + +class OpenApiParameterSerializationPathSimple + extends OpenApiParameterSerializationPath { + const OpenApiParameterSerializationPathSimple({ + required super.explode, + required super.parameterName, + }); + + @override + String modifyTemplateToRFC6570(String template) { + return template.replaceAll( + oldParameterPlaceHolder, + '{$parameterName$appendExplode}', + ); + } +} + +class OpenApiParameterSerializationPathLabel + extends OpenApiParameterSerializationPath { + const OpenApiParameterSerializationPathLabel({ + required super.explode, + required super.parameterName, + }); + + @override + String modifyTemplateToRFC6570(String template) { + return template.replaceAll( + oldParameterPlaceHolder, + '{.$parameterName$appendExplode}', + ); + } +} + +class OpenApiParameterSerializationPathMatrix + extends OpenApiParameterSerializationPath { + const OpenApiParameterSerializationPathMatrix({ + required super.explode, + required super.parameterName, + }); + + @override + String modifyTemplateToRFC6570(String template) { + return template.replaceAll( + oldParameterPlaceHolder, + '{;$parameterName$appendExplode}', + ); + } +} + +// in: query ------------------ + +abstract class OpenApiParameterSerializationQuery + extends OpenApiParameterSerialization { + const OpenApiParameterSerializationQuery({ + required super.explode, + required super.parameterName, + required this.allowEmptyValue, + }); + + factory OpenApiParameterSerializationQuery.fromStyle(String style, { + required bool explode, + required String parameterName, + required bool allowEmptyValue, + }) { + return switch (style) { + 'form' => OpenApiParameterSerializationQueryForm(parameterName: parameterName, explode: explode, allowEmptyValue: allowEmptyValue), + 'spaceDelimited' => OpenApiParameterSerializationQuerySpaceDelimited(parameterName: parameterName, explode: explode, allowEmptyValue: allowEmptyValue), + 'pipeDelimited' => OpenApiParameterSerializationQueryPipeDelimited(parameterName: parameterName, explode: explode, allowEmptyValue: allowEmptyValue), + 'deepObject' => OpenApiParameterSerializationQueryDeepObject(parameterName: parameterName, explode: explode, allowEmptyValue: allowEmptyValue), + _ => throw UnimplementedError('Invalid style value for path.') + }; + } + + final bool allowEmptyValue; + + /// The templates passed here are valid [Uri]s missing query parameters + Uri expandUri(Uri template, Object? value) { + if ((value == null || + (value is String && value.isEmpty) || + (value is Iterable && value.isEmpty)) && + !allowEmptyValue) { + return template; + } + + final key = Uri.encodeComponent(parameterName); + var expanded = StdUriTemplate.expand('{?$key$appendExplode}', { + key: value, + }); + if (expanded.startsWith('?')) { + expanded = expanded.substring(1); + } + final uriWithExpanded = Uri(query: expanded); + + return template.replace(queryParameters: { + ...template.queryParameters, + ...uriWithExpanded.queryParameters, + }); + } +} + +// Default behavior is the same as [OpenApiParameterSerializationQuery]. +class OpenApiParameterSerializationQueryForm + extends OpenApiParameterSerializationQuery { + const OpenApiParameterSerializationQueryForm({ + required super.explode, + required super.parameterName, + required super.allowEmptyValue, + }); +} + +class OpenApiParameterSerializationQuerySpaceDelimited + extends OpenApiParameterSerializationQuery { + const OpenApiParameterSerializationQuerySpaceDelimited({ + required super.explode, + required super.parameterName, + required super.allowEmptyValue, + }); + + @override + Uri expandUri( + Uri template, + Object? value, + ) { + if (value is Iterable) { + value = value.join(' '); + } + + return super.expandUri(template, value); + } +} + +class OpenApiParameterSerializationQueryPipeDelimited + extends OpenApiParameterSerializationQuery { + const OpenApiParameterSerializationQueryPipeDelimited({ + required super.explode, + required super.parameterName, + required super.allowEmptyValue, + }); + + @override + Uri expandUri( + Uri template, + Object? value, + ) { + if (value is Iterable) { + value = value.join('|'); + } + + return super.expandUri(template, value); + } +} + +class OpenApiParameterSerializationQueryDeepObject + extends OpenApiParameterSerializationQuery { + const OpenApiParameterSerializationQueryDeepObject({ + required super.explode, + required super.parameterName, + required super.allowEmptyValue, + }); + + @override + Uri expandUri( + Uri template, + Object? value, + ) { + if (value is Map) { + return template.replace(queryParameters: { + ...template.queryParameters, + ...value.map( + (key, v) => MapEntry('$parameterName[$key]', v), + ), + }); + } + return super.expandUri(template, value); + } +} + +// in: header ------------------ + +class OpenApiParameterSerializationHeader + extends OpenApiParameterSerialization { + const OpenApiParameterSerializationHeader({ + required super.explode, + required super.parameterName, + }); + + //Style is always "simple" + String serialize(Object? value) { + return StdUriTemplate.expand('{v$appendExplode}', { + 'v': value, + }); + } +} + +// in: cookie ------------------ + +/// WARNING: this is not properly implemented. +/// see https://github.com/OAI/OpenAPI-Specification/issues/2940 +class OpenApiParameterSerializationCookie + extends OpenApiParameterSerialization { + const OpenApiParameterSerializationCookie({ + required super.explode, + required super.parameterName, + }); + + String serialize(Object? value) { + return StdUriTemplate.expand('{$parameterName$appendExplode}', { + parameterName: value, + }); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/primitive_reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/primitive_reflection.dart new file mode 100644 index 000000000000..9963b6a74adf --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/primitive_reflection.dart @@ -0,0 +1,744 @@ +import 'package:petstore_api/_internal.dart'; + +import 'package:collection/collection.dart'; + +abstract class PrimitiveReflection + with + SerializationReflection, + InheritanceBasedSerializationReflection { + const PrimitiveReflection(); + + static const fornum = NumReflection(); + static const forint = IntReflection(); + static const fordouble = DoubleReflection(); + static const forbool = BoolReflection(); + static const forString = StringReflection(); + static const forUint8List = Uint8ListReflection(); + static const forDateTime = DateTimeReflection(); + static const forXFile = XFileReflection(); + static const forObject = ObjectReflection(); + static const for$FreeFormObject = $FreeFormObjectReflection; +} + +class ObjectReflection extends PrimitiveReflection + implements Equality { + const ObjectReflection(); + static const basicReflections = >[ + PrimitiveReflection.fornum, + PrimitiveReflection.forbool, + PrimitiveReflection.forDateTime, + ListReflection(NullableReflection(PrimitiveReflection.forObject)), + MapReflection(NullableReflection(PrimitiveReflection.forObject)), + PrimitiveReflection.forString, + ]; + static const aggregatedReflections = [ + ...basicReflections, + ...generatedClassReflectionsList, + ]; + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src == null) { + // It's impossible to know the reflection of a null object. + return false; + } + final reflection = context.deserializeReflectionResolver?.call(src); + if (reflection != null) { + return reflection.canDeserializeFunction(src, context); + } + // If deserialization fails we just return the object itself + return true; + } + + @override + Object deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src == null) { + throw ArgumentError.notNull('src'); + } + var subReflection = context.deserializeReflectionResolver?.call(src) ?? + basicReflections + .firstWhereOrNull((x) => x.canDeserializeFunction(src, context)); + if (subReflection == null) { + //return it as is. + return src; + } + return subReflection.deserializeFunction(src, context); + } + + /// Attempts to discover the reflection of a given input that was received in + /// either [deserialize] or [canDeserialize]. + /// + /// It first asks the context if it has a result by calling [SerializationContext.deserializeReflectionResolver]. + /// + /// If it fails, it iteratively checks every item in [basicReflections], and + /// calls [canDeserialize] on each of them, until a reflection returns true. + static SerializationReflection? discoverDeserializeReflection( + Object? src, + SerializationContext context, + ) { + final resolvedResult = context.deserializeReflectionResolver?.call(src); + if (resolvedResult != null) { + return resolvedResult; + } + + return basicReflections + .firstWhereOrNull((x) => x.canDeserializeFunction(src)); + } + + /// It checks if the src object is a [ReflectionOverrideWrapper], and returns its + /// reflection. + /// + /// If it fails, it checks if the src object implements [$OpenApiObjectMixin], + /// and returns its reflection via [$OpenApiObjectMixin.$classReflection]. + /// + /// If it fails, it iteratively checks every item in [aggregatedReflections], and + /// calls [isInstanceOfType] on each of them, until a reflection returns true. + static SerializationReflection? discoverDartObjectReflection( + Object src, + ) { + if (src is ReflectionOverrideWrapper) { + return src.reflection; + } + if (src is $OpenApiObjectMixin) { + return src.$classReflection; + } + + return basicReflections.firstWhereOrNull((x) => x.isInstanceOfType(src)); + } + + /// Attempts to discover the reflection of a given input that was received in + /// a [serialize] call. + /// + /// It first asks the context if it has a result by calling [SerializationContext.serializeReflectionResolver]. + /// + /// If it fails, it checks if the src object implements [$OpenApiObjectMixin], + /// and returns its reflection via [$OpenApiObjectMixin.$classReflection]. + /// + /// If it fails, it iteratively checks every item in [aggregatedReflections], and + /// calls [isInstanceOfType] on each of them, until a reflection returns true. + static SerializationReflection? discoverSerializeReflection( + Object src, + SerializationContext context, + ) { + final resolvedResult = context.serializeReflectionResolver?.call(src); + if (resolvedResult != null) { + return resolvedResult; + } + return discoverDartObjectReflection(src); + } + + @override + Object? serialize( + Object src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final subReflection = discoverSerializeReflection(src, context); + if (subReflection == null) { + //return it as is. + return src; + } + return subReflection.serializeFunction(src, context); + } + + // aggregate primitive equalities. + static final _slowEquality = MultiEquality( + basicReflections.map((e) => e.equality).toList(growable: false), + ); + + @override + Equality get equality => this; + + @override + Object empty() => 0; + + @override + Object example([ExampleContext? context]) { + context ??= ExampleContext(); + final selectedReflectionIndex = + context.random.nextInt(basicReflections.length); + return basicReflections[selectedReflectionIndex].exampleFunction(context); + } + + @override + bool equals(Object e1, Object e2) { + // attempt naïve equality by checking == operator. + // + // this will work on generated models and ReflectionOverrideWrapper, + // but won't work on some primitives like XFile, Uint8List. + // + // which is why we need to check other cases as well. + if (e1 == e2) { + return true; + } + // extract the true value if ReflectionOverrideWrapper is used. + final trueE1 = e1 is ReflectionOverrideWrapper ? e1.value : e1; + final trueE2 = e2 is ReflectionOverrideWrapper ? e2.value : e2; + // attempt to extract reflection if provided via ReflectionOverrideWrapper. + final e1Reflection = discoverDartObjectReflection(e1); + final e2Reflection = discoverDartObjectReflection(e2); + // two objects are equal if any of the discovered reflections say that they are equal. + if (e1Reflection != null) { + final e1Eq = e1Reflection.equality; + return e1Eq.isValidKey(trueE1) && + e1Eq.isValidKey(trueE2) && + e1Eq.equals(trueE1, trueE2); + } + if (e2Reflection != null) { + final e2Eq = e2Reflection.equality; + return e2Eq.isValidKey(trueE1) && + e2Eq.isValidKey(trueE2) && + e2Eq.equals(trueE1, trueE2); + } + // if no reflection was discovered, use the iterative equality. + return _slowEquality.equals(e1, e2); + } + + @override + int hash(Object e) { + final discoveredReflection = discoverDartObjectReflection(e); + if (discoveredReflection != null) { + return discoveredReflection.equality.hash(e); + } + return e.hashCode; + } + + @override + bool isValidKey(Object? o) { + // any non-null object works. + return o != null; + } + + @override + Object clone(Object src) { + final discoveredReflection = discoverDartObjectReflection(src); + if (discoveredReflection != null) { + return discoveredReflection.cloneFunction(src) as Object; + } + return src; + } +} + +class NumReflection extends PrimitiveReflection { + const NumReflection(); + + @override + num clone(num src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is num || + (const StringReflection().canDeserialize(src, context) && + num.tryParse( + const StringReflection().deserialize(src, context)) != + null), + onXml: (context) => + const StringReflection().canDeserialize(src, context) && + num.tryParse(const StringReflection().deserialize(src, context)) != + null, + ); + } + + @override + num deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src is num + ? src + : num.parse(const StringReflection().deserialize(src, context)), + onXml: (context) => + num.parse(const StringReflection().deserialize(src, context)), + ); + } + + @override + Object? serialize( + num src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src, + onXml: (context) => + PrimitiveReflection.forString.serialize(src.toString(), context), + ); + } + + @override + num empty() => 0; + + @override + num example([ExampleContext? context]) { + return (context ??= ExampleContext()).random.nextDouble(); + } +} + +class IntReflection extends PrimitiveReflection { + const IntReflection(); + + @override + int clone(int src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is int || + (const StringReflection().canDeserialize(src, context) && + int.tryParse( + const StringReflection().deserialize(src, context)) != + null), + onXml: (context) => + const StringReflection().canDeserialize(src, context) && + int.tryParse(const StringReflection().deserialize(src, context)) != + null, + ); + } + + @override + int deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src is int + ? src + : int.parse(const StringReflection().deserialize(src, context)), + onXml: (context) => + int.parse(const StringReflection().deserialize(src, context)), + ); + } + + @override + Object? serialize( + int src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src, + onXml: (context) => + PrimitiveReflection.forString.serialize(src.toString(), context), + ); + } + + @override + int empty() => 0; + + @override + int example([ExampleContext? context]) => + (context ??= ExampleContext()).random.nextInt(100); +} + +class DoubleReflection extends PrimitiveReflection { + const DoubleReflection(); + @override + double clone(double src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return const NumReflection().canDeserialize(src, context); + } + + @override + double deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return const NumReflection().deserialize(src, context).toDouble(); + } + + @override + Object? serialize( + double src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return PrimitiveReflection.fornum.serialize(src, context); + } + + @override + double empty() => 0; + + @override + double example([ExampleContext? context]) => + (context ??= ExampleContext()).random.nextDouble(); +} + +class StringReflection extends PrimitiveReflection { + const StringReflection(); + @override + String clone(String src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => true, + onXml: (context) => src is XmlNode, + ); + } + + @override + String deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src.toString(), + onXml: (context) => (src as XmlNode).value ?? src.innerText, + ); + } + + @override + Object? serialize( + String src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src, + onXml: (context) => XmlText(src), + ); + } + + @override + String empty() => ""; + + @override + String example([ExampleContext? context]) => + 'random_string_${(context ??= ExampleContext()).random.nextInt(100)}'; +} + +class BoolReflection extends PrimitiveReflection { + const BoolReflection(); + @override + bool clone(bool src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => + src is bool || + (PrimitiveReflection.forString.canDeserialize(src, context) && + bool.tryParse(PrimitiveReflection.forString + .deserialize(src, context)) != + null), + onXml: (context) => + PrimitiveReflection.forString.canDeserialize(src, context) && + bool.tryParse( + PrimitiveReflection.forString.deserialize(src, context)) != + null, + ); + } + + @override + bool deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src is bool + ? src + : bool.parse(PrimitiveReflection.forString.deserialize(src, context)), + onXml: (context) => + bool.parse(PrimitiveReflection.forString.deserialize(src, context)), + ); + } + + @override + Object? serialize( + bool src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src, + onXml: (context) => + PrimitiveReflection.forString.serialize(src.toString(), context), + ); + } + + @override + bool empty() => false; + + @override + bool example([ExampleContext? context]) => + (context ??= ExampleContext()).random.nextBool(); +} + +class Uint8ListEquality extends StrictEquality { + const Uint8ListEquality(); + + static const subEq = ListEquality(StrictEquality()); + + @override + bool equals(Uint8List e1, Uint8List e2) { + return subEq.equals(e1, e2); + } + + @override + int hash(Uint8List e) { + return subEq.hash(e); + } + + @override + bool isValidKey(Object? o) { + return subEq.isValidKey(o); + } +} + +class Uint8ListReflection extends PrimitiveReflection { + const Uint8ListReflection(); + @override + Uint8List clone(Uint8List src) { + return Uint8List.fromList(src); + } + + static bool isBase64String(String src) { + final regex = RegExp( + r'^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$', + ); + return regex.hasMatch(src); + } + + @override + Equality get equality => const Uint8ListEquality(); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + // src MUST be base64 string + return context.split( + onJson: (context) => + src is Uint8List || + (PrimitiveReflection.forString.canDeserialize(src, context) && + isBase64String( + PrimitiveReflection.forString.deserialize(src, context))), + onXml: (context) => + PrimitiveReflection.forString.canDeserialize(src, context) && + isBase64String( + PrimitiveReflection.forString.deserialize(src, context)), + ); + } + + @override + Uint8List deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return context.split( + onJson: (context) => src is Uint8List + ? src + : base64 + .decode(PrimitiveReflection.forString.deserialize(src, context)), + onXml: (context) => base64 + .decode(PrimitiveReflection.forString.deserialize(src, context)), + ); + } + + @override + Object? serialize( + Uint8List src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final encoded = base64.encode(src); + return context.split( + onJson: (context) => encoded, + onXml: (context) => + PrimitiveReflection.forString.serialize(encoded, context), + ); + } + + @override + Uint8List empty() => Uint8List(0); + + @override + Uint8List example([ExampleContext? context]) { + context ??= ExampleContext(); + final len = context.random.nextInt(50); + return Uint8List(len)..fillRange(0, len, context.random.nextInt(255)); + } +} + +class DateTimeReflection extends PrimitiveReflection { + const DateTimeReflection(); + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src is DateTime) { + return true; + } + return PrimitiveReflection.forString.canDeserialize(src) && + DateTime.tryParse( + PrimitiveReflection.forString.deserialize(src, context)) != + null; + } + + @override + DateTime deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src is DateTime) { + return src; + } + return DateTime.parse( + PrimitiveReflection.forString.deserialize(src, context), + ); + } + + @override + Object? serialize( + DateTime src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return PrimitiveReflection.forString.serialize( + src.toIso8601String(), + context, + ); + } + + @override + DateTime empty() => DateTime.fromMillisecondsSinceEpoch(0, isUtc: true); + + @override + DateTime example([ExampleContext? context]) { + context ??= ExampleContext(); + return DateTime.fromMillisecondsSinceEpoch( + context.random.nextInt(4294967296) + + context.random.nextInt(4294967296) + + context.random.nextInt(4294967296), + isUtc: true, + ); + } + + @override + DateTime clone(DateTime src) { + return src; + } +} + +class XFileReflection extends PrimitiveReflection + implements Equality { + const XFileReflection(); + // XFiles are read only anyway, so we return them as is. + @override + XFile clone(XFile src) { + return src; + } + + @override + bool canDeserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + // for now, treat files the same as bytes. + if (src is XFile) { + return true; + } + return PrimitiveReflection.forUint8List.canDeserialize(src, context); + } + + @override + XFile deserialize( + Object? src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + if (src is XFile) { + return src; + } + final data = PrimitiveReflection.forUint8List.deserialize(src, context); + final name = "unknown"; + return XFile.fromData( + data, + name: name, + path: '/$name', + length: data.lengthInBytes, + mimeType: "application/octet-stream", + ); + } + + @override + Object? serialize( + XFile src, [ + SerializationContext context = const SerializationContext.json(), + ]) { + final bytes = context.fileBytesResolver?.call(src); + if (bytes != null) { + return PrimitiveReflection.forUint8List.serialize(bytes, context); + } + return src; + } + + @override + XFile empty() => XFile.fromData(PrimitiveReflection.forUint8List.empty(), + name: '', length: 0); + + @override + XFile example([ExampleContext? context]) { + context ??= ExampleContext(); + final data = PrimitiveReflection.forUint8List.example(context); + final name = PrimitiveReflection.forString.example(context) + ".txt"; + context.fileCache[name] = data; + return XFile.fromData( + data, + name: name, + path: '/$name', + length: data.lengthInBytes, + mimeType: "text/plain", + ); + } + + @override + Equality get equality => this; + @override + bool equals(XFile e1, XFile e2) { + if (identical(e1, e2)) return true; + return e1.path == e2.path && + e1.mimeType == e2.mimeType && + e1.name == e2.name; + } + + @override + int hash(XFile e) { + return Object.hash(e.path, e.mimeType, e.name); + } + + @override + bool isValidKey(Object? o) { + return o is XFile; + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/reflection.dart new file mode 100644 index 000000000000..02eb6799caa9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/reflection.dart @@ -0,0 +1,194 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:collection/collection.dart'; + +class StrictEquality implements Equality { + const StrictEquality(); + + @override + bool equals(T e1, T e2) => e1 == e2; + + @override + int hash(T e) { + return e.hashCode; + } + + @override + bool isValidKey(Object? o) { + return o is T; + } +} + +mixin SerializationReflection { + SerializationFunction get deserializeFunction; + SerializationFunction get canDeserializeFunction; + SerializationFunction get serializeFunction; + + T Function([ExampleContext?]) get exampleFunction; + T Function() get emptyFunction; + Equality get equality => StrictEquality(); + FunctionWrapper1 get cloneFunction; + + /// check if an instance can be reflected using this reflection. + bool isInstanceOfType( + Object? instance, [ + SerializationContext context = const SerializationContext.json(), + ]) => + instance is T; + + /// check if a `TOther Function()` is assignable to `T Function()`, + /// meaning that [TOther] is assignable to -and thus a subtype of- [T]. + /// + /// A reflection can reflect a type as long as [TOther] is assignable to [T]. + bool canReflectType() => + TOther == T || (() => null as TOther) is T Function(); +} + +mixin InheritanceBasedSerializationReflection on SerializationReflection { + @override + SerializationFunction get canDeserializeFunction => + SerializationFunction(canDeserialize); + bool canDeserialize(Object? src, + [SerializationContext context = const SerializationContext.json()]); + + @override + SerializationFunction get deserializeFunction => + SerializationFunction(deserialize); + T deserialize(Object? src, + [SerializationContext context = const SerializationContext.json()]); + + @override + SerializationFunction get serializeFunction => + SerializationFunction(serialize); + Object? serialize(T src, + [SerializationContext context = const SerializationContext.json()]); + + @override + T Function([ExampleContext?]) get exampleFunction => example; + T example([ExampleContext? context]); + + @override + T Function() get emptyFunction => empty; + T empty(); + + @override + FunctionWrapper1 get cloneFunction => FunctionWrapper1(clone); + T clone(T src); +} + +class DelegatingSerializationReflection with SerializationReflection { + @override + final SerializationFunction serializeFunction; + @override + final SerializationFunction canDeserializeFunction; + @override + final SerializationFunction deserializeFunction; + + @override + final T Function() emptyFunction; + @override + final T Function([ExampleContext? p1]) exampleFunction; + + @override + final Equality equality; + @override + final FunctionWrapper1 cloneFunction; + + const DelegatingSerializationReflection({ + required this.serializeFunction, + required this.canDeserializeFunction, + required this.deserializeFunction, + required this.emptyFunction, + required this.exampleFunction, + required this.equality, + required this.cloneFunction, + }); +} + +/// A special wrapper to be used in Map or Iterable, +/// where the type information of the object is lost. +/// +/// e.g. +/// +/// final serialized = MapReflection(NullableReflection(PrimitiveReflection.forObject)).serialize({ +/// // this will use the default string reflection +/// 'a': 'b' +/// // this uses a special enum reflection +/// 'c': ReflectionOverrideWrapper( +/// value: 'z', +/// reflection: MyEnumReflection.instance, +/// ), +/// // now we know that this null actually represents `num?`. +/// 'd': ReflectionOverrideWrapper( +/// value: null, +/// reflection: NullableReflection(PrimitiveReflection.fornum) +/// ) +/// }, SerializationContext.json()); +class ReflectionOverrideWrapper { + final T value; + final SerializationReflection reflection; + + const ReflectionOverrideWrapper({ + required this.value, + required this.reflection, + }); + + @override + bool operator ==(Object other) { + final otherValue = + other is ReflectionOverrideWrapper ? other.value : other; + return otherValue is T && + reflection.equality.isValidKey(otherValue) && + reflection.equality.equals(value, otherValue); + } + + @override + int get hashCode => reflection.equality.hash(value); +} + +class OasNameWrapper with HasOasName { + @override + final String oasName; + + const OasNameWrapper({ + required this.oasName, + }); +} + +mixin HasOasName { + String get oasName; +} + +// see https://github.com/dart-lang/sdk/issues/56231 for reason why this is needed. +extension type const SerializationFunction.unsafe(Function fn) { + const SerializationFunction( + TOut Function(TIn, [SerializationContext context]) src, + ) : this.unsafe(src); + + TOut call( + TIn value, [ + SerializationContext context = const SerializationContext.json(), + ]) { + return fn(value, context) as TOut; + } +} +extension type const FunctionWrapper1.unsafe(Function fn) { + const FunctionWrapper1(TOut Function(TIn1) src) : this.unsafe(src); + TOut call(TIn1 value1) { + return fn(value1) as TOut; + } +} +extension type const FunctionWrapper2.unsafe(Function fn) { + const FunctionWrapper2(TOut Function(TIn1, TIn2) src) : this.unsafe(src); + TOut call(TIn1 value1, TIn2 value2) { + return fn(value1, value2) as TOut; + } +} +extension type const FunctionWrapper3.unsafe( + Function fn) { + const FunctionWrapper3(TOut Function(TIn1, TIn2, TIn3) src) + : this.unsafe(src); + + TOut call(TIn1 value1, TIn2 value2, TIn3 value3) { + return fn(value1, value2, value3) as TOut; + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/xml_extensions.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/xml_extensions.dart new file mode 100644 index 000000000000..3deb912896df --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/xml_extensions.dart @@ -0,0 +1,105 @@ +import 'package:xml/xml.dart'; +import 'package:openapi_infrastructure/openapi_infrastructure.dart'; + +extension UndefinedWrapperXmlNodeExtensions on XmlNode { + Map readNormalized() { + final srcMap = >{}; + for (final child in children.followedBy(attributes)) { + String? srcMapKey; + if (child case XmlHasName namedChild) { + srcMapKey = namedChild.name.qualified; + } + final nodes = srcMap[srcMapKey] ??= []; + nodes.add(child); + } + final srcNormalized = srcMap.map( + (key, value) => MapEntry( + key, + value.normalize(), + ), + ); + return srcNormalized; + } + UndefinedWrapper getElementOrUndefined( + String key, { + String? namespace, + }) { + final element = getElement(key, namespace: namespace); + if (element == null) { + return UndefinedWrapper.undefined(); + } else { + return UndefinedWrapper(element); + } + } + + UndefinedWrapper getElementOrUndefinedMapped( + String key, + T Function(XmlElement src) mapper, { + String? namespace, + }) { + return getElementOrUndefined(key, namespace: namespace).map(mapper); + } + + T getElementRequiredMapped( + String key, + T Function(XmlElement src) mapper, { + String? namespace, + }) { + final element = getElement(key, namespace: namespace); + if (element == null) { + throw ArgumentError( + 'Element ($key) is not present in the Node, but it is required.', + 'key', + ); + } else { + return mapper(element); + } + } + + UndefinedWrapper getAttributeOrUndefined( + String key, { + String? namespace, + }) { + final element = getAttributeNode(key, namespace: namespace); + if (element == null) { + return UndefinedWrapper.undefined(); + } else { + return UndefinedWrapper(element); + } + } + + UndefinedWrapper getAttributeOrUndefinedMapped( + String key, + T Function(XmlAttribute src) mapper, { + String? namespace, + }) { + return getAttributeOrUndefined(key, namespace: namespace).map(mapper); + } + + T getAttributeRequiredMapped( + String key, + T Function(XmlAttribute src) mapper, { + String? namespace, + }) { + final element = getAttributeNode(key, namespace: namespace); + if (element == null) { + throw ArgumentError( + 'Element ($key) is not present in the Node, but it is required.', + 'key', + ); + } else { + return mapper(element); + } + } +} + +extension XmlNodeListExtensions on Iterable { + XmlNode normalize() { + final length = this.length; + return length == 0 + ? XmlDocumentFragment([]) + : length == 1 + ? first + : XmlDocumentFragment(this.map((e) => e.copy())); + } +} diff --git a/samples/openapi3/client/petstore/dart/next/lib/src/serialization/xml_reflection.dart b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/xml_reflection.dart new file mode 100644 index 000000000000..10c4c2ec5a06 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/lib/src/serialization/xml_reflection.dart @@ -0,0 +1,40 @@ +import 'package:petstore_api/_internal.dart'; + +mixin HasXmlReflection { + XmlReflection get xml; +} + +class XmlReflection { + const XmlReflection({ + this.xmlName, + this.namespace, + this.prefix, + this.attribute = false, + this.wrapped = false, + }); + + final String? xmlName; + final String? namespace; + final String? prefix; + final bool attribute; + final bool wrapped; + + XmlName getQualifiedName(String fallbackName) { + return XmlName(xmlName ?? fallbackName, prefix); + } + + XmlName? getQualifiedNameOrNull(String? fallbackName) { + final actualName = xmlName ?? fallbackName; + if (actualName == null) { + return null; + } + return XmlName(actualName, prefix); + } + + XmlAttribute? getXmlNamespaceAttribute() { + if (prefix == null || namespace == null) { + return null; + } + return XmlAttribute(XmlName(prefix!, 'xmlns'), namespace!); + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/pubspec.yaml b/samples/openapi3/client/petstore/dart/next/pubspec.yaml new file mode 100644 index 000000000000..56821cf50ca7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/pubspec.yaml @@ -0,0 +1,22 @@ +name: petstore_api +version: 1.0.0 +description: OpenAPI API client +homepage: homepage + +environment: + sdk: '>=3.4.3 <4.0.0' + +# Add regular dependencies here. +dependencies: + http: ^1.2.1 + xml: ^6.5.0 + std_uritemplate: ^1.0.1 + collection: ^1.19.0 + http_parser: ^4.1.0 + cross_file: '>=0.3.4+1 <1.0.0' + openapi_infrastructure: ^2.0.1 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 + parameterized_test: ^2.0.0 diff --git a/samples/openapi3/client/petstore/dart/next/test/apis/another_fake_api_test.dart b/samples/openapi3/client/petstore/dart/next/test/apis/another_fake_api_test.dart new file mode 100644 index 000000000000..6b71ad3edf20 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/apis/another_fake_api_test.dart @@ -0,0 +1,375 @@ +import 'package:test/test.dart'; +import 'package:petstore_api/_internal.dart'; +import '../utils.dart'; + +/// tests for AnotherFakeApi +void main() { + final wireOptions = WireSerializationOptions(); + final exampleContext = ExampleContext(); + group(AnotherFakeApi, () { + final baseUrl = Uri.https("example.com", "/api"); + // To test special tags + // + // To test special tags and operation ID starting with number + // + group(r'$123testSpecialTags', () { + group(AnotherFakeApi$123testSpecialTagsRequest, () { + late AnotherFakeApi$123testSpecialTagsRequest request; + test(AnotherFakeApi$123testSpecialTagsRequestUnsafe, () async { + request = AnotherFakeApi$123testSpecialTagsRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(AnotherFakeApi$123testSpecialTagsRequestApplicationJson, () async { + request = AnotherFakeApi$123testSpecialTagsRequest.applicationJson( + data: AnotherFakeApi$123testSpecialTagsRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(AnotherFakeApi$123testSpecialTagsResponse, () { + late AnotherFakeApi$123testSpecialTagsResponse response; + test('Unkown status code', () async { + response = await AnotherFakeApi$123testSpecialTagsResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(AnotherFakeApi$123testSpecialTagsResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await AnotherFakeApi$123testSpecialTagsResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = AnotherFakeApi$123testSpecialTagsResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await AnotherFakeApi$123testSpecialTagsResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // parameter array number default value + // + group(r'getParameterArrayNumber', () { + group(AnotherFakeApiGetParameterArrayNumberRequest, () { + late AnotherFakeApiGetParameterArrayNumberRequest request; + test(r'No Body', () async { + request = AnotherFakeApiGetParameterArrayNumberRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +array: XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +) +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(AnotherFakeApiGetParameterArrayNumberResponse, () { + late AnotherFakeApiGetParameterArrayNumberResponse response; + test('Unkown status code', () async { + response = await AnotherFakeApiGetParameterArrayNumberResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(AnotherFakeApiGetParameterArrayNumberResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await AnotherFakeApiGetParameterArrayNumberResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // parameter string number + // + group(r'getParameterStringNumber', () { + group(AnotherFakeApiGetParameterStringNumberRequest, () { + late AnotherFakeApiGetParameterStringNumberRequest request; + test(r'No Body', () async { + request = AnotherFakeApiGetParameterStringNumberRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +stringNumber: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.fordouble + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(AnotherFakeApiGetParameterStringNumberResponse, () { + late AnotherFakeApiGetParameterStringNumberResponse response; + test('Unkown status code', () async { + response = await AnotherFakeApiGetParameterStringNumberResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(AnotherFakeApiGetParameterStringNumberResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await AnotherFakeApiGetParameterStringNumberResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // null request body + // + group(r'nullRequestBody', () { + group(AnotherFakeApiNullRequestBodyRequest, () { + late AnotherFakeApiNullRequestBodyRequest request; + test(r'No Body', () async { + request = AnotherFakeApiNullRequestBodyRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +acceptLanguage: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +).exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(AnotherFakeApiNullRequestBodyResponse, () { + late AnotherFakeApiNullRequestBodyResponse response; + test('Unkown status code', () async { + response = await AnotherFakeApiNullRequestBodyResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(AnotherFakeApiNullRequestBodyResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await AnotherFakeApiNullRequestBodyResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/apis/default_api_test.dart b/samples/openapi3/client/petstore/dart/next/test/apis/default_api_test.dart new file mode 100644 index 000000000000..e7433be1a183 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/apis/default_api_test.dart @@ -0,0 +1,976 @@ +import 'package:test/test.dart'; +import 'package:petstore_api/_internal.dart'; +import '../utils.dart'; + +/// tests for DefaultApi +void main() { + final wireOptions = WireSerializationOptions(); + final exampleContext = ExampleContext(); + group(DefaultApi, () { + final baseUrl = Uri.https("example.com", "/api"); + // Test route, this shouldn't cause a compiler error + // + group(r'fakeAnyOfWIthSameErasureGet', () { + group(DefaultApiFakeAnyOfWIthSameErasureGetRequest, () { + late DefaultApiFakeAnyOfWIthSameErasureGetRequest request; + test(r'No Body', () async { + request = DefaultApiFakeAnyOfWIthSameErasureGetRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(DefaultApiFakeAnyOfWIthSameErasureGetResponse, () { + late DefaultApiFakeAnyOfWIthSameErasureGetResponse response; + test('Unkown status code', () async { + response = await DefaultApiFakeAnyOfWIthSameErasureGetResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(DefaultApiFakeAnyOfWIthSameErasureGetResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await DefaultApiFakeAnyOfWIthSameErasureGetResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = DefaultApiFakeAnyOfWIthSameErasureGetResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await DefaultApiFakeAnyOfWIthSameErasureGetResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // Test route, this shouldn't cause a compiler error + // + group(r'fakeOneOfWIthSameErasureGet', () { + group(DefaultApiFakeOneOfWIthSameErasureGetRequest, () { + late DefaultApiFakeOneOfWIthSameErasureGetRequest request; + test(r'No Body', () async { + request = DefaultApiFakeOneOfWIthSameErasureGetRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(DefaultApiFakeOneOfWIthSameErasureGetResponse, () { + late DefaultApiFakeOneOfWIthSameErasureGetResponse response; + test('Unkown status code', () async { + response = await DefaultApiFakeOneOfWIthSameErasureGetResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(DefaultApiFakeOneOfWIthSameErasureGetResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await DefaultApiFakeOneOfWIthSameErasureGetResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = DefaultApiFakeOneOfWIthSameErasureGetResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await DefaultApiFakeOneOfWIthSameErasureGetResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + group(r'fooGet', () { + group(DefaultApiFooGetRequest, () { + late DefaultApiFooGetRequest request; + test(r'No Body', () async { + request = DefaultApiFooGetRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(DefaultApiFooGetResponse, () { + late DefaultApiFooGetResponse response; + test('Unkown status code', () async { + response = await DefaultApiFooGetResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(DefaultApiFooGetResponseDefault, () { + test('Unknown mime', () async { + final codeExample = exampleContext.exampleCode(1, 599) +; + response = await DefaultApiFooGetResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(DefaultApiFooGetResponseDefaultApplicationJson, () async { + final codeExample = exampleContext.exampleCode(1, 599) +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = DefaultApiFooGetResponseDefaultApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await DefaultApiFooGetResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // Add a new pet + // + group(r'petsMulticontentTestPost', () { + group(DefaultApiPetsMulticontentTestPostRequest, () { + late DefaultApiPetsMulticontentTestPostRequest request; + test(DefaultApiPetsMulticontentTestPostRequestUnsafe, () async { + request = DefaultApiPetsMulticontentTestPostRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostRequestApplicationJson, () async { + request = DefaultApiPetsMulticontentTestPostRequest.applicationJson( + data: DefaultApiPetsMulticontentTestPostRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostRequestApplicationXml, () async { + request = DefaultApiPetsMulticontentTestPostRequest.applicationXml( + data: DefaultApiPetsMulticontentTestPostRequestApplicationXml.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostRequestApplicationXWwwFormUrlencoded, () async { + request = DefaultApiPetsMulticontentTestPostRequest.applicationXWwwFormUrlencoded( + data: DefaultApiPetsMulticontentTestPostRequestApplicationXWwwFormUrlencoded.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostRequestTextPlain, () async { + request = DefaultApiPetsMulticontentTestPostRequest.textPlain( + data: DefaultApiPetsMulticontentTestPostRequestTextPlain.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostRequestAnyAny, () async { + request = DefaultApiPetsMulticontentTestPostRequest.anyAny( + data: DefaultApiPetsMulticontentTestPostRequestAnyAny.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostRequestTextAny, () async { + request = DefaultApiPetsMulticontentTestPostRequest.textAny( + data: DefaultApiPetsMulticontentTestPostRequestTextAny.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostRequestMultipartFormData, () async { + request = DefaultApiPetsMulticontentTestPostRequest.multipartFormData( + data: DefaultApiPetsMulticontentTestPostRequestMultipartFormData.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(DefaultApiPetsMulticontentTestPostResponse, () { + late DefaultApiPetsMulticontentTestPostResponse response; + test('Unkown status code', () async { + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(DefaultApiPetsMulticontentTestPostResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(DefaultApiPetsMulticontentTestPostResponse200TextPlain, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'text/plain')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponse200TextPlain.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostResponse200AnyAny, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'*/*')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponse200AnyAny.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostResponse200TextAny, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'text/*')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponse200TextAny.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostResponse200MultipartFormData, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'multipart/form-data')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponse200MultipartFormData.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(DefaultApiPetsMulticontentTestPostResponse201, () { + test('Unknown mime', () async { + final codeExample = + 201 +; + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(DefaultApiPetsMulticontentTestPostResponse201ApplicationJson, () async { + final codeExample = + 201 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponse201ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostResponse201ApplicationXml, () async { + final codeExample = + 201 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/xml')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponse201ApplicationXml.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody; + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded, () async { + final codeExample = + 201 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/x-www-form-urlencoded')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponse201ApplicationXWwwFormUrlencoded.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody is Map ? OASNetworkingUtils.formUrlEncoded(serializedBody, {}) : serializedBody.toString(); + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(DefaultApiPetsMulticontentTestPostResponse2XX, () { + test('Unknown mime', () async { + final codeExample = + + exampleContext.exampleCode(200, 300) + + + + +; + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson, () async { + final codeExample = + + exampleContext.exampleCode(200, 300) + + + + +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponse2XXApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(DefaultApiPetsMulticontentTestPostResponseDefault, () { + test('Unknown mime', () async { + final codeExample = exampleContext.exampleCode(1, 599) +; + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson, () async { + final codeExample = exampleContext.exampleCode(1, 599) +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponseDefaultApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded, () async { + final codeExample = exampleContext.exampleCode(1, 599) +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/x-www-form-urlencoded')); + final bodyReflection = DefaultApiPetsMulticontentTestPostResponseDefaultApplicationXWwwFormUrlencoded.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody is Map ? OASNetworkingUtils.formUrlEncoded(serializedBody, {}) : serializedBody.toString(); + + response = await DefaultApiPetsMulticontentTestPostResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/apis/fake_api_test.dart b/samples/openapi3/client/petstore/dart/next/test/apis/fake_api_test.dart new file mode 100644 index 000000000000..359815c99f95 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/apis/fake_api_test.dart @@ -0,0 +1,2333 @@ +import 'package:test/test.dart'; +import 'package:petstore_api/_internal.dart'; +import '../utils.dart'; + +/// tests for FakeApi +void main() { + final wireOptions = WireSerializationOptions(); + final exampleContext = ExampleContext(); + group(FakeApi, () { + final baseUrl = Uri.https("example.com", "/api"); + // Get a free form object or Json string + // + group(r'fakeGetFreeFormObjectGet', () { + group(FakeApiFakeGetFreeFormObjectGetRequest, () { + late FakeApiFakeGetFreeFormObjectGetRequest request; + test(r'No Body', () async { + request = FakeApiFakeGetFreeFormObjectGetRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(FakeApiFakeGetFreeFormObjectGetResponse, () { + late FakeApiFakeGetFreeFormObjectGetResponse response; + test('Unkown status code', () async { + response = await FakeApiFakeGetFreeFormObjectGetResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiFakeGetFreeFormObjectGetResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiFakeGetFreeFormObjectGetResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = FakeApiFakeGetFreeFormObjectGetResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await FakeApiFakeGetFreeFormObjectGetResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // Test serialization of outer boolean types + // + group(r'fakeOuterBooleanSerialize', () { + group(FakeApiFakeOuterBooleanSerializeRequest, () { + late FakeApiFakeOuterBooleanSerializeRequest request; + test(FakeApiFakeOuterBooleanSerializeRequestUnsafe, () async { + request = FakeApiFakeOuterBooleanSerializeRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiFakeOuterBooleanSerializeRequestApplicationJson, () async { + request = FakeApiFakeOuterBooleanSerializeRequest.applicationJson( + data: FakeApiFakeOuterBooleanSerializeRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiFakeOuterBooleanSerializeResponse, () { + late FakeApiFakeOuterBooleanSerializeResponse response; + test('Unkown status code', () async { + response = await FakeApiFakeOuterBooleanSerializeResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiFakeOuterBooleanSerializeResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiFakeOuterBooleanSerializeResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeApiFakeOuterBooleanSerializeResponse200AnyAny, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'*/*')); + final bodyReflection = FakeApiFakeOuterBooleanSerializeResponse200AnyAny.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + + response = await FakeApiFakeOuterBooleanSerializeResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // Test serialization of object with outer number type + // + group(r'fakeOuterCompositeSerialize', () { + group(FakeApiFakeOuterCompositeSerializeRequest, () { + late FakeApiFakeOuterCompositeSerializeRequest request; + test(FakeApiFakeOuterCompositeSerializeRequestUnsafe, () async { + request = FakeApiFakeOuterCompositeSerializeRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiFakeOuterCompositeSerializeRequestApplicationJson, () async { + request = FakeApiFakeOuterCompositeSerializeRequest.applicationJson( + data: FakeApiFakeOuterCompositeSerializeRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiFakeOuterCompositeSerializeResponse, () { + late FakeApiFakeOuterCompositeSerializeResponse response; + test('Unkown status code', () async { + response = await FakeApiFakeOuterCompositeSerializeResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiFakeOuterCompositeSerializeResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiFakeOuterCompositeSerializeResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeApiFakeOuterCompositeSerializeResponse200AnyAny, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'*/*')); + final bodyReflection = FakeApiFakeOuterCompositeSerializeResponse200AnyAny.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + + response = await FakeApiFakeOuterCompositeSerializeResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // Test serialization of outer number types + // + group(r'fakeOuterNumberSerialize', () { + group(FakeApiFakeOuterNumberSerializeRequest, () { + late FakeApiFakeOuterNumberSerializeRequest request; + test(FakeApiFakeOuterNumberSerializeRequestUnsafe, () async { + request = FakeApiFakeOuterNumberSerializeRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiFakeOuterNumberSerializeRequestApplicationJson, () async { + request = FakeApiFakeOuterNumberSerializeRequest.applicationJson( + data: FakeApiFakeOuterNumberSerializeRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiFakeOuterNumberSerializeResponse, () { + late FakeApiFakeOuterNumberSerializeResponse response; + test('Unkown status code', () async { + response = await FakeApiFakeOuterNumberSerializeResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiFakeOuterNumberSerializeResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiFakeOuterNumberSerializeResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeApiFakeOuterNumberSerializeResponse200AnyAny, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'*/*')); + final bodyReflection = FakeApiFakeOuterNumberSerializeResponse200AnyAny.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + + response = await FakeApiFakeOuterNumberSerializeResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // /fake/outer/string + // + // Test serialization of outer string types + // + group(r'fakeOuterStringSerialize', () { + group(FakeApiFakeOuterStringSerializeRequest, () { + late FakeApiFakeOuterStringSerializeRequest request; + test(FakeApiFakeOuterStringSerializeRequestUnsafe, () async { + request = FakeApiFakeOuterStringSerializeRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiFakeOuterStringSerializeRequestApplicationJson, () async { + request = FakeApiFakeOuterStringSerializeRequest.applicationJson( + data: FakeApiFakeOuterStringSerializeRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiFakeOuterStringSerializeResponse, () { + late FakeApiFakeOuterStringSerializeResponse response; + test('Unkown status code', () async { + response = await FakeApiFakeOuterStringSerializeResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiFakeOuterStringSerializeResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiFakeOuterStringSerializeResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeApiFakeOuterStringSerializeResponse200AnyAny, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'*/*')); + final bodyReflection = FakeApiFakeOuterStringSerializeResponse200AnyAny.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + + response = await FakeApiFakeOuterStringSerializeResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // fake uploads an image with ref request bodies + // + // + // + group(r'fakeUploadRefRequestBodies', () { + group(FakeApiFakeUploadRefRequestBodiesRequest, () { + late FakeApiFakeUploadRefRequestBodiesRequest request; + test(FakeApiFakeUploadRefRequestBodiesRequestUnsafe, () async { + request = FakeApiFakeUploadRefRequestBodiesRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +petId: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiFakeUploadRefRequestBodiesResponse, () { + late FakeApiFakeUploadRefRequestBodiesResponse response; + test('Unkown status code', () async { + response = await FakeApiFakeUploadRefRequestBodiesResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiFakeUploadRefRequestBodiesResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiFakeUploadRefRequestBodiesResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = FakeApiFakeUploadRefRequestBodiesResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await FakeApiFakeUploadRefRequestBodiesResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // Array of Enums + // + group(r'getFakeArrayofenums', () { + group(FakeApiGetFakeArrayofenumsRequest, () { + late FakeApiGetFakeArrayofenumsRequest request; + test(r'No Body', () async { + request = FakeApiGetFakeArrayofenumsRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(FakeApiGetFakeArrayofenumsResponse, () { + late FakeApiGetFakeArrayofenumsResponse response; + test('Unkown status code', () async { + response = await FakeApiGetFakeArrayofenumsResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiGetFakeArrayofenumsResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiGetFakeArrayofenumsResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeApiGetFakeArrayofenumsResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = FakeApiGetFakeArrayofenumsResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await FakeApiGetFakeArrayofenumsResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // Health check endpoint + // + group(r'getFakeHealth', () { + group(FakeApiGetFakeHealthRequest, () { + late FakeApiGetFakeHealthRequest request; + test(r'No Body', () async { + request = FakeApiGetFakeHealthRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(FakeApiGetFakeHealthResponse, () { + late FakeApiGetFakeHealthResponse response; + test('Unkown status code', () async { + response = await FakeApiGetFakeHealthResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiGetFakeHealthResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiGetFakeHealthResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeApiGetFakeHealthResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = FakeApiGetFakeHealthResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await FakeApiGetFakeHealthResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // parameter name mapping test + // + group(r'getParameterNameMapping', () { + group(FakeApiGetParameterNameMappingRequest, () { + late FakeApiGetParameterNameMappingRequest request; + test(r'No Body', () async { + request = FakeApiGetParameterNameMappingRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +$type: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + +type: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + +type$: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(FakeApiGetParameterNameMappingResponse, () { + late FakeApiGetParameterNameMappingResponse response; + test('Unkown status code', () async { + response = await FakeApiGetParameterNameMappingResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiGetParameterNameMappingResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiGetParameterNameMappingResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // test referenced additionalProperties + // + // + // + group(r'testAdditionalPropertiesReference', () { + group(FakeApiTestAdditionalPropertiesReferenceRequest, () { + late FakeApiTestAdditionalPropertiesReferenceRequest request; + test(FakeApiTestAdditionalPropertiesReferenceRequestUnsafe, () async { + request = FakeApiTestAdditionalPropertiesReferenceRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiTestAdditionalPropertiesReferenceRequestApplicationJson, () async { + request = FakeApiTestAdditionalPropertiesReferenceRequest.applicationJson( + data: FakeApiTestAdditionalPropertiesReferenceRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiTestAdditionalPropertiesReferenceResponse, () { + late FakeApiTestAdditionalPropertiesReferenceResponse response; + test('Unkown status code', () async { + response = await FakeApiTestAdditionalPropertiesReferenceResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestAdditionalPropertiesReferenceResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiTestAdditionalPropertiesReferenceResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // For this test, the body for this request much reference a schema named `File`. + // + group(r'testBodyWithFileSchema', () { + group(FakeApiTestBodyWithFileSchemaRequest, () { + late FakeApiTestBodyWithFileSchemaRequest request; + test(FakeApiTestBodyWithFileSchemaRequestUnsafe, () async { + request = FakeApiTestBodyWithFileSchemaRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiTestBodyWithFileSchemaRequestApplicationJson, () async { + request = FakeApiTestBodyWithFileSchemaRequest.applicationJson( + data: FakeApiTestBodyWithFileSchemaRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiTestBodyWithFileSchemaResponse, () { + late FakeApiTestBodyWithFileSchemaResponse response; + test('Unkown status code', () async { + response = await FakeApiTestBodyWithFileSchemaResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestBodyWithFileSchemaResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiTestBodyWithFileSchemaResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + group(r'testBodyWithQueryParams', () { + group(FakeApiTestBodyWithQueryParamsRequest, () { + late FakeApiTestBodyWithQueryParamsRequest request; + test(FakeApiTestBodyWithQueryParamsRequestUnsafe, () async { + request = FakeApiTestBodyWithQueryParamsRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +query: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiTestBodyWithQueryParamsRequestApplicationJson, () async { + request = FakeApiTestBodyWithQueryParamsRequest.applicationJson( + data: FakeApiTestBodyWithQueryParamsRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +query: XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiTestBodyWithQueryParamsResponse, () { + late FakeApiTestBodyWithQueryParamsResponse response; + test('Unkown status code', () async { + response = await FakeApiTestBodyWithQueryParamsResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestBodyWithQueryParamsResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiTestBodyWithQueryParamsResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // To test \"client\" model + // + // To test \"client\" model + // + group(r'testClientModel', () { + group(FakeApiTestClientModelRequest, () { + late FakeApiTestClientModelRequest request; + test(FakeApiTestClientModelRequestUnsafe, () async { + request = FakeApiTestClientModelRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiTestClientModelRequestApplicationJson, () async { + request = FakeApiTestClientModelRequest.applicationJson( + data: FakeApiTestClientModelRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiTestClientModelResponse, () { + late FakeApiTestClientModelResponse response; + test('Unkown status code', () async { + response = await FakeApiTestClientModelResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestClientModelResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiTestClientModelResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeApiTestClientModelResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = FakeApiTestClientModelResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await FakeApiTestClientModelResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + // + // Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + // + group(r'testEndpointParameters', () { + group(FakeApiTestEndpointParametersRequest, () { + late FakeApiTestEndpointParametersRequest request; + test(FakeApiTestEndpointParametersRequestUnsafe, () async { + request = FakeApiTestEndpointParametersRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiTestEndpointParametersResponse, () { + late FakeApiTestEndpointParametersResponse response; + test('Unkown status code', () async { + response = await FakeApiTestEndpointParametersResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestEndpointParametersResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await FakeApiTestEndpointParametersResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(FakeApiTestEndpointParametersResponse404, () { + test('Unknown mime', () async { + final codeExample = + 404 +; + response = await FakeApiTestEndpointParametersResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // To test enum parameters + // + // To test enum parameters + // + group(r'testEnumParameters', () { + group(FakeApiTestEnumParametersRequest, () { + late FakeApiTestEnumParametersRequest request; + test(r'No Body', () async { + request = FakeApiTestEnumParametersRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +enumHeaderStringArray: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumHeaderStringArrayEnum.$reflection + + +, +) +) +, +) +).exampleFunction(exampleContext), + +enumHeaderString: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumHeaderStringEnum.$reflection + + +, +) +).exampleFunction(exampleContext), + +enumQueryStringArray: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumQueryStringArrayEnum.$reflection + + +, +) +) +, +) +).exampleFunction(exampleContext), + +enumQueryString: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumQueryStringEnum.$reflection + + +, +) +).exampleFunction(exampleContext), + +enumQueryInteger: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumQueryIntegerEnum.$reflection + + +, +) +).exampleFunction(exampleContext), + +enumQueryDouble: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + EnumQueryDoubleEnum.$reflection + + +, +) +).exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(FakeApiTestEnumParametersResponse, () { + late FakeApiTestEnumParametersResponse response; + test('Unkown status code', () async { + response = await FakeApiTestEnumParametersResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestEnumParametersResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await FakeApiTestEnumParametersResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(FakeApiTestEnumParametersResponse404, () { + test('Unknown mime', () async { + final codeExample = + 404 +; + response = await FakeApiTestEnumParametersResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Fake endpoint to test group parameters (optional) + // + // Fake endpoint to test group parameters (optional) + // + group(r'testGroupParameters', () { + group(FakeApiTestGroupParametersRequest, () { + late FakeApiTestGroupParametersRequest request; + test(r'No Body', () async { + request = FakeApiTestGroupParametersRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +requiredStringGroup: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + +requiredBooleanGroup: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +.exampleFunction(exampleContext), + +requiredInt64Group: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + +stringGroup: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).exampleFunction(exampleContext), + +booleanGroup: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forbool + +, +) +).exampleFunction(exampleContext), + +int64Group: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +).exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(FakeApiTestGroupParametersResponse, () { + late FakeApiTestGroupParametersResponse response; + test('Unkown status code', () async { + response = await FakeApiTestGroupParametersResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestGroupParametersResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await FakeApiTestGroupParametersResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // test inline additionalProperties + // + // + // + group(r'testInlineAdditionalProperties', () { + group(FakeApiTestInlineAdditionalPropertiesRequest, () { + late FakeApiTestInlineAdditionalPropertiesRequest request; + test(FakeApiTestInlineAdditionalPropertiesRequestUnsafe, () async { + request = FakeApiTestInlineAdditionalPropertiesRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiTestInlineAdditionalPropertiesRequestApplicationJson, () async { + request = FakeApiTestInlineAdditionalPropertiesRequest.applicationJson( + data: FakeApiTestInlineAdditionalPropertiesRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiTestInlineAdditionalPropertiesResponse, () { + late FakeApiTestInlineAdditionalPropertiesResponse response; + test('Unkown status code', () async { + response = await FakeApiTestInlineAdditionalPropertiesResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestInlineAdditionalPropertiesResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiTestInlineAdditionalPropertiesResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // test inline free-form additionalProperties + // + // + // + group(r'testInlineFreeformAdditionalProperties', () { + group(FakeApiTestInlineFreeformAdditionalPropertiesRequest, () { + late FakeApiTestInlineFreeformAdditionalPropertiesRequest request; + test(FakeApiTestInlineFreeformAdditionalPropertiesRequestUnsafe, () async { + request = FakeApiTestInlineFreeformAdditionalPropertiesRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiTestInlineFreeformAdditionalPropertiesRequestApplicationJson, () async { + request = FakeApiTestInlineFreeformAdditionalPropertiesRequest.applicationJson( + data: FakeApiTestInlineFreeformAdditionalPropertiesRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiTestInlineFreeformAdditionalPropertiesResponse, () { + late FakeApiTestInlineFreeformAdditionalPropertiesResponse response; + test('Unkown status code', () async { + response = await FakeApiTestInlineFreeformAdditionalPropertiesResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestInlineFreeformAdditionalPropertiesResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiTestInlineFreeformAdditionalPropertiesResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // test json serialization of form data + // + // + // + group(r'testJsonFormData', () { + group(FakeApiTestJsonFormDataRequest, () { + late FakeApiTestJsonFormDataRequest request; + test(r'No Body', () async { + request = FakeApiTestJsonFormDataRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(FakeApiTestJsonFormDataResponse, () { + late FakeApiTestJsonFormDataResponse response; + test('Unkown status code', () async { + response = await FakeApiTestJsonFormDataResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestJsonFormDataResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiTestJsonFormDataResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // To test the collection format in query parameters + // + group(r'testQueryParameterCollectionFormat', () { + group(FakeApiTestQueryParameterCollectionFormatRequest, () { + late FakeApiTestQueryParameterCollectionFormatRequest request; + test(FakeApiTestQueryParameterCollectionFormatRequestUnsafe, () async { + request = FakeApiTestQueryParameterCollectionFormatRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +pipe: XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +.exampleFunction(exampleContext), + +ioutil: XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +.exampleFunction(exampleContext), + +http: XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +.exampleFunction(exampleContext), + +url: XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +.exampleFunction(exampleContext), + +context: XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiTestQueryParameterCollectionFormatResponse, () { + late FakeApiTestQueryParameterCollectionFormatResponse response; + test('Unkown status code', () async { + response = await FakeApiTestQueryParameterCollectionFormatResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestQueryParameterCollectionFormatResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiTestQueryParameterCollectionFormatResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // test referenced string map + // + // + // + group(r'testStringMapReference', () { + group(FakeApiTestStringMapReferenceRequest, () { + late FakeApiTestStringMapReferenceRequest request; + test(FakeApiTestStringMapReferenceRequestUnsafe, () async { + request = FakeApiTestStringMapReferenceRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeApiTestStringMapReferenceRequestApplicationJson, () async { + request = FakeApiTestStringMapReferenceRequest.applicationJson( + data: FakeApiTestStringMapReferenceRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeApiTestStringMapReferenceResponse, () { + late FakeApiTestStringMapReferenceResponse response; + test('Unkown status code', () async { + response = await FakeApiTestStringMapReferenceResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeApiTestStringMapReferenceResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeApiTestStringMapReferenceResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/apis/fake_classname_tags123_api_test.dart b/samples/openapi3/client/petstore/dart/next/test/apis/fake_classname_tags123_api_test.dart new file mode 100644 index 000000000000..e17604b2826b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/apis/fake_classname_tags123_api_test.dart @@ -0,0 +1,137 @@ +import 'package:test/test.dart'; +import 'package:petstore_api/_internal.dart'; +import '../utils.dart'; + +/// tests for FakeClassnameTags123Api +void main() { + final wireOptions = WireSerializationOptions(); + final exampleContext = ExampleContext(); + group(FakeClassnameTags123Api, () { + final baseUrl = Uri.https("example.com", "/api"); + // To test class name in snake case + // + // To test class name in snake case + // + group(r'testClassname', () { + group(FakeClassnameTags123ApiTestClassnameRequest, () { + late FakeClassnameTags123ApiTestClassnameRequest request; + test(FakeClassnameTags123ApiTestClassnameRequestUnsafe, () async { + request = FakeClassnameTags123ApiTestClassnameRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(FakeClassnameTags123ApiTestClassnameRequestApplicationJson, () async { + request = FakeClassnameTags123ApiTestClassnameRequest.applicationJson( + data: FakeClassnameTags123ApiTestClassnameRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(FakeClassnameTags123ApiTestClassnameResponse, () { + late FakeClassnameTags123ApiTestClassnameResponse response; + test('Unkown status code', () async { + response = await FakeClassnameTags123ApiTestClassnameResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(FakeClassnameTags123ApiTestClassnameResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await FakeClassnameTags123ApiTestClassnameResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = FakeClassnameTags123ApiTestClassnameResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await FakeClassnameTags123ApiTestClassnameResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/apis/pet_api_test.dart b/samples/openapi3/client/petstore/dart/next/test/apis/pet_api_test.dart new file mode 100644 index 000000000000..f7d8d0f788dc --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/apis/pet_api_test.dart @@ -0,0 +1,1248 @@ +import 'package:test/test.dart'; +import 'package:petstore_api/_internal.dart'; +import '../utils.dart'; + +/// tests for PetApi +void main() { + final wireOptions = WireSerializationOptions(); + final exampleContext = ExampleContext(); + group(PetApi, () { + final baseUrl = Uri.https("example.com", "/api"); + // Add a new pet to the store + // + // + // + group(r'addPet', () { + group(PetApiAddPetRequest, () { + late PetApiAddPetRequest request; + test(PetApiAddPetRequestUnsafe, () async { + request = PetApiAddPetRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(PetApiAddPetRequestApplicationJson, () async { + request = PetApiAddPetRequest.applicationJson( + data: PetApiAddPetRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(PetApiAddPetRequestApplicationXml, () async { + request = PetApiAddPetRequest.applicationXml( + data: PetApiAddPetRequestApplicationXml.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(PetApiAddPetResponse, () { + late PetApiAddPetResponse response; + test('Unkown status code', () async { + response = await PetApiAddPetResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(PetApiAddPetResponse405, () { + test('Unknown mime', () async { + final codeExample = + 405 +; + response = await PetApiAddPetResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Deletes a pet + // + // + // + group(r'deletePet', () { + group(PetApiDeletePetRequest, () { + late PetApiDeletePetRequest request; + test(r'No Body', () async { + request = PetApiDeletePetRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +petId: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + +apiKey: UndefinedWrapperReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +).exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(PetApiDeletePetResponse, () { + late PetApiDeletePetResponse response; + test('Unkown status code', () async { + response = await PetApiDeletePetResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(PetApiDeletePetResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await PetApiDeletePetResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Finds Pets by status + // + // Multiple status values can be provided with comma separated strings + // + group(r'findPetsByStatus', () { + group(PetApiFindPetsByStatusRequest, () { + late PetApiFindPetsByStatusRequest request; + test(r'No Body', () async { + request = PetApiFindPetsByStatusRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +status: XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + StatusEnum.$reflection + + +, +) +) +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(PetApiFindPetsByStatusResponse, () { + late PetApiFindPetsByStatusResponse response; + test('Unkown status code', () async { + response = await PetApiFindPetsByStatusResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(PetApiFindPetsByStatusResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await PetApiFindPetsByStatusResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(PetApiFindPetsByStatusResponse200ApplicationXml, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/xml')); + final bodyReflection = PetApiFindPetsByStatusResponse200ApplicationXml.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody; + + response = await PetApiFindPetsByStatusResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(PetApiFindPetsByStatusResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = PetApiFindPetsByStatusResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await PetApiFindPetsByStatusResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(PetApiFindPetsByStatusResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await PetApiFindPetsByStatusResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Finds Pets by tags + // + // Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + // + group(r'findPetsByTags', () { + group(PetApiFindPetsByTagsRequest, () { + late PetApiFindPetsByTagsRequest request; + test(r'No Body', () async { + request = PetApiFindPetsByTagsRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +tags: XmlReflectionWrapper( + xml: XmlReflection( +), + + ListReflection(XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +) +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(PetApiFindPetsByTagsResponse, () { + late PetApiFindPetsByTagsResponse response; + test('Unkown status code', () async { + response = await PetApiFindPetsByTagsResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(PetApiFindPetsByTagsResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await PetApiFindPetsByTagsResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(PetApiFindPetsByTagsResponse200ApplicationXml, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/xml')); + final bodyReflection = PetApiFindPetsByTagsResponse200ApplicationXml.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody; + + response = await PetApiFindPetsByTagsResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(PetApiFindPetsByTagsResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = PetApiFindPetsByTagsResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await PetApiFindPetsByTagsResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(PetApiFindPetsByTagsResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await PetApiFindPetsByTagsResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Find pet by ID + // + // Returns a single pet + // + group(r'getPetById', () { + group(PetApiGetPetByIdRequest, () { + late PetApiGetPetByIdRequest request; + test(r'No Body', () async { + request = PetApiGetPetByIdRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +petId: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(PetApiGetPetByIdResponse, () { + late PetApiGetPetByIdResponse response; + test('Unkown status code', () async { + response = await PetApiGetPetByIdResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(PetApiGetPetByIdResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await PetApiGetPetByIdResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(PetApiGetPetByIdResponse200ApplicationXml, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/xml')); + final bodyReflection = PetApiGetPetByIdResponse200ApplicationXml.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody; + + response = await PetApiGetPetByIdResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(PetApiGetPetByIdResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = PetApiGetPetByIdResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await PetApiGetPetByIdResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(PetApiGetPetByIdResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await PetApiGetPetByIdResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(PetApiGetPetByIdResponse404, () { + test('Unknown mime', () async { + final codeExample = + 404 +; + response = await PetApiGetPetByIdResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Update an existing pet + // + // + // + group(r'updatePet', () { + group(PetApiUpdatePetRequest, () { + late PetApiUpdatePetRequest request; + test(PetApiUpdatePetRequestUnsafe, () async { + request = PetApiUpdatePetRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(PetApiUpdatePetRequestApplicationJson, () async { + request = PetApiUpdatePetRequest.applicationJson( + data: PetApiUpdatePetRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(PetApiUpdatePetRequestApplicationXml, () async { + request = PetApiUpdatePetRequest.applicationXml( + data: PetApiUpdatePetRequestApplicationXml.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(PetApiUpdatePetResponse, () { + late PetApiUpdatePetResponse response; + test('Unkown status code', () async { + response = await PetApiUpdatePetResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(PetApiUpdatePetResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await PetApiUpdatePetResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(PetApiUpdatePetResponse404, () { + test('Unknown mime', () async { + final codeExample = + 404 +; + response = await PetApiUpdatePetResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(PetApiUpdatePetResponse405, () { + test('Unknown mime', () async { + final codeExample = + 405 +; + response = await PetApiUpdatePetResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Updates a pet in the store with form data + // + // + // + group(r'updatePetWithForm', () { + group(PetApiUpdatePetWithFormRequest, () { + late PetApiUpdatePetWithFormRequest request; + test(PetApiUpdatePetWithFormRequestUnsafe, () async { + request = PetApiUpdatePetWithFormRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +petId: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(PetApiUpdatePetWithFormResponse, () { + late PetApiUpdatePetWithFormResponse response; + test('Unkown status code', () async { + response = await PetApiUpdatePetWithFormResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(PetApiUpdatePetWithFormResponse405, () { + test('Unknown mime', () async { + final codeExample = + 405 +; + response = await PetApiUpdatePetWithFormResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // uploads an image + // + // + // + group(r'uploadFile', () { + group(PetApiUploadFileRequest, () { + late PetApiUploadFileRequest request; + test(PetApiUploadFileRequestUnsafe, () async { + request = PetApiUploadFileRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +petId: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(PetApiUploadFileResponse, () { + late PetApiUploadFileResponse response; + test('Unkown status code', () async { + response = await PetApiUploadFileResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(PetApiUploadFileResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await PetApiUploadFileResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(PetApiUploadFileResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = PetApiUploadFileResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await PetApiUploadFileResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // uploads an image (required) + // + // + // + group(r'uploadFileWithRequiredFile', () { + group(PetApiUploadFileWithRequiredFileRequest, () { + late PetApiUploadFileWithRequiredFileRequest request; + test(PetApiUploadFileWithRequiredFileRequestUnsafe, () async { + request = PetApiUploadFileWithRequiredFileRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +petId: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(PetApiUploadFileWithRequiredFileResponse, () { + late PetApiUploadFileWithRequiredFileResponse response; + test('Unkown status code', () async { + response = await PetApiUploadFileWithRequiredFileResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(PetApiUploadFileWithRequiredFileResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await PetApiUploadFileWithRequiredFileResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(PetApiUploadFileWithRequiredFileResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = PetApiUploadFileWithRequiredFileResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await PetApiUploadFileWithRequiredFileResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/apis/store_api_test.dart b/samples/openapi3/client/petstore/dart/next/test/apis/store_api_test.dart new file mode 100644 index 000000000000..45caea481244 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/apis/store_api_test.dart @@ -0,0 +1,604 @@ +import 'package:test/test.dart'; +import 'package:petstore_api/_internal.dart'; +import '../utils.dart'; + +/// tests for StoreApi +void main() { + final wireOptions = WireSerializationOptions(); + final exampleContext = ExampleContext(); + group(StoreApi, () { + final baseUrl = Uri.https("example.com", "/api"); + // Delete purchase order by ID + // + // For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + // + group(r'deleteOrder', () { + group(StoreApiDeleteOrderRequest, () { + late StoreApiDeleteOrderRequest request; + test(r'No Body', () async { + request = StoreApiDeleteOrderRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +orderId: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(StoreApiDeleteOrderResponse, () { + late StoreApiDeleteOrderResponse response; + test('Unkown status code', () async { + response = await StoreApiDeleteOrderResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(StoreApiDeleteOrderResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await StoreApiDeleteOrderResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(StoreApiDeleteOrderResponse404, () { + test('Unknown mime', () async { + final codeExample = + 404 +; + response = await StoreApiDeleteOrderResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Returns pet inventories by status + // + // Returns a map of status codes to quantities + // + group(r'getInventory', () { + group(StoreApiGetInventoryRequest, () { + late StoreApiGetInventoryRequest request; + test(r'No Body', () async { + request = StoreApiGetInventoryRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(StoreApiGetInventoryResponse, () { + late StoreApiGetInventoryResponse response; + test('Unkown status code', () async { + response = await StoreApiGetInventoryResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(StoreApiGetInventoryResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await StoreApiGetInventoryResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(StoreApiGetInventoryResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = StoreApiGetInventoryResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await StoreApiGetInventoryResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + +}); + }); + // Find purchase order by ID + // + // For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + // + group(r'getOrderById', () { + group(StoreApiGetOrderByIdRequest, () { + late StoreApiGetOrderByIdRequest request; + test(r'No Body', () async { + request = StoreApiGetOrderByIdRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +orderId: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forint + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(StoreApiGetOrderByIdResponse, () { + late StoreApiGetOrderByIdResponse response; + test('Unkown status code', () async { + response = await StoreApiGetOrderByIdResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(StoreApiGetOrderByIdResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await StoreApiGetOrderByIdResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(StoreApiGetOrderByIdResponse200ApplicationXml, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/xml')); + final bodyReflection = StoreApiGetOrderByIdResponse200ApplicationXml.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody; + + response = await StoreApiGetOrderByIdResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(StoreApiGetOrderByIdResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = StoreApiGetOrderByIdResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await StoreApiGetOrderByIdResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(StoreApiGetOrderByIdResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await StoreApiGetOrderByIdResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(StoreApiGetOrderByIdResponse404, () { + test('Unknown mime', () async { + final codeExample = + 404 +; + response = await StoreApiGetOrderByIdResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Place an order for a pet + // + // + // + group(r'placeOrder', () { + group(StoreApiPlaceOrderRequest, () { + late StoreApiPlaceOrderRequest request; + test(StoreApiPlaceOrderRequestUnsafe, () async { + request = StoreApiPlaceOrderRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(StoreApiPlaceOrderRequestApplicationJson, () async { + request = StoreApiPlaceOrderRequest.applicationJson( + data: StoreApiPlaceOrderRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(StoreApiPlaceOrderResponse, () { + late StoreApiPlaceOrderResponse response; + test('Unkown status code', () async { + response = await StoreApiPlaceOrderResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(StoreApiPlaceOrderResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await StoreApiPlaceOrderResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(StoreApiPlaceOrderResponse200ApplicationXml, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/xml')); + final bodyReflection = StoreApiPlaceOrderResponse200ApplicationXml.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody; + + response = await StoreApiPlaceOrderResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(StoreApiPlaceOrderResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = StoreApiPlaceOrderResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await StoreApiPlaceOrderResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(StoreApiPlaceOrderResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await StoreApiPlaceOrderResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/apis/user_api_test.dart b/samples/openapi3/client/petstore/dart/next/test/apis/user_api_test.dart new file mode 100644 index 000000000000..de73d1000dbf --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/apis/user_api_test.dart @@ -0,0 +1,958 @@ +import 'package:test/test.dart'; +import 'package:petstore_api/_internal.dart'; +import '../utils.dart'; + +/// tests for UserApi +void main() { + final wireOptions = WireSerializationOptions(); + final exampleContext = ExampleContext(); + group(UserApi, () { + final baseUrl = Uri.https("example.com", "/api"); + // Create user + // + // This can only be done by the logged in user. + // + group(r'createUser', () { + group(UserApiCreateUserRequest, () { + late UserApiCreateUserRequest request; + test(UserApiCreateUserRequestUnsafe, () async { + request = UserApiCreateUserRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(UserApiCreateUserRequestApplicationJson, () async { + request = UserApiCreateUserRequest.applicationJson( + data: UserApiCreateUserRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(UserApiCreateUserResponse, () { + late UserApiCreateUserResponse response; + test('Unkown status code', () async { + response = await UserApiCreateUserResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(UserApiCreateUserResponseDefault, () { + test('Unknown mime', () async { + final codeExample = exampleContext.exampleCode(1, 599) +; + response = await UserApiCreateUserResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Creates list of users with given input array + // + // + // + group(r'createUsersWithArrayInput', () { + group(UserApiCreateUsersWithArrayInputRequest, () { + late UserApiCreateUsersWithArrayInputRequest request; + test(UserApiCreateUsersWithArrayInputRequestUnsafe, () async { + request = UserApiCreateUsersWithArrayInputRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(UserApiCreateUsersWithArrayInputRequestApplicationJson, () async { + request = UserApiCreateUsersWithArrayInputRequest.applicationJson( + data: UserApiCreateUsersWithArrayInputRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(UserApiCreateUsersWithArrayInputResponse, () { + late UserApiCreateUsersWithArrayInputResponse response; + test('Unkown status code', () async { + response = await UserApiCreateUsersWithArrayInputResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(UserApiCreateUsersWithArrayInputResponseDefault, () { + test('Unknown mime', () async { + final codeExample = exampleContext.exampleCode(1, 599) +; + response = await UserApiCreateUsersWithArrayInputResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Creates list of users with given input array + // + // + // + group(r'createUsersWithListInput', () { + group(UserApiCreateUsersWithListInputRequest, () { + late UserApiCreateUsersWithListInputRequest request; + test(UserApiCreateUsersWithListInputRequestUnsafe, () async { + request = UserApiCreateUsersWithListInputRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(UserApiCreateUsersWithListInputRequestApplicationJson, () async { + request = UserApiCreateUsersWithListInputRequest.applicationJson( + data: UserApiCreateUsersWithListInputRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(UserApiCreateUsersWithListInputResponse, () { + late UserApiCreateUsersWithListInputResponse response; + test('Unkown status code', () async { + response = await UserApiCreateUsersWithListInputResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(UserApiCreateUsersWithListInputResponseDefault, () { + test('Unknown mime', () async { + final codeExample = exampleContext.exampleCode(1, 599) +; + response = await UserApiCreateUsersWithListInputResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Delete user + // + // This can only be done by the logged in user. + // + group(r'deleteUser', () { + group(UserApiDeleteUserRequest, () { + late UserApiDeleteUserRequest request; + test(r'No Body', () async { + request = UserApiDeleteUserRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +username: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(UserApiDeleteUserResponse, () { + late UserApiDeleteUserResponse response; + test('Unkown status code', () async { + response = await UserApiDeleteUserResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(UserApiDeleteUserResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await UserApiDeleteUserResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(UserApiDeleteUserResponse404, () { + test('Unknown mime', () async { + final codeExample = + 404 +; + response = await UserApiDeleteUserResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Get user by user name + // + // + // + group(r'getUserByName', () { + group(UserApiGetUserByNameRequest, () { + late UserApiGetUserByNameRequest request; + test(r'No Body', () async { + request = UserApiGetUserByNameRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +username: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(UserApiGetUserByNameResponse, () { + late UserApiGetUserByNameResponse response; + test('Unkown status code', () async { + response = await UserApiGetUserByNameResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(UserApiGetUserByNameResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await UserApiGetUserByNameResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(UserApiGetUserByNameResponse200ApplicationXml, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/xml')); + final bodyReflection = UserApiGetUserByNameResponse200ApplicationXml.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody; + + response = await UserApiGetUserByNameResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(UserApiGetUserByNameResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = UserApiGetUserByNameResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await UserApiGetUserByNameResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(UserApiGetUserByNameResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await UserApiGetUserByNameResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(UserApiGetUserByNameResponse404, () { + test('Unknown mime', () async { + final codeExample = + 404 +; + response = await UserApiGetUserByNameResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Logs user into the system + // + // + // + group(r'loginUser', () { + group(UserApiLoginUserRequest, () { + late UserApiLoginUserRequest request; + test(r'No Body', () async { + request = UserApiLoginUserRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +username: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + +password: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(UserApiLoginUserResponse, () { + late UserApiLoginUserResponse response; + test('Unkown status code', () async { + response = await UserApiLoginUserResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(UserApiLoginUserResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await UserApiLoginUserResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(UserApiLoginUserResponse200ApplicationXml, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/xml')); + final bodyReflection = UserApiLoginUserResponse200ApplicationXml.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = serializedBody; + + response = await UserApiLoginUserResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + test(UserApiLoginUserResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = UserApiLoginUserResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await UserApiLoginUserResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(UserApiLoginUserResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await UserApiLoginUserResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Logs out current logged in user session + // + // + // + group(r'logoutUser', () { + group(UserApiLogoutUserRequest, () { + late UserApiLogoutUserRequest request; + test(r'No Body', () async { + request = UserApiLogoutUserRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(UserApiLogoutUserResponse, () { + late UserApiLogoutUserResponse response; + test('Unkown status code', () async { + response = await UserApiLogoutUserResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(UserApiLogoutUserResponseDefault, () { + test('Unknown mime', () async { + final codeExample = exampleContext.exampleCode(1, 599) +; + response = await UserApiLogoutUserResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + // Updated user + // + // This can only be done by the logged in user. + // + group(r'updateUser', () { + group(UserApiUpdateUserRequest, () { + late UserApiUpdateUserRequest request; + test(UserApiUpdateUserRequestUnsafe, () async { + request = UserApiUpdateUserRequest.unsafe( + bodyBytesStream: Stream.value(Uint8List.fromList([1, 2, 3])), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +username: XmlReflectionWrapper( + xml: XmlReflection( +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + + test(UserApiUpdateUserRequestApplicationJson, () async { + request = UserApiUpdateUserRequest.applicationJson( + data: UserApiUpdateUserRequestApplicationJson.dataReflection.exampleFunction(exampleContext), + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + +username: XmlReflectionWrapper( + xml: XmlReflection( + xmlName: r'User', +), + + + + + + PrimitiveReflection.forString + +, +) +.exampleFunction(exampleContext), + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); + +}); + + group(UserApiUpdateUserResponse, () { + late UserApiUpdateUserResponse response; + test('Unkown status code', () async { + response = await UserApiUpdateUserResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(UserApiUpdateUserResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await UserApiUpdateUserResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + group(UserApiUpdateUserResponse404, () { + test('Unknown mime', () async { + final codeExample = + 404 +; + response = await UserApiUpdateUserResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/apis/values_api_test.dart b/samples/openapi3/client/petstore/dart/next/test/apis/values_api_test.dart new file mode 100644 index 000000000000..67dfe4247aba --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/apis/values_api_test.dart @@ -0,0 +1,138 @@ +import 'package:test/test.dart'; +import 'package:petstore_api/_internal.dart'; +import '../utils.dart'; + +/// tests for ValuesApi +void main() { + final wireOptions = WireSerializationOptions(); + final exampleContext = ExampleContext(); + group(ValuesApi, () { + final baseUrl = Uri.https("example.com", "/api"); + // Get some primitive variable values + // + // + // + group(r'getSomeValues', () { + group(ValuesApiGetSomeValuesRequest, () { + late ValuesApiGetSomeValuesRequest request; + test(r'No Body', () async { + request = ValuesApiGetSomeValuesRequest( + extraHeaders: { + "hello":"world", + }, + extraQueryParameters: { + "welcome": "back", + }, + extraCookies: { + "nice": "work", + }, + + ); + final createdRequest = await request.createHttpRequest(baseUrl: baseUrl); + expect(createdRequest, isNotNull); + }); +}); + + group(ValuesApiGetSomeValuesResponse, () { + late ValuesApiGetSomeValuesResponse response; + test('Unkown status code', () async { + response = await ValuesApiGetSomeValuesResponse.fromResponse( + createFakeTextResponse( + statusCode: 2, + value: "value", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + expect(response.statusCode, 2); + }); + group(ValuesApiGetSomeValuesResponse200, () { + test('Unknown mime', () async { + final codeExample = + 200 +; + response = await ValuesApiGetSomeValuesResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + test(ValuesApiGetSomeValuesResponse200ApplicationJson, () async { + final codeExample = + 200 +; + final mimeExample = MediaType.parse(exampleContext.exampleMimeType(r'application/json')); + final bodyReflection = ValuesApiGetSomeValuesResponse200ApplicationJson.bodyReflection; + // v: an example response body. + final v = bodyReflection.exampleFunction(exampleContext); + SerializationContext context; + if (wireOptions.isXml(mimeExample)) { + context = const SerializationContext.xml(); + } else { + context = const SerializationContext.json(); + } + final serializedBody = bodyReflection.serializeFunction(v, context); + Object? finalValue = null; + finalValue = jsonEncode(serializedBody, toEncodable: wireOptions.toEncodable); + + response = await ValuesApiGetSomeValuesResponse.fromResponse( + switch (finalValue) { + String() => createFakeTextResponse( + statusCode: codeExample, + value: finalValue, + contentType: mimeExample.toString(), + ), + _ => createFakeTextResponse( + value: serializedBody.toString(), + statusCode: codeExample, + contentType: mimeExample.toString(), + ), + }, + userContext: {}, + wireSerializationOptions: wireOptions, + ); + expect(response.statusCode, codeExample); + expect(response.headers, containsPair('content-type', mimeExample.toString())); + //bodyBytesStream SHOULD be null if the response was handled successfully. + expect(response.bodyBytesStream, OASNetworkingUtils.isMediaTypeSerializable(mimeExample) ? isNull : isNotNull); + }); + + }); + group(ValuesApiGetSomeValuesResponse400, () { + test('Unknown mime', () async { + final codeExample = + 400 +; + response = await ValuesApiGetSomeValuesResponse.fromResponse( + createFakeTextResponse( + statusCode: codeExample, + value: "value", + contentType: "application/whatever", + ), + wireSerializationOptions: wireOptions, + userContext: {}, + ); + expect(response.statusCode, codeExample); + expect(response, isA() + .having((f) => f.bodyBytesStream, 'bodyBytesStream', isNotNull), + ); + }); + + }); + +}); + }); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/__200_response_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/__200_response_test.dart new file mode 100644 index 000000000000..53c43b50c8ce --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/__200_response_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'$200Response', () { + final reflection = $200Response.$reflection; + final exampleContext = ExampleContext(); + + late $200Response exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect($200Response.canDeserialize(roundTripped, context), isTrue); + + final deserialized = $200Response.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/__list_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/__list_test.dart new file mode 100644 index 000000000000..83ec6199f4d4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/__list_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'$List', () { + final reflection = $List.$reflection; + final exampleContext = ExampleContext(); + + late $List exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect($List.canDeserialize(roundTripped, context), isTrue); + + final deserialized = $List.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/__return_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/__return_test.dart new file mode 100644 index 000000000000..14e10e715da4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/__return_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'$Return', () { + final reflection = $Return.$reflection; + final exampleContext = ExampleContext(); + + late $Return exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect($Return.canDeserialize(roundTripped, context), isTrue); + + final deserialized = $Return.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/additional_properties_class_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/additional_properties_class_test.dart new file mode 100644 index 000000000000..14d7a36e8af4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/additional_properties_class_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'AdditionalPropertiesClass', () { + final reflection = AdditionalPropertiesClass.$reflection; + final exampleContext = ExampleContext(); + + late AdditionalPropertiesClass exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(AdditionalPropertiesClass.canDeserialize(roundTripped, context), isTrue); + + final deserialized = AdditionalPropertiesClass.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_attributes_c_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_attributes_c_test.dart new file mode 100644 index 000000000000..339c6e7cbaaa --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_attributes_c_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'AllOfModelArrayAnyOfAllOfAttributesC', () { + final reflection = AllOfModelArrayAnyOfAllOfAttributesC.$reflection; + final exampleContext = ExampleContext(); + + late AllOfModelArrayAnyOfAllOfAttributesC exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(AllOfModelArrayAnyOfAllOfAttributesC.canDeserialize(roundTripped, context), isTrue); + + final deserialized = AllOfModelArrayAnyOfAllOfAttributesC.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_attributes_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_attributes_test.dart new file mode 100644 index 000000000000..95c1f70b40cf --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_attributes_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'AllOfModelArrayAnyOfAllOfAttributes', () { + final reflection = AllOfModelArrayAnyOfAllOfAttributes.$reflection; + final exampleContext = ExampleContext(); + + late AllOfModelArrayAnyOfAllOfAttributes exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(AllOfModelArrayAnyOfAllOfAttributes.canDeserialize(roundTripped, context), isTrue); + + final deserialized = AllOfModelArrayAnyOfAllOfAttributes.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_link_list_column1_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_link_list_column1_test.dart new file mode 100644 index 000000000000..a80162cfac98 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_link_list_column1_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'AllOfModelArrayAnyOfAllOfLinkListColumn1', () { + final reflection = AllOfModelArrayAnyOfAllOfLinkListColumn1.$reflection; + final exampleContext = ExampleContext(); + + late AllOfModelArrayAnyOfAllOfLinkListColumn1 exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(AllOfModelArrayAnyOfAllOfLinkListColumn1.canDeserialize(roundTripped, context), isTrue); + + final deserialized = AllOfModelArrayAnyOfAllOfLinkListColumn1.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_link_list_column1_value_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_link_list_column1_value_test.dart new file mode 100644 index 000000000000..bbbf79a490f8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_all_of_link_list_column1_value_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'AllOfModelArrayAnyOfAllOfLinkListColumn1Value', () { + final reflection = AllOfModelArrayAnyOfAllOfLinkListColumn1Value.$reflection; + final exampleContext = ExampleContext(); + + late AllOfModelArrayAnyOfAllOfLinkListColumn1Value exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(AllOfModelArrayAnyOfAllOfLinkListColumn1Value.canDeserialize(roundTripped, context), isTrue); + + final deserialized = AllOfModelArrayAnyOfAllOfLinkListColumn1Value.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_test.dart new file mode 100644 index 000000000000..a187f195c333 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/all_of_model_array_any_of_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'AllOfModelArrayAnyOf', () { + final reflection = AllOfModelArrayAnyOf.$reflection; + final exampleContext = ExampleContext(); + + late AllOfModelArrayAnyOf exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(AllOfModelArrayAnyOf.canDeserialize(roundTripped, context), isTrue); + + final deserialized = AllOfModelArrayAnyOf.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/animal_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/animal_test.dart new file mode 100644 index 000000000000..bcecfcb31590 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/animal_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Animal', () { + final reflection = Animal.$reflection; + final exampleContext = ExampleContext(); + + late Animal exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Animal.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Animal.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/api_response_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/api_response_test.dart new file mode 100644 index 000000000000..7730c99d4646 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/api_response_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ApiResponse', () { + final reflection = ApiResponse.$reflection; + final exampleContext = ExampleContext(); + + late ApiResponse exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ApiResponse.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ApiResponse.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/apple_req_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/apple_req_test.dart new file mode 100644 index 000000000000..e17308e659fa --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/apple_req_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'AppleReq', () { + final reflection = AppleReq.$reflection; + final exampleContext = ExampleContext(); + + late AppleReq exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(AppleReq.canDeserialize(roundTripped, context), isTrue); + + final deserialized = AppleReq.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/apple_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/apple_test.dart new file mode 100644 index 000000000000..07b67de128b8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/apple_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Apple', () { + final reflection = Apple.$reflection; + final exampleContext = ExampleContext(); + + late Apple exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Apple.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Apple.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/array_any_of_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/array_any_of_test.dart new file mode 100644 index 000000000000..83a547521cfb --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/array_any_of_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ArrayAnyOf', () { + final reflection = ArrayAnyOf.$reflection; + final exampleContext = ExampleContext(); + + late ArrayAnyOf exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ArrayAnyOf.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ArrayAnyOf.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/array_default_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/array_default_test.dart new file mode 100644 index 000000000000..e8782de52453 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/array_default_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ArrayDefault', () { + final reflection = ArrayDefault.$reflection; + final exampleContext = ExampleContext(); + + late ArrayDefault exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ArrayDefault.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ArrayDefault.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/array_of_array_of_number_only_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/array_of_array_of_number_only_test.dart new file mode 100644 index 000000000000..9f91ed6dc158 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/array_of_array_of_number_only_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ArrayOfArrayOfNumberOnly', () { + final reflection = ArrayOfArrayOfNumberOnly.$reflection; + final exampleContext = ExampleContext(); + + late ArrayOfArrayOfNumberOnly exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ArrayOfArrayOfNumberOnly.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ArrayOfArrayOfNumberOnly.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/array_of_inline_all_of_array_allof_dog_property_inner_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/array_of_inline_all_of_array_allof_dog_property_inner_test.dart new file mode 100644 index 000000000000..8c9d93f00164 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/array_of_inline_all_of_array_allof_dog_property_inner_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ArrayOfInlineAllOfArrayAllofDogPropertyInner', () { + final reflection = ArrayOfInlineAllOfArrayAllofDogPropertyInner.$reflection; + final exampleContext = ExampleContext(); + + late ArrayOfInlineAllOfArrayAllofDogPropertyInner exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ArrayOfInlineAllOfArrayAllofDogPropertyInner.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ArrayOfInlineAllOfArrayAllofDogPropertyInner.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/array_of_inline_all_of_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/array_of_inline_all_of_test.dart new file mode 100644 index 000000000000..2d8869a6d9dd --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/array_of_inline_all_of_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ArrayOfInlineAllOf', () { + final reflection = ArrayOfInlineAllOf.$reflection; + final exampleContext = ExampleContext(); + + late ArrayOfInlineAllOf exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ArrayOfInlineAllOf.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ArrayOfInlineAllOf.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/array_of_number_only_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/array_of_number_only_test.dart new file mode 100644 index 000000000000..f80a094b5532 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/array_of_number_only_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ArrayOfNumberOnly', () { + final reflection = ArrayOfNumberOnly.$reflection; + final exampleContext = ExampleContext(); + + late ArrayOfNumberOnly exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ArrayOfNumberOnly.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ArrayOfNumberOnly.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/array_one_of_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/array_one_of_test.dart new file mode 100644 index 000000000000..885e2aab6481 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/array_one_of_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ArrayOneOf', () { + final reflection = ArrayOneOf.$reflection; + final exampleContext = ExampleContext(); + + late ArrayOneOf exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ArrayOneOf.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ArrayOneOf.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/array_test_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/array_test_test.dart new file mode 100644 index 000000000000..f1530f52a8b6 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/array_test_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ArrayTest', () { + final reflection = ArrayTest.$reflection; + final exampleContext = ExampleContext(); + + late ArrayTest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ArrayTest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ArrayTest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/banana_req_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/banana_req_test.dart new file mode 100644 index 000000000000..027be27fead4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/banana_req_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'BananaReq', () { + final reflection = BananaReq.$reflection; + final exampleContext = ExampleContext(); + + late BananaReq exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(BananaReq.canDeserialize(roundTripped, context), isTrue); + + final deserialized = BananaReq.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/banana_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/banana_test.dart new file mode 100644 index 000000000000..59a57649643d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/banana_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Banana', () { + final reflection = Banana.$reflection; + final exampleContext = ExampleContext(); + + late Banana exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Banana.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Banana.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/basque_pig_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/basque_pig_test.dart new file mode 100644 index 000000000000..edcccf17ecc2 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/basque_pig_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'BasquePig', () { + final reflection = BasquePig.$reflection; + final exampleContext = ExampleContext(); + + late BasquePig exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(BasquePig.canDeserialize(roundTripped, context), isTrue); + + final deserialized = BasquePig.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/capitalization_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/capitalization_test.dart new file mode 100644 index 000000000000..c07819879223 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/capitalization_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Capitalization', () { + final reflection = Capitalization.$reflection; + final exampleContext = ExampleContext(); + + late Capitalization exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Capitalization.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Capitalization.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/cat_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/cat_test.dart new file mode 100644 index 000000000000..d354a472341b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/cat_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Cat', () { + final reflection = Cat.$reflection; + final exampleContext = ExampleContext(); + + late Cat exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Cat.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Cat.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/category_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/category_test.dart new file mode 100644 index 000000000000..1b82ae435a6e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/category_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Category', () { + final reflection = Category.$reflection; + final exampleContext = ExampleContext(); + + late Category exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Category.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Category.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/class_model_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/class_model_test.dart new file mode 100644 index 000000000000..eab8f8b003b6 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/class_model_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ClassModel', () { + final reflection = ClassModel.$reflection; + final exampleContext = ExampleContext(); + + late ClassModel exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ClassModel.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ClassModel.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/client_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/client_test.dart new file mode 100644 index 000000000000..db6960ad20f9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/client_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Client', () { + final reflection = Client.$reflection; + final exampleContext = ExampleContext(); + + late Client exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Client.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Client.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/complex_quadrilateral_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/complex_quadrilateral_test.dart new file mode 100644 index 000000000000..660fd5c606c9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/complex_quadrilateral_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ComplexQuadrilateral', () { + final reflection = ComplexQuadrilateral.$reflection; + final exampleContext = ExampleContext(); + + late ComplexQuadrilateral exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ComplexQuadrilateral.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ComplexQuadrilateral.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/danish_pig_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/danish_pig_test.dart new file mode 100644 index 000000000000..c863d3e7c89e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/danish_pig_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'DanishPig', () { + final reflection = DanishPig.$reflection; + final exampleContext = ExampleContext(); + + late DanishPig exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(DanishPig.canDeserialize(roundTripped, context), isTrue); + + final deserialized = DanishPig.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/deprecated_object_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/deprecated_object_test.dart new file mode 100644 index 000000000000..e22db541869f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/deprecated_object_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'DeprecatedObject', () { + final reflection = DeprecatedObject.$reflection; + final exampleContext = ExampleContext(); + + late DeprecatedObject exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(DeprecatedObject.canDeserialize(roundTripped, context), isTrue); + + final deserialized = DeprecatedObject.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/dog_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/dog_test.dart new file mode 100644 index 000000000000..6ab11b3afe6a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/dog_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Dog', () { + final reflection = Dog.$reflection; + final exampleContext = ExampleContext(); + + late Dog exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Dog.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Dog.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/drawing_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/drawing_test.dart new file mode 100644 index 000000000000..13b30c47feff --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/drawing_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Drawing', () { + final reflection = Drawing.$reflection; + final exampleContext = ExampleContext(); + + late Drawing exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Drawing.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Drawing.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/enum_arrays_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/enum_arrays_test.dart new file mode 100644 index 000000000000..0a0d994a2749 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/enum_arrays_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'EnumArrays', () { + final reflection = EnumArrays.$reflection; + final exampleContext = ExampleContext(); + + late EnumArrays exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(EnumArrays.canDeserialize(roundTripped, context), isTrue); + + final deserialized = EnumArrays.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/enum_class_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/enum_class_test.dart new file mode 100644 index 000000000000..7f7c046a6cda --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/enum_class_test.dart @@ -0,0 +1,33 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'EnumClass', () { + final reflection = EnumClass.$reflection; + final exampleContext = ExampleContext(); + test('values not empty', () { + expect(EnumClass.values, isNotEmpty); + }); + + test('unsafe', () { + final example = reflection.subReflection.exampleFunction(exampleContext); + expect(EnumClass.$unsafe(example), example); + }); + + + test(r'abc', () { + expect(EnumClass.abc().value, r'_abc'); + }); + + test(r'efg', () { + expect(EnumClass.efg().value, r'-efg'); + }); + + test(r'xyz', () { + expect(EnumClass.xyz().value, r'(xyz)'); + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/enum_string_discriminator_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/enum_string_discriminator_test.dart new file mode 100644 index 000000000000..d6eb2677c336 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/enum_string_discriminator_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'EnumStringDiscriminator', () { + final reflection = EnumStringDiscriminator.$reflection; + final exampleContext = ExampleContext(); + + late EnumStringDiscriminator exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(EnumStringDiscriminator.canDeserialize(roundTripped, context), isTrue); + + final deserialized = EnumStringDiscriminator.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/enum_test_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/enum_test_test.dart new file mode 100644 index 000000000000..6f8ba9c69a29 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/enum_test_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'EnumTest', () { + final reflection = EnumTest.$reflection; + final exampleContext = ExampleContext(); + + late EnumTest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(EnumTest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = EnumTest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/equilateral_triangle_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/equilateral_triangle_test.dart new file mode 100644 index 000000000000..6facbc9c9d60 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/equilateral_triangle_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'EquilateralTriangle', () { + final reflection = EquilateralTriangle.$reflection; + final exampleContext = ExampleContext(); + + late EquilateralTriangle exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(EquilateralTriangle.canDeserialize(roundTripped, context), isTrue); + + final deserialized = EquilateralTriangle.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/fake_any_of_w_ith_same_erasure_get200_response_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/fake_any_of_w_ith_same_erasure_get200_response_test.dart new file mode 100644 index 000000000000..b997f993c25e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/fake_any_of_w_ith_same_erasure_get200_response_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'FakeAnyOfWIthSameErasureGet200Response', () { + final reflection = FakeAnyOfWIthSameErasureGet200Response.$reflection; + final exampleContext = ExampleContext(); + + late FakeAnyOfWIthSameErasureGet200Response exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(FakeAnyOfWIthSameErasureGet200Response.canDeserialize(roundTripped, context), isTrue); + + final deserialized = FakeAnyOfWIthSameErasureGet200Response.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/fake_one_of_w_ith_same_erasure_get200_response_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/fake_one_of_w_ith_same_erasure_get200_response_test.dart new file mode 100644 index 000000000000..fb0d809fcbb5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/fake_one_of_w_ith_same_erasure_get200_response_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'FakeOneOfWIthSameErasureGet200Response', () { + final reflection = FakeOneOfWIthSameErasureGet200Response.$reflection; + final exampleContext = ExampleContext(); + + late FakeOneOfWIthSameErasureGet200Response exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(FakeOneOfWIthSameErasureGet200Response.canDeserialize(roundTripped, context), isTrue); + + final deserialized = FakeOneOfWIthSameErasureGet200Response.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/file_schema_test_class_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/file_schema_test_class_test.dart new file mode 100644 index 000000000000..495e10d55f02 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/file_schema_test_class_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'FileSchemaTestClass', () { + final reflection = FileSchemaTestClass.$reflection; + final exampleContext = ExampleContext(); + + late FileSchemaTestClass exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(FileSchemaTestClass.canDeserialize(roundTripped, context), isTrue); + + final deserialized = FileSchemaTestClass.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/file_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/file_test.dart new file mode 100644 index 000000000000..501e852239de --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/file_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'File', () { + final reflection = File.$reflection; + final exampleContext = ExampleContext(); + + late File exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(File.canDeserialize(roundTripped, context), isTrue); + + final deserialized = File.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/foo_get_default_response_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/foo_get_default_response_test.dart new file mode 100644 index 000000000000..01b9334b8a55 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/foo_get_default_response_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'FooGetDefaultResponse', () { + final reflection = FooGetDefaultResponse.$reflection; + final exampleContext = ExampleContext(); + + late FooGetDefaultResponse exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(FooGetDefaultResponse.canDeserialize(roundTripped, context), isTrue); + + final deserialized = FooGetDefaultResponse.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/foo_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/foo_test.dart new file mode 100644 index 000000000000..5a13d3dbdc2b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/foo_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Foo', () { + final reflection = Foo.$reflection; + final exampleContext = ExampleContext(); + + late Foo exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Foo.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Foo.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/format_test_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/format_test_test.dart new file mode 100644 index 000000000000..6dce218fe80b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/format_test_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'FormatTest', () { + final reflection = FormatTest.$reflection; + final exampleContext = ExampleContext(); + + late FormatTest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(FormatTest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = FormatTest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/free_form_object_test_class_properties_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/free_form_object_test_class_properties_test.dart new file mode 100644 index 000000000000..e7c42d6643e1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/free_form_object_test_class_properties_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'FreeFormObjectTestClassProperties', () { + final reflection = FreeFormObjectTestClassProperties.$reflection; + final exampleContext = ExampleContext(); + + late FreeFormObjectTestClassProperties exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(FreeFormObjectTestClassProperties.canDeserialize(roundTripped, context), isTrue); + + final deserialized = FreeFormObjectTestClassProperties.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/free_form_object_test_class_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/free_form_object_test_class_test.dart new file mode 100644 index 000000000000..daa242eb0124 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/free_form_object_test_class_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'FreeFormObjectTestClass', () { + final reflection = FreeFormObjectTestClass.$reflection; + final exampleContext = ExampleContext(); + + late FreeFormObjectTestClass exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(FreeFormObjectTestClass.canDeserialize(roundTripped, context), isTrue); + + final deserialized = FreeFormObjectTestClass.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/fruit_req_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/fruit_req_test.dart new file mode 100644 index 000000000000..f8498f57cf14 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/fruit_req_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'FruitReq', () { + final reflection = FruitReq.$reflection; + final exampleContext = ExampleContext(); + + late FruitReq exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(FruitReq.canDeserialize(roundTripped, context), isTrue); + + final deserialized = FruitReq.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/fruit_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/fruit_test.dart new file mode 100644 index 000000000000..d6cd3a4d0bc3 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/fruit_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Fruit', () { + final reflection = Fruit.$reflection; + final exampleContext = ExampleContext(); + + late Fruit exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Fruit.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Fruit.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/gm_fruit_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/gm_fruit_test.dart new file mode 100644 index 000000000000..d71cf53f9841 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/gm_fruit_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'GmFruit', () { + final reflection = GmFruit.$reflection; + final exampleContext = ExampleContext(); + + late GmFruit exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(GmFruit.canDeserialize(roundTripped, context), isTrue); + + final deserialized = GmFruit.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/grandparent_animal_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/grandparent_animal_test.dart new file mode 100644 index 000000000000..bc0355279a6d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/grandparent_animal_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'GrandparentAnimal', () { + final reflection = GrandparentAnimal.$reflection; + final exampleContext = ExampleContext(); + + late GrandparentAnimal exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(GrandparentAnimal.canDeserialize(roundTripped, context), isTrue); + + final deserialized = GrandparentAnimal.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/has_only_read_only_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/has_only_read_only_test.dart new file mode 100644 index 000000000000..d456ede78970 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/has_only_read_only_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'HasOnlyReadOnly', () { + final reflection = HasOnlyReadOnly.$reflection; + final exampleContext = ExampleContext(); + + late HasOnlyReadOnly exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(HasOnlyReadOnly.canDeserialize(roundTripped, context), isTrue); + + final deserialized = HasOnlyReadOnly.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/health_check_result_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/health_check_result_test.dart new file mode 100644 index 000000000000..c11e4af20a08 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/health_check_result_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'HealthCheckResult', () { + final reflection = HealthCheckResult.$reflection; + final exampleContext = ExampleContext(); + + late HealthCheckResult exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(HealthCheckResult.canDeserialize(roundTripped, context), isTrue); + + final deserialized = HealthCheckResult.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/isosceles_triangle_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/isosceles_triangle_test.dart new file mode 100644 index 000000000000..5b3f67d0770b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/isosceles_triangle_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'IsoscelesTriangle', () { + final reflection = IsoscelesTriangle.$reflection; + final exampleContext = ExampleContext(); + + late IsoscelesTriangle exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(IsoscelesTriangle.canDeserialize(roundTripped, context), isTrue); + + final deserialized = IsoscelesTriangle.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/mammal_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/mammal_test.dart new file mode 100644 index 000000000000..409fd48fd2a4 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/mammal_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Mammal', () { + final reflection = Mammal.$reflection; + final exampleContext = ExampleContext(); + + late Mammal exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Mammal.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Mammal.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/map_test_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/map_test_test.dart new file mode 100644 index 000000000000..88385be83404 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/map_test_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'MapTest', () { + final reflection = MapTest.$reflection; + final exampleContext = ExampleContext(); + + late MapTest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(MapTest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = MapTest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/mixed_properties_and_additional_properties_class_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/mixed_properties_and_additional_properties_class_test.dart new file mode 100644 index 000000000000..45bf6e935766 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/mixed_properties_and_additional_properties_class_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'MixedPropertiesAndAdditionalPropertiesClass', () { + final reflection = MixedPropertiesAndAdditionalPropertiesClass.$reflection; + final exampleContext = ExampleContext(); + + late MixedPropertiesAndAdditionalPropertiesClass exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(MixedPropertiesAndAdditionalPropertiesClass.canDeserialize(roundTripped, context), isTrue); + + final deserialized = MixedPropertiesAndAdditionalPropertiesClass.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_number_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_number_test.dart new file mode 100644 index 000000000000..12cd6705f8ec --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_number_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'MixedTypeOneOfNumber', () { + final reflection = MixedTypeOneOfNumber.$reflection; + final exampleContext = ExampleContext(); + + late MixedTypeOneOfNumber exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(MixedTypeOneOfNumber.canDeserialize(roundTripped, context), isTrue); + + final deserialized = MixedTypeOneOfNumber.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_any_of1_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_any_of1_test.dart new file mode 100644 index 000000000000..0e5963091f31 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_any_of1_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'MixedTypeOneOfObjectAnyOf1', () { + final reflection = MixedTypeOneOfObjectAnyOf1.$reflection; + final exampleContext = ExampleContext(); + + late MixedTypeOneOfObjectAnyOf1 exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(MixedTypeOneOfObjectAnyOf1.canDeserialize(roundTripped, context), isTrue); + + final deserialized = MixedTypeOneOfObjectAnyOf1.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_any_of_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_any_of_test.dart new file mode 100644 index 000000000000..b31699cfb784 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_any_of_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'MixedTypeOneOfObjectAnyOf', () { + final reflection = MixedTypeOneOfObjectAnyOf.$reflection; + final exampleContext = ExampleContext(); + + late MixedTypeOneOfObjectAnyOf exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(MixedTypeOneOfObjectAnyOf.canDeserialize(roundTripped, context), isTrue); + + final deserialized = MixedTypeOneOfObjectAnyOf.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_one_of1_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_one_of1_test.dart new file mode 100644 index 000000000000..8d05ce023284 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_one_of1_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'MixedTypeOneOfObjectOneOf1', () { + final reflection = MixedTypeOneOfObjectOneOf1.$reflection; + final exampleContext = ExampleContext(); + + late MixedTypeOneOfObjectOneOf1 exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(MixedTypeOneOfObjectOneOf1.canDeserialize(roundTripped, context), isTrue); + + final deserialized = MixedTypeOneOfObjectOneOf1.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_one_of_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_one_of_test.dart new file mode 100644 index 000000000000..04b8924b9733 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_one_of_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'MixedTypeOneOfObjectOneOf', () { + final reflection = MixedTypeOneOfObjectOneOf.$reflection; + final exampleContext = ExampleContext(); + + late MixedTypeOneOfObjectOneOf exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(MixedTypeOneOfObjectOneOf.canDeserialize(roundTripped, context), isTrue); + + final deserialized = MixedTypeOneOfObjectOneOf.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_test.dart new file mode 100644 index 000000000000..0100a17cee8d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/mixed_type_one_of_object_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'MixedTypeOneOfObject', () { + final reflection = MixedTypeOneOfObject.$reflection; + final exampleContext = ExampleContext(); + + late MixedTypeOneOfObject exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(MixedTypeOneOfObject.canDeserialize(roundTripped, context), isTrue); + + final deserialized = MixedTypeOneOfObject.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/model_with_one_of_any_of_properties_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/model_with_one_of_any_of_properties_test.dart new file mode 100644 index 000000000000..85449c4f0e83 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/model_with_one_of_any_of_properties_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ModelWithOneOfAnyOfProperties', () { + final reflection = ModelWithOneOfAnyOfProperties.$reflection; + final exampleContext = ExampleContext(); + + late ModelWithOneOfAnyOfProperties exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ModelWithOneOfAnyOfProperties.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ModelWithOneOfAnyOfProperties.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/name_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/name_test.dart new file mode 100644 index 000000000000..dbd1196ee047 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/name_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Name', () { + final reflection = Name.$reflection; + final exampleContext = ExampleContext(); + + late Name exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Name.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Name.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/new_pet_category_inline_allof_all_of_category_tag_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/new_pet_category_inline_allof_all_of_category_tag_test.dart new file mode 100644 index 000000000000..e2b7453c387f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/new_pet_category_inline_allof_all_of_category_tag_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'NewPetCategoryInlineAllofAllOfCategoryTag', () { + final reflection = NewPetCategoryInlineAllofAllOfCategoryTag.$reflection; + final exampleContext = ExampleContext(); + + late NewPetCategoryInlineAllofAllOfCategoryTag exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(NewPetCategoryInlineAllofAllOfCategoryTag.canDeserialize(roundTripped, context), isTrue); + + final deserialized = NewPetCategoryInlineAllofAllOfCategoryTag.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/new_pet_category_inline_allof_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/new_pet_category_inline_allof_test.dart new file mode 100644 index 000000000000..fdff6e5a059a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/new_pet_category_inline_allof_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'NewPetCategoryInlineAllof', () { + final reflection = NewPetCategoryInlineAllof.$reflection; + final exampleContext = ExampleContext(); + + late NewPetCategoryInlineAllof exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(NewPetCategoryInlineAllof.canDeserialize(roundTripped, context), isTrue); + + final deserialized = NewPetCategoryInlineAllof.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/new_pet_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/new_pet_test.dart new file mode 100644 index 000000000000..320b32a9af53 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/new_pet_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'NewPet', () { + final reflection = NewPet.$reflection; + final exampleContext = ExampleContext(); + + late NewPet exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(NewPet.canDeserialize(roundTripped, context), isTrue); + + final deserialized = NewPet.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/nullable_class_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/nullable_class_test.dart new file mode 100644 index 000000000000..9a6da36302c8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/nullable_class_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'NullableClass', () { + final reflection = NullableClass.$reflection; + final exampleContext = ExampleContext(); + + late NullableClass exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(NullableClass.canDeserialize(roundTripped, context), isTrue); + + final deserialized = NullableClass.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/nullable_shape_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/nullable_shape_test.dart new file mode 100644 index 000000000000..0863caefb1f8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/nullable_shape_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'NullableShape', () { + final reflection = NullableShape.$reflection; + final exampleContext = ExampleContext(); + + late NullableShape exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(NullableShape.canDeserialize(roundTripped, context), isTrue); + + final deserialized = NullableShape.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/number_only_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/number_only_test.dart new file mode 100644 index 000000000000..6e5f84bee761 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/number_only_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'NumberOnly', () { + final reflection = NumberOnly.$reflection; + final exampleContext = ExampleContext(); + + late NumberOnly exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(NumberOnly.canDeserialize(roundTripped, context), isTrue); + + final deserialized = NumberOnly.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/object_with_deprecated_fields_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/object_with_deprecated_fields_test.dart new file mode 100644 index 000000000000..d10fac658c3f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/object_with_deprecated_fields_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ObjectWithDeprecatedFields', () { + final reflection = ObjectWithDeprecatedFields.$reflection; + final exampleContext = ExampleContext(); + + late ObjectWithDeprecatedFields exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ObjectWithDeprecatedFields.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ObjectWithDeprecatedFields.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/order_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/order_test.dart new file mode 100644 index 000000000000..f0bb61ebe69c --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/order_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Order', () { + final reflection = Order.$reflection; + final exampleContext = ExampleContext(); + + late Order exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Order.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Order.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/outer_composite_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/outer_composite_test.dart new file mode 100644 index 000000000000..500acde97af1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/outer_composite_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'OuterComposite', () { + final reflection = OuterComposite.$reflection; + final exampleContext = ExampleContext(); + + late OuterComposite exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(OuterComposite.canDeserialize(roundTripped, context), isTrue); + + final deserialized = OuterComposite.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_default_value_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_default_value_test.dart new file mode 100644 index 000000000000..92b16fb0b5d7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_default_value_test.dart @@ -0,0 +1,33 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'OuterEnumDefaultValue', () { + final reflection = OuterEnumDefaultValue.$reflection; + final exampleContext = ExampleContext(); + test('values not empty', () { + expect(OuterEnumDefaultValue.values, isNotEmpty); + }); + + test('unsafe', () { + final example = reflection.subReflection.exampleFunction(exampleContext); + expect(OuterEnumDefaultValue.$unsafe(example), example); + }); + + + test(r'placed', () { + expect(OuterEnumDefaultValue.placed().value, r'placed'); + }); + + test(r'approved', () { + expect(OuterEnumDefaultValue.approved().value, r'approved'); + }); + + test(r'delivered', () { + expect(OuterEnumDefaultValue.delivered().value, r'delivered'); + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_integer_default_value_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_integer_default_value_test.dart new file mode 100644 index 000000000000..b5721580f9f9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_integer_default_value_test.dart @@ -0,0 +1,33 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'OuterEnumIntegerDefaultValue', () { + final reflection = OuterEnumIntegerDefaultValue.$reflection; + final exampleContext = ExampleContext(); + test('values not empty', () { + expect(OuterEnumIntegerDefaultValue.values, isNotEmpty); + }); + + test('unsafe', () { + final example = reflection.subReflection.exampleFunction(exampleContext); + expect(OuterEnumIntegerDefaultValue.$unsafe(example), example); + }); + + + test(r'number0', () { + expect(OuterEnumIntegerDefaultValue.number0().value, 0); + }); + + test(r'number1', () { + expect(OuterEnumIntegerDefaultValue.number1().value, 1); + }); + + test(r'number2', () { + expect(OuterEnumIntegerDefaultValue.number2().value, 2); + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_integer_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_integer_test.dart new file mode 100644 index 000000000000..50a313a12591 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_integer_test.dart @@ -0,0 +1,33 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'OuterEnumInteger', () { + final reflection = OuterEnumInteger.$reflection; + final exampleContext = ExampleContext(); + test('values not empty', () { + expect(OuterEnumInteger.values, isNotEmpty); + }); + + test('unsafe', () { + final example = reflection.subReflection.exampleFunction(exampleContext); + expect(OuterEnumInteger.$unsafe(example), example); + }); + + + test(r'number0', () { + expect(OuterEnumInteger.number0().value, 0); + }); + + test(r'number1', () { + expect(OuterEnumInteger.number1().value, 1); + }); + + test(r'number2', () { + expect(OuterEnumInteger.number2().value, 2); + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_test.dart new file mode 100644 index 000000000000..f1ae39aac1c5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/outer_enum_test.dart @@ -0,0 +1,41 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'OuterEnum', () { + final reflection = OuterEnum.$reflection; + final exampleContext = ExampleContext(); + test('values not empty', () { + expect(OuterEnum.values, isNotEmpty); + }); + + test('unsafe', () { + final example = reflection.subReflection.exampleFunction(exampleContext); + expect(OuterEnum.$unsafe(example), example); + }); + + + test(r'placed', () { + expect(OuterEnum.placed().value, r'placed'); + }); + + test(r'approved', () { + expect(OuterEnum.approved().value, r'approved'); + }); + + test(r'delivered', () { + expect(OuterEnum.delivered().value, r'delivered'); + }); + + test(r'LOWER_CASE_S', () { + expect(OuterEnum.LOWER_CASE_S().value, r's'); + }); + + test(r'UPPER_CASE_S', () { + expect(OuterEnum.UPPER_CASE_S().value, r'S'); + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/parent_pet_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/parent_pet_test.dart new file mode 100644 index 000000000000..592f1402bfef --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/parent_pet_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ParentPet', () { + final reflection = ParentPet.$reflection; + final exampleContext = ExampleContext(); + + late ParentPet exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ParentPet.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ParentPet.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/pet_composition_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/pet_composition_test.dart new file mode 100644 index 000000000000..6bfdcd53977d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/pet_composition_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'PetComposition', () { + final reflection = PetComposition.$reflection; + final exampleContext = ExampleContext(); + + late PetComposition exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(PetComposition.canDeserialize(roundTripped, context), isTrue); + + final deserialized = PetComposition.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/pet_ref_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/pet_ref_test.dart new file mode 100644 index 000000000000..540b600f708b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/pet_ref_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'PetRef', () { + final reflection = PetRef.$reflection; + final exampleContext = ExampleContext(); + + late PetRef exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(PetRef.canDeserialize(roundTripped, context), isTrue); + + final deserialized = PetRef.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/pet_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/pet_test.dart new file mode 100644 index 000000000000..0e27671dc200 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/pet_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Pet', () { + final reflection = Pet.$reflection; + final exampleContext = ExampleContext(); + + late Pet exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Pet.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Pet.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/pet_using_all_of_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/pet_using_all_of_test.dart new file mode 100644 index 000000000000..aafdeb544562 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/pet_using_all_of_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'PetUsingAllOf', () { + final reflection = PetUsingAllOf.$reflection; + final exampleContext = ExampleContext(); + + late PetUsingAllOf exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(PetUsingAllOf.canDeserialize(roundTripped, context), isTrue); + + final deserialized = PetUsingAllOf.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/pet_with_required_tags_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/pet_with_required_tags_test.dart new file mode 100644 index 000000000000..8359aa9f7995 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/pet_with_required_tags_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'PetWithRequiredTags', () { + final reflection = PetWithRequiredTags.$reflection; + final exampleContext = ExampleContext(); + + late PetWithRequiredTags exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(PetWithRequiredTags.canDeserialize(roundTripped, context), isTrue); + + final deserialized = PetWithRequiredTags.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/pets_multicontent_test_post_request_address_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/pets_multicontent_test_post_request_address_test.dart new file mode 100644 index 000000000000..c8ddef23738a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/pets_multicontent_test_post_request_address_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'PetsMulticontentTestPostRequestAddress', () { + final reflection = PetsMulticontentTestPostRequestAddress.$reflection; + final exampleContext = ExampleContext(); + + late PetsMulticontentTestPostRequestAddress exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(PetsMulticontentTestPostRequestAddress.canDeserialize(roundTripped, context), isTrue); + + final deserialized = PetsMulticontentTestPostRequestAddress.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/pets_multicontent_test_post_request_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/pets_multicontent_test_post_request_test.dart new file mode 100644 index 000000000000..06f9de975b6e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/pets_multicontent_test_post_request_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'PetsMulticontentTestPostRequest', () { + final reflection = PetsMulticontentTestPostRequest.$reflection; + final exampleContext = ExampleContext(); + + late PetsMulticontentTestPostRequest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(PetsMulticontentTestPostRequest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = PetsMulticontentTestPostRequest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/pig_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/pig_test.dart new file mode 100644 index 000000000000..13837367bc7a --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/pig_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Pig', () { + final reflection = Pig.$reflection; + final exampleContext = ExampleContext(); + + late Pig exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Pig.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Pig.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/property_name_collision_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/property_name_collision_test.dart new file mode 100644 index 000000000000..7b481b2b0982 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/property_name_collision_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'PropertyNameCollision', () { + final reflection = PropertyNameCollision.$reflection; + final exampleContext = ExampleContext(); + + late PropertyNameCollision exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(PropertyNameCollision.canDeserialize(roundTripped, context), isTrue); + + final deserialized = PropertyNameCollision.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/quadrilateral_interface_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/quadrilateral_interface_test.dart new file mode 100644 index 000000000000..076e15ec4ecd --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/quadrilateral_interface_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'QuadrilateralInterface', () { + final reflection = QuadrilateralInterface.$reflection; + final exampleContext = ExampleContext(); + + late QuadrilateralInterface exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(QuadrilateralInterface.canDeserialize(roundTripped, context), isTrue); + + final deserialized = QuadrilateralInterface.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/quadrilateral_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/quadrilateral_test.dart new file mode 100644 index 000000000000..a50b3f2bbe8d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/quadrilateral_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Quadrilateral', () { + final reflection = Quadrilateral.$reflection; + final exampleContext = ExampleContext(); + + late Quadrilateral exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Quadrilateral.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Quadrilateral.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/read_only_first_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/read_only_first_test.dart new file mode 100644 index 000000000000..632c2632e2f9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/read_only_first_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ReadOnlyFirst', () { + final reflection = ReadOnlyFirst.$reflection; + final exampleContext = ExampleContext(); + + late ReadOnlyFirst exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ReadOnlyFirst.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ReadOnlyFirst.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/scalar_any_of_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/scalar_any_of_test.dart new file mode 100644 index 000000000000..90c43195494e --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/scalar_any_of_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ScalarAnyOf', () { + final reflection = ScalarAnyOf.$reflection; + final exampleContext = ExampleContext(); + + late ScalarAnyOf exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ScalarAnyOf.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ScalarAnyOf.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/scalar_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/scalar_test.dart new file mode 100644 index 000000000000..6f8b64ddb709 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/scalar_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Scalar', () { + final reflection = Scalar.$reflection; + final exampleContext = ExampleContext(); + + late Scalar exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Scalar.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Scalar.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/scalene_triangle_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/scalene_triangle_test.dart new file mode 100644 index 000000000000..cdfdc39a9eef --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/scalene_triangle_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ScaleneTriangle', () { + final reflection = ScaleneTriangle.$reflection; + final exampleContext = ExampleContext(); + + late ScaleneTriangle exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ScaleneTriangle.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ScaleneTriangle.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/shape_interface_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/shape_interface_test.dart new file mode 100644 index 000000000000..ae7a021ec24d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/shape_interface_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ShapeInterface', () { + final reflection = ShapeInterface.$reflection; + final exampleContext = ExampleContext(); + + late ShapeInterface exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ShapeInterface.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ShapeInterface.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/shape_or_null_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/shape_or_null_test.dart new file mode 100644 index 000000000000..6e6bd4cbf4ba --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/shape_or_null_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'ShapeOrNull', () { + final reflection = ShapeOrNull.$reflection; + final exampleContext = ExampleContext(); + + late ShapeOrNull exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(ShapeOrNull.canDeserialize(roundTripped, context), isTrue); + + final deserialized = ShapeOrNull.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/shape_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/shape_test.dart new file mode 100644 index 000000000000..7f1ba79971fe --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/shape_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Shape', () { + final reflection = Shape.$reflection; + final exampleContext = ExampleContext(); + + late Shape exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Shape.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Shape.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/simple_quadrilateral_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/simple_quadrilateral_test.dart new file mode 100644 index 000000000000..d5546fbde20f --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/simple_quadrilateral_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'SimpleQuadrilateral', () { + final reflection = SimpleQuadrilateral.$reflection; + final exampleContext = ExampleContext(); + + late SimpleQuadrilateral exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(SimpleQuadrilateral.canDeserialize(roundTripped, context), isTrue); + + final deserialized = SimpleQuadrilateral.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/special_model_name_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/special_model_name_test.dart new file mode 100644 index 000000000000..961b0882eaf1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/special_model_name_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'SpecialModelName', () { + final reflection = SpecialModelName.$reflection; + final exampleContext = ExampleContext(); + + late SpecialModelName exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(SpecialModelName.canDeserialize(roundTripped, context), isTrue); + + final deserialized = SpecialModelName.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/tag_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/tag_test.dart new file mode 100644 index 000000000000..6c84d468250b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/tag_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Tag', () { + final reflection = Tag.$reflection; + final exampleContext = ExampleContext(); + + late Tag exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Tag.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Tag.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/test_endpoint_parameters_request_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/test_endpoint_parameters_request_test.dart new file mode 100644 index 000000000000..04efeff282f6 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/test_endpoint_parameters_request_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'TestEndpointParametersRequest', () { + final reflection = TestEndpointParametersRequest.$reflection; + final exampleContext = ExampleContext(); + + late TestEndpointParametersRequest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(TestEndpointParametersRequest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = TestEndpointParametersRequest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/test_enum_parameters_request_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/test_enum_parameters_request_test.dart new file mode 100644 index 000000000000..98a046d32532 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/test_enum_parameters_request_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'TestEnumParametersRequest', () { + final reflection = TestEnumParametersRequest.$reflection; + final exampleContext = ExampleContext(); + + late TestEnumParametersRequest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(TestEnumParametersRequest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = TestEnumParametersRequest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/test_inline_freeform_additional_properties_request_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/test_inline_freeform_additional_properties_request_test.dart new file mode 100644 index 000000000000..3e1dc8d378c5 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/test_inline_freeform_additional_properties_request_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'TestInlineFreeformAdditionalPropertiesRequest', () { + final reflection = TestInlineFreeformAdditionalPropertiesRequest.$reflection; + final exampleContext = ExampleContext(); + + late TestInlineFreeformAdditionalPropertiesRequest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(TestInlineFreeformAdditionalPropertiesRequest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = TestInlineFreeformAdditionalPropertiesRequest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/test_json_form_data_request_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/test_json_form_data_request_test.dart new file mode 100644 index 000000000000..0e9a591cd6dd --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/test_json_form_data_request_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'TestJsonFormDataRequest', () { + final reflection = TestJsonFormDataRequest.$reflection; + final exampleContext = ExampleContext(); + + late TestJsonFormDataRequest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(TestJsonFormDataRequest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = TestJsonFormDataRequest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/triangle_interface_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/triangle_interface_test.dart new file mode 100644 index 000000000000..93d00b94b7fd --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/triangle_interface_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'TriangleInterface', () { + final reflection = TriangleInterface.$reflection; + final exampleContext = ExampleContext(); + + late TriangleInterface exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(TriangleInterface.canDeserialize(roundTripped, context), isTrue); + + final deserialized = TriangleInterface.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/triangle_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/triangle_test.dart new file mode 100644 index 000000000000..ead372c5c8e8 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/triangle_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Triangle', () { + final reflection = Triangle.$reflection; + final exampleContext = ExampleContext(); + + late Triangle exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Triangle.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Triangle.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/update_pet_with_form_request_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/update_pet_with_form_request_test.dart new file mode 100644 index 000000000000..0f4cd5371a55 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/update_pet_with_form_request_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'UpdatePetWithFormRequest', () { + final reflection = UpdatePetWithFormRequest.$reflection; + final exampleContext = ExampleContext(); + + late UpdatePetWithFormRequest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(UpdatePetWithFormRequest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = UpdatePetWithFormRequest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/upload_file_request_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/upload_file_request_test.dart new file mode 100644 index 000000000000..7f73d161e4cd --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/upload_file_request_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'UploadFileRequest', () { + final reflection = UploadFileRequest.$reflection; + final exampleContext = ExampleContext(); + + late UploadFileRequest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(UploadFileRequest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = UploadFileRequest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/upload_file_with_required_file_request_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/upload_file_with_required_file_request_test.dart new file mode 100644 index 000000000000..2c36862cd742 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/upload_file_with_required_file_request_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'UploadFileWithRequiredFileRequest', () { + final reflection = UploadFileWithRequiredFileRequest.$reflection; + final exampleContext = ExampleContext(); + + late UploadFileWithRequiredFileRequest exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(UploadFileWithRequiredFileRequest.canDeserialize(roundTripped, context), isTrue); + + final deserialized = UploadFileWithRequiredFileRequest.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/user_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/user_test.dart new file mode 100644 index 000000000000..4833744086e9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/user_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'User', () { + final reflection = User.$reflection; + final exampleContext = ExampleContext(); + + late User exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(User.canDeserialize(roundTripped, context), isTrue); + + final deserialized = User.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/value_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/value_test.dart new file mode 100644 index 000000000000..dbc7908307b0 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/value_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Value', () { + final reflection = Value.$reflection; + final exampleContext = ExampleContext(); + + late Value exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Value.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Value.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/variable_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/variable_test.dart new file mode 100644 index 000000000000..673a3a631a7b --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/variable_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Variable', () { + final reflection = Variable.$reflection; + final exampleContext = ExampleContext(); + + late Variable exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Variable.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Variable.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/whale_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/whale_test.dart new file mode 100644 index 000000000000..9f42027badb3 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/whale_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Whale', () { + final reflection = Whale.$reflection; + final exampleContext = ExampleContext(); + + late Whale exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Whale.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Whale.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/xml_item_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/xml_item_test.dart new file mode 100644 index 000000000000..be6bcf12886d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/xml_item_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'XmlItem', () { + final reflection = XmlItem.$reflection; + final exampleContext = ExampleContext(); + + late XmlItem exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(XmlItem.canDeserialize(roundTripped, context), isTrue); + + final deserialized = XmlItem.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/models/zebra_test.dart b/samples/openapi3/client/petstore/dart/next/test/models/zebra_test.dart new file mode 100644 index 000000000000..8a1f88871d5d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/models/zebra_test.dart @@ -0,0 +1,62 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; + +void main() { + group(r'Zebra', () { + final reflection = Zebra.$reflection; + final exampleContext = ExampleContext(); + + late Zebra exampleInstance; + setUp(() { + exampleInstance = reflection.example(exampleContext); + }); + + test('validate', () { + expect(exampleInstance, isNotNull); + expect(exampleInstance.validate(), isTrue); + }); + + test('equals itself', () { + expect(exampleInstance, exampleInstance); + }); + + test('equals its clone', () { + final clone = exampleInstance.clone(); + expect(exampleInstance, modelEquals(clone, reflection: reflection)); + // test if equality is transitive + expect(clone, modelEquals(exampleInstance, reflection: reflection)); + }); + + parameterizedTest( + 'serialization roundtrip', + [ + SerializationContext.json( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + SerializationContext.xml( + fileBytesResolver: (file) => exampleContext.fileCache[file.name], + ), + ], + (SerializationContext context) { + final serialized = exampleInstance.serialize(context); + final roundTripped = context.split( + onJson: (context) { + final encoded = jsonEncode(serialized); + return jsonDecode(encoded); + }, + onXml: (context) { + final pretty = (serialized as XmlNode).toXmlString(pretty: true); + return XmlDocument.parse(pretty).firstElementChild; + }, + ); + expect(Zebra.canDeserialize(roundTripped, context), isTrue); + + final deserialized = Zebra.deserialize(serialized, context); + expect(deserialized.validate(), isTrue); + expect(deserialized, modelEquals(exampleInstance, reflection: reflection)); + } + ); + }); +} diff --git a/samples/openapi3/client/petstore/dart/next/test/networking/helpers_test.dart b/samples/openapi3/client/petstore/dart/next/test/networking/helpers_test.dart new file mode 100644 index 000000000000..286346fccac2 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/networking/helpers_test.dart @@ -0,0 +1,8 @@ +import '../utils.dart'; +import 'package:test/test.dart'; + +void main() { + group('OASNetworkingUtils', () { + test('works',(){}); + }); +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/test/serialization/helpers_test.dart b/samples/openapi3/client/petstore/dart/next/test/serialization/helpers_test.dart new file mode 100644 index 000000000000..8a0a1a6f9979 --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/serialization/helpers_test.dart @@ -0,0 +1,66 @@ +import '../utils.dart'; +import 'package:parameterized_test/parameterized_test.dart'; +import 'package:test/test.dart'; +import 'package:petstore_api/_internal.dart'; + +void main() { + group('Serialization Helpers', () { + parameterizedTest( + 'Uint8ListReflection.isBase64String', + [ + ['invalid string', false, null], + ['SGVsbG8gd29ybGQgIQ==', true, 'Hello world !'], + ['IA==', true, ' '], + ], + (String input, bool result, String? original) { + expect(Uint8ListReflection.isBase64String(input), result); + if (result) { + expect(utf8.decode(base64.decode(input)), original); + } + }, + ); + }); + + group('XML Reflection', () { + test( + 'test wrapped array', + () { + final rootXml = XmlReflection( + prefix: r'kl', + wrapped: true, + ); + final propReflection = UndefinedWrapperReflection(XmlReflectionWrapper( + xml: rootXml, + ListReflection(XmlReflectionWrapper( + xml: XmlReflection(prefix: r'mn', xmlName: r'my_item'), + PrimitiveReflection.forint, + )), + )); + final context = XmlSerializationContext() + .withOasNameContainer(OasNameWrapper(oasName: 'my_list')); + final serialized1 = context.handleAttributes( + rootXml, + context.wrapSerializedValue( + rootXml.getQualifiedName('my_list'), + propReflection.serialize( + UndefinedWrapper([]), + context, + ), + ), + ); + print(serialized1); + final serialized2 = context.handleAttributes( + rootXml, + context.wrapSerializedValue( + rootXml.getQualifiedName('my_list'), + propReflection.serialize( + UndefinedWrapper([1, 2, 3]), + context, + ), + ), + ); + print(serialized2); + }, + ); + }); +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart/next/test/utils.dart b/samples/openapi3/client/petstore/dart/next/test/utils.dart new file mode 100644 index 000000000000..fb0da0519d3d --- /dev/null +++ b/samples/openapi3/client/petstore/dart/next/test/utils.dart @@ -0,0 +1,325 @@ +import 'package:petstore_api/_internal.dart'; +import 'package:test/test.dart'; + +HttpResponseBase createFakeResponse({ + required int statusCode, + required Stream> bodyBytesStream, + Map headers = const {}, + String? contentType, + String? reasonPhrase, +}) { + return HttpResponseBase.stream( + originalRequest: HttpRequestBase.empty( + url: Uri.https("example.com", "/api"), method: 'GET'), + bodyBytesStream: bodyBytesStream, + statusCode: statusCode, + reasonPhrase: reasonPhrase, + headers: CaseInsensitiveMap.from({ + if (contentType != null) 'Content-Type': contentType, + ...headers, + }), + ); +} + +Stream> streamOfText(String value, {Encoding? encoding}) async* { + yield (encoding ?? utf8).encode(value); +} + +HttpResponseBase createFakeTextResponse({ + required int statusCode, + required String value, + Map headers = const {}, + String? contentType, + Encoding? encoding, + String? reasonPhrase, +}) { + var parsedContentType = + contentType == null ? null : MediaType.parse(contentType); + if (encoding != null) { + parsedContentType = parsedContentType?.change(parameters: { + ...parsedContentType.parameters, + 'charset': encoding.name, + }); + } + return createFakeResponse( + statusCode: statusCode, + headers: { + 'Content-Type': 'text/plain; charset=utf-8', + if (parsedContentType != null) + 'Content-Type': parsedContentType.toString(), + ...headers, + }, + reasonPhrase: reasonPhrase, + bodyBytesStream: streamOfText(value, encoding: encoding), + ); +} + +_DeepMatcher modelEquals( + T expected, { + required ModelReflection reflection, +}) { + return _DeepMatcher( + expected, + reflection: reflection, + ignoreAdditionalPropertiesExtraKeys: + reflection.anyOfs.isNotEmpty || reflection.oneOfs.isNotEmpty, + ); +} + +class ModelEqualsMatcher extends Matcher { + const ModelEqualsMatcher( + this.expected, { + required this.reflection, + }); + + final T expected; + final ModelReflection reflection; + @override + Description describe(Description description) { + return description.addDescriptionOf(expected).addDescriptionOf(reflection); + } + + @override + bool matches(Object? item, Map matchState) { + if (item is! T) { + return false; + } + return true; + } + + @override + Description describeMismatch( + Object? item, + Description mismatchDescription, + Map matchState, + bool verbose, + ) { + return super + .describeMismatch(item, mismatchDescription, matchState, verbose); + } +} + +class _DeepMatcher extends Matcher { + final T _expected; + final ModelReflection reflection; + final bool ignoreAdditionalPropertiesExtraKeys; + _DeepMatcher( + this._expected, { + required this.reflection, + required this.ignoreAdditionalPropertiesExtraKeys, + }); + + _Mismatch? _getMismatch({ + required Object? actual, + required TModel expected, + required ModelReflection reflection, + }) { + if (actual == _expected) { + return null; + } + if (actual is! TModel) { + return _Mismatch.simple( + '', + actual, + 'expected $TModel', + reflection: reflection, + ); + } + for (final prop in reflection.properties) { + final actualValue = prop.getter(actual); + final expectedValue = prop.getter(expected); + final eq = prop.reflection.equality; + if (!eq.equals(actualValue, expectedValue)) { + return _Mismatch( + 'property[${prop.dartName}]', + actualValue, + (description, verbose) => description.addDescriptionOf(expectedValue), + instead: true, + reflection: reflection, + ); + } + } + final additionalPropertiesPart = reflection.additionalPropertiesPart; + if (additionalPropertiesPart != null) { + final actualValue = additionalPropertiesPart.getter(actual); + final expectedValue = additionalPropertiesPart.getter(expected); + var err = (expectedValue.length == actualValue.length) + ? '' + : 'has different length and '; + for (var key in expectedValue.keys) { + if (!actualValue.containsKey(key)) { + return _Mismatch( + 'additionalProperties', + actual, + (description, verbose) => description + .add('${err}is missing map key ') + .addDescriptionOf(key) + .add('where the actual map is ') + .addDescriptionOf(actualValue), + reflection: reflection, + ); + } + } + + if (!ignoreAdditionalPropertiesExtraKeys) { + for (var key in actualValue.keys) { + if (!expectedValue.containsKey(key)) { + return _Mismatch( + 'additionalProperties', + actualValue, + (description, verbose) => description + .add('${err}has extra map key ') + .addDescriptionOf(key) + .add(' where the expected map is ') + .addDescriptionOf(expectedValue), + reflection: reflection, + ); + } + } + } + + for (var key in expectedValue.keys) { + final expectedPropValue = expectedValue[key]; + final actualPropValue = actualValue[key]; + + if (!additionalPropertiesPart.itemReflection.equality + .equals(expectedPropValue, actualPropValue)) { + // + return _Mismatch( + "additionalProperties['$key']", + actualPropValue, + (description, verbose) => + description.addDescriptionOf(expectedPropValue), + reflection: reflection, + ); + } + } + } + for (final (index, oneof) in reflection.oneOfs.indexed) { + final expectedValue = oneof.getter(expected); + final actualValue = oneof.getter(actual); + + if (!oneof.reflection.equality.equals(expectedValue, actualValue)) { + return _Mismatch( + 'oneOf[$index]', + actualValue, + (description, verbose) => description.addDescriptionOf(expectedValue), + reflection: reflection, + ); + } + } + for (final (index, anyof) in reflection.anyOfs.indexed) { + final expectedValue = anyof.getter(expected); + final actualValue = anyof.getter(actual); + if (!anyof.reflection.equality.equals(expectedValue, actualValue)) { + return _Mismatch( + 'anyOf[$index]', + actualValue, + (description, verbose) => description.addDescriptionOf(expectedValue), + reflection: reflection, + ); + } + } + + return _Mismatch( + '', + actual, + (description, verbose) => description + .add( + '== resulted in false, but no reason was found to explain it', + ) + .addDescriptionOf(expected), + reflection: reflection, + ); + } + + @override + bool matches(Object? actual, Map matchState) { + if (actual is! T) { + return false; + } + final mismatch = _getMismatch( + actual: actual, + expected: _expected, + reflection: reflection, + ); + if (mismatch == null) { + return true; + } + addStateInfo(matchState, {'mismatch': mismatch}); + return false; + } + + @override + Description describe(Description description) => + description.addDescriptionOf(_expected); + + @override + Description describeMismatch(Object? item, Description mismatchDescription, + Map matchState, bool verbose) { + var mismatch = matchState['mismatch'] as _Mismatch; + var describeProblem = mismatch.describeProblem; + if (mismatch.location.isNotEmpty) { + mismatchDescription + .add('at location ') + .add(mismatch.location) + .add(' is ') + .addDescriptionOf(mismatch.actual); + if (describeProblem != null) { + mismatchDescription + .add(' ${mismatch.instead ? 'instead of' : 'which'} '); + describeProblem(mismatchDescription, verbose); + } + } else { + // If we didn't get a good reason, that would normally be a + // simple 'is ' message. We only add that if the mismatch + // description is non empty (so we are supplementing the mismatch + // description). + if (describeProblem == null) { + if (mismatchDescription.length > 0) { + mismatchDescription.add('is ').addDescriptionOf(item); + } + } else { + describeProblem(mismatchDescription, verbose); + } + } + return mismatchDescription; + } +} + +class _Mismatch { + /// A human-readable description of the location within the collection where + /// the mismatch occurred. + final String location; + + /// The actual value found at [location]. + final Object? actual; + final SerializationReflection reflection; + + /// Callback that can create a detailed description of the problem. + final void Function(Description, bool verbose)? describeProblem; + + /// If `true`, [describeProblem] describes the expected value, so when the + /// final mismatch description is pieced together, it will be preceded by + /// `instead of` (e.g. `at location [2] is <3> instead of <4>`). If `false`, + /// [describeProblem] is a problem description from a sub-matcher, so when the + /// final mismatch description is pieced together, it will be preceded by + /// `which` (e.g. `at location [2] is which has length of 3`). + final bool instead; + + _Mismatch( + this.location, + this.actual, + this.describeProblem, { + this.instead = false, + required this.reflection, + }); + + _Mismatch.simple( + this.location, + this.actual, + String problem, { + required this.reflection, + }) : describeProblem = ((description, verbose) => description.add(problem)), + instead = false; +}