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

Error when handling response with the field name "type" #122

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

Goodmain
Copy link
Contributor

@Goodmain Goodmain commented Apr 19, 2024

Description

We have an issue when the response contains a field with the name type. Here is an example of response structure:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "type": {
      "type": "string"
    },
    "comment": {
      "type": "string",
      "nullable": true
    },
    "color_code": {
      "nullable": true,
      "type": "string"
    }
  }
}

When we are trying to get the definition of the field the following error occurs:

TypeError: Cannot access offset of type string on string in /app/vendor/ronasit/laravel-swagger/src/Services/SwaggerService.php:325

The reason is that the Arr::get takes the first occurrence on the type in the array, not the correct one.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@Goodmain Goodmain requested a review from DenTray April 19, 2024 05:19
Copy link

sonarcloud bot commented Apr 19, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@DenTray DenTray merged commit 37ed94f into master Apr 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants