Carapacik / swagger_parser

Dart package that takes an OpenApi definition file and generates REST clients based on retrofit and data classes for your project.
https://pub.dev/packages/swagger_parser
MIT License
88 stars 33 forks source link

dio import name clash #194

Open dickermoshe opened 4 months ago

dickermoshe commented 4 months ago
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, unused_import

import 'package:dio/dio.dart';
import 'package:retrofit/retrofit.dart';

import '../models/options.dart';

part 'client_client.g.dart';

@RestApi()
abstract class ClientClient {
  factory ClientClient(Dio dio, {String? baseUrl}) = _ClientClient;

  @GET('/test')
  Future<String> test({
    @Query('options') Options? options, // <<< Dio has an Option, we need to use prefixes
  });
}

Schema

openapi: 3.0.3
info:
  title: deepobject-array-with-pattern-test
  version: 1.0.0
paths:
  /test:
    get:
      operationId: test
      parameters:
        - name: options
          in: query
          required: false
          style: deepObject
          schema:
            $ref: '#/components/schemas/Options'
          explode: true
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                type: string
components:
  schemas:
    Options:
      type: object
      properties:
        a:
          type: array
          items:
            type: string
            pattern: '^[A-Z].*'
dickermoshe commented 4 months ago

Proposal we add a suffix Model to each Dto. We can make it customizable via config E.G Instead of Person it will be PersonModel This suffix will be customizable via config It would be a breaking change

dickermoshe commented 4 months ago

@Carapacik How to you want to handle this?