Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #10522
Closed
Open
Issue created Oct 04, 2021 by Administrator@rootContributor

[dart-dio-next] [BUG] Import mappings are not working

Created by: HerrNiklasRaab

Before reading the issue, the following two things are important:

  • I am supporting fixing this issue with 50€
  • I know that there is the option "dateLibrary: timemachine", but I need to solve it using "import-mappings" because of another reason I don't want to go into here (which should be possible, because I was already able to set up below use case in the backend).

I am running openapi-generator with the following command:

openapi-generator generate -g dart-dio-next \
-i ./api/_config/specs/backend-functional.yml \
-o ./api/backend-api \
-c ./api/_config/specs/backend-functional-config.yml

with the this configuration:

additionalProperties:
  pubName: backend_api
typeMappings:
  object: dynamic
  JsonObject: dynamic
  LocalDate: LocalDate
importMappings:
  LocalDate: "package:time_machine/time_machine.dart"

with this yaml:

CronRunConfiguration:
  properties:
    fakeDate:
      $ref: "#/components/schemas/LocalDate"

LocalDate:
  type: object

which generates the following code:

//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//

import 'package:built_collection/built_collection.dart';
import 'package:backend_api/src/model/local_date.dart'; // Wrong import, expected: "package:time_machine/time_machine.dart"
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'cron_run_configuration.g.dart';

/// CronRunConfiguration
///
/// Properties:
/// * [fakeDate] 
/// * [runCronFor] 
abstract class CronRunConfiguration implements Built<CronRunConfiguration, CronRunConfigurationBuilder> {
    @BuiltValueField(wireName: r'fakeDate')
    LocalDate? get fakeDate;

// ... The rest of the file is not important

what I would have expected is the following:

//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//

import 'package:built_collection/built_collection.dart';
import 'package:time_machine/time_machine.dart'; // This is the important line
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'cron_run_configuration.g.dart';

/// CronRunConfiguration
///
/// Properties:
/// * [fakeDate] 
/// * [runCronFor] 
abstract class CronRunConfiguration implements Built<CronRunConfiguration, CronRunConfigurationBuilder> {
    @BuiltValueField(wireName: r'fakeDate')
    LocalDate? get fakeDate;

// ... The rest of the file is not important

cc @kuhnroyal @wing328 Can you reproduce?

Assignee
Assign to
Time tracking