Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect method name generation #83

Closed
StarProxima opened this issue Sep 18, 2023 · 1 comment
Closed

Incorrect method name generation #83

StarProxima opened this issue Sep 18, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@StarProxima
Copy link
Collaborator

Hi, thanks for developing a great package, I am getting some errors when generating.

When generating method names in the rest client, a summary is used, which may not be valid for the name.

Result:

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

import '../shared_models/email_form.dart';
import '../shared_models/verify_email_response.dart';

part 'email_client.g.dart';

@RestApi()
abstract class EmailClient {
  factory EmailClient(Dio dio, {String baseUrl}) = _EmailClient;

  @POST('/auth/email/verify')
  Future<VerifyEmailResponse> проверитьEmailНаСуществованиеAuthEmailVerifyPost({  // <- error
    @Body() required EmailForm body,
  });
}

Expected result:

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

import '../shared_models/email_form.dart';
import '../shared_models/verify_email_response.dart';

part 'email_client.g.dart';

@RestApi()
abstract class EmailClient {
  factory EmailClient(Dio dio, {String baseUrl}) = _EmailClient;

  /// Проверить Email на существование
  @POST('/auth/email/verify')
  Future<VerifyEmailResponse> authEmailVerifyPost({
    @Body() required EmailForm body,
  });
}

OpenApi:

{
  "openapi": "3.1.0",
  "info": {
    "title": "Microservice Auth API methods",
    "version": "0.2.2"
  },
  "paths": {
    "/auth/email/verify": {
      "post": {
        "tags": [
          "Email"
        ],
        "summary": "Проверить Email На Существование",
        "description": "Вернет True, если пользователь с указанным Email уже зарегистрирован, иначе False.",
        "operationId": "Проверить_Email_на_существование_auth_email_verify_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailForm"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyEmailResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "EmailForm": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email",
            "description": "Адрес электронной почты"
          }
        },
        "type": "object",
        "required": [
          "email"
        ],
        "title": "EmailForm"
      },
      "VerifyEmailResponse": {
        "properties": {
          "exists": {
            "type": "boolean",
            "title": "Exists",
            "description": "Возвращает true, если сущность существует, иначе false"
          }
        },
        "type": "object",
        "required": [
          "exists"
        ],
        "title": "VerifyEmailResponse"
      }
    }
  },
  "tags": [
    {
      "name": "Auth",
      "description": "Auth Management"
    }
  ]
}
@Carapacik Carapacik self-assigned this Sep 18, 2023
@Carapacik Carapacik added the bug Something isn't working label Sep 18, 2023
Carapacik added a commit that referenced this issue Sep 18, 2023
@StarProxima
Copy link
Collaborator Author

StarProxima commented Sep 18, 2023

@Carapacik What do you think about the possibility of adding a flag to the swagger_parser configuration that leaves only path in the method name, and outputs summary as a documentation comment?

With the current implementation there are no errors, but there may be difficulties in interpreting method names as only some words may be used.

If you want I could look into implementing this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants