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

Why is different code generated with the same swagger file? I give an example below. #770

Open
rym236 opened this issue Oct 4, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@rym236
Copy link

rym236 commented Oct 4, 2024

The project was like this from the beginning and everything worked well.

//Login and password authorization
  ///@param username Name
  ///@param password password
  Future<chopper.Response<Object>> loginJsonPost({
    required String? username,
    required String? password,
  }) {
    return _loginJsonPost(username: username, password: password);
  }

///Login and password authorization
  ///@param username Name
  ///@param password password
  @Post(
    path: '/login.json',
    optionalBody: true,
  )
  Future<chopper.Response<Object>> _loginJsonPost({
    @Query('username') required String? username,
    @Query('password') required String? password,
  });

After regenerating the chopper code, it became like this and now an error occurs when trying to log in
Error:type 'Response' is not a subtype of type 'Response<LoginJsonPost$Response>' in type cast:

Future<chopper.Response<LoginJsonPost$Response>> loginJsonPost({
    required String? username,
    required String? password,
  }) {
    generatedMapping.putIfAbsent(
        LoginJsonPost$Response, () => LoginJsonPost$Response.fromJsonFactory);

    return _loginJsonPost(username: username, password: password);
  }

  ///Login and password authorization
  ///@param username Name
  ///@param password password
  @Post(
    path: '/login.json',
    optionalBody: true,
  )
  Future<chopper.Response<LoginJsonPost$Response>> _loginJsonPost({
    @Query('username') required String? username,
    @Query('password') required String? password,
  });

However, the swagger code for this method has not changed.
Please tell me why this is happening, what needs to be done to return to the previous state?

@rym236 rym236 added the question Further information is requested label Oct 4, 2024
@rym236 rym236 closed this as completed Oct 7, 2024
@Vovanella95
Copy link
Collaborator

Hello!

Old version returned Object as a return type. New version supports responses as models. In your case it's LoginJsonPost$Response. Previously, you had Object and needed to parse it manually.

Regarding your error (Response<LoginJsonPost$Response>' in type cast) I need more details. On which line it's occurs?

@Vovanella95 Vovanella95 reopened this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants