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

fix: getting first available content type for parametersV2 method #133

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

elenaferr0
Copy link
Contributor

I added another check in the parametersV2 method so that if there is a content type which is not multipart or form url encoded it is added to the request.
For example, I would expect the following swagger:

{
  "swagger": "2.0",
  "info": {
    "description": "",
    "version": "",
    "title": "Test swagger"
  },
  "host": "localhost:8081",
  "basePath": "/",
  "tags": [
    {
      "name": "Tests",
      "description": "Test Controller"
    }
  ],
  "paths": {
    "/test": {
      "patch": {
        "tags": [
          "Tests"
        ],
        "description": "Description",
        "operationId": "operationId",
        "consumes": [
          "application/json-patch+json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  },
  "definitions": {}
}

to generate the following dart code:

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

  /// Description
  @Headers(<String, String>{'Content-Type': 'application/json-patch+json'})
  @PATCH('/test')
  Future<void> operationId();
}

But instead generates this (the @Headers annotation is missing):

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

  /// Description
  @PATCH('/test')
  Future<void> operationId();
}

I also fixed the parser request_tests for v2 (callingactualRestClient.last in that scenario always returns the same element, therefore not all the list element were properly compared). The basic paths check 3.0 test has the same issue, if you switch from

expect(actualRestClients.last, expectedRestClients.last);

to

expect(actualRestClients[i], expectedRestClients[i]);

the test fails, it seems that the returnType is different but I didn't manage to understand why.

@elenaferr0 elenaferr0 changed the title fix: getting first available content type for paramsV2 method fix: getting first available content type for parametersV2 method Oct 31, 2023
Copy link
Owner

@Carapacik Carapacik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@Carapacik Carapacik merged commit 4e5eaf6 into Carapacik:main Oct 31, 2023
2 checks passed
@Carapacik Carapacik added the bug Something isn't working label Feb 26, 2024
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

Successfully merging this pull request may close these issues.

2 participants