Skip to content

Commit

Permalink
fix: The URL parameters with underscores cannot be correctly converte…
Browse files Browse the repository at this point in the history
…d to camel case. jonasbark#7

jonasbark#7

The URL parameters with underscores are not being correctly converted to camel case in the generated code. This issue occurs when using the OpenAPI YAML file with the following configuration:

/v1/students/{student_id}/courses/reading:
  get:
    operationId: getV1StudentsStudentIdCourses
    parameters:
    - name: student_id
      in: path
      required: true
      schema:
        type: string
Generated Code Example
The generated code does not properly convert the student_id parameter to camel case (studentId):

Future<Response<ApiV1EntitiesBasicCourse>>
    getV1StudentsStudentIdCourses(
        {required String studentId}) async {
  final queryParams = <String, dynamic>{};
  final uri = baseUri.replace(
      queryParameters: queryParams,
      path: baseUri.path +
          '/v1/students/${student_id}/courses');
  final response = await dio.getUri<Map<String, dynamic>>(uri);
  final parsed = ApiLearningV1EntitiesBasicCourse.fromJson(response.data!);
  return Response<ApiLearningV1EntitiesBasicCourse>(
    data: parsed,
    headers: response.headers,
    requestOptions: response.requestOptions,
    isRedirect: response.isRedirect,
    statusCode: response.statusCode,
    redirects: response.redirects,
    extra: response.extra,
  );
}
Expected Behavior
The parameter student_id should be correctly converted to camel case (studentId) in the generated code, ensuring consistency and correct functionality.
  • Loading branch information
qwlong authored Jul 6, 2024
1 parent 966c955 commit 8012b29
Showing 1 changed file with 319 additions and 305 deletions.
Loading

0 comments on commit 8012b29

Please sign in to comment.