Skip to content

Warning on referenced example #1162

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

Closed
EstebanDugueperoux2 opened this issue May 12, 2021 · 3 comments
Closed

Warning on referenced example #1162

EstebanDugueperoux2 opened this issue May 12, 2021 · 3 comments

Comments

@EstebanDugueperoux2
Copy link

EstebanDugueperoux2 commented May 12, 2021

Describe the bug
I get the same problem as #437 but for example in RequestBody

To Reproduce
Steps to reproduce the behavior:
Have an operation with a complex object in parameter to be specified in JSON:

  public ResponseEntity<CommissionDto> updateCommission(

@Parameter(description = "Security account number to update the Commission", required = true) @PathVariable("id") @Size(min = SecuritiesAccount.SECURITY_ACCOUNT_ID_SIZE, max = SecuritiesAccount.SECURITY_ACCOUNT_ID_SIZE) @Valid String id,

@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "A Security account's commission rates to update", required = true, content = @Content(schema = @Schema(implementation = CommissionDto.class), examples = @ExampleObject(name = "requestBodyExample", ref = PUT_COMMISSION_REQUEST_BODY_EXAMPLE_KEY))) @RequestBody(required = true) @Valid CommissionDto commission

){
...
}

Expected behavior
I expect to have a valid openapi.yaml, i.e. without description field in example which give a warning when using https://editor.swagger.io/:

paths:
  '/api/v1/commissions/{id}':
    put:
      tags:
        - commissions-resource
      summary: Updates the security account's commission details into Base tiers repository
      description: updateCommission
      operationId: updateCommission
      parameters:
        - name: id
          in: path
          description: Security account number to update the Commission
          required: true
          schema:
            maxLength: 21
            minLength: 21
            type: string
      requestBody:
        description: A Security account's commission rates to update
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Commission'
            examples:
              requestBodyExample:
                description: requestBodyExample
                $ref: '#/components/examples/httpPutCommissionRequestBodyExample'

Could we have a similar fix than in 437 issue?

Thanks in advance.

@bnasslahsen
Copy link
Collaborator

@EstebanDugueperoux2,

The description is not even readable.
Please make sure you format the code and use github code/syntax highlighting features.

@EstebanDugueperoux2
Copy link
Author

Do you agree this issue?

@bnasslahsen
Copy link
Collaborator

bnasslahsen commented May 22, 2021

@EstebanDugueperoux2 ,

You sample, is referencing many missing objects...
Remove the name of the ExampleObject, if you want use ref instead.
@ExampleObject(ref = PUT_COMMISSION_REQUEST_BODY_EXAMPLE_KEY)

swagger-core, sets the description of the example with it's name if present.

For any future ticket you want to open, please make sure you follow the contribution guide, section using GITHUB ISSUES.

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

No branches or pull requests

2 participants