Skip to content

[scala-sttp] fix enumeration operator constant name collision - #10596

Merged
wing328 merged 3 commits into
OpenAPITools:masterfrom
bgong-mdsol:fix/enumeration-operator-constant-name-collision
Mar 1, 2022
Merged

[scala-sttp] fix enumeration operator constant name collision#10596
wing328 merged 3 commits into
OpenAPITools:masterfrom
bgong-mdsol:fix/enumeration-operator-constant-name-collision

Conversation

@bgong-mdsol

@bgong-mdsol bgong-mdsol commented Oct 13, 2021

Copy link
Copy Markdown
Contributor

This PR fixes the issue #10187

Here is the openapi spec that can be used to reproduce the issue and verify the fix.

openapi: 3.0.3
info:
title: The comparison operator
version: '1.0'
paths:
/state:
  get:
    operationId: getReport
    responses:
      '200':
        description: get Report
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Reports'
components:
schemas:
  Reports:
    properties:
      name:
        type: string
      expression:
        items:
          $ref: '#/components/schemas/Condition'
        type: array
  Condition:
    example:
      variable: variable
      operator: =
      comparison_value: comparison_value
    properties:
      variable:
        type: string
      comparison_value:
        type: string
      operator:
        description: The comparison operator.
        enum:
        - =
        - '!='
        - '>'
        - <
        - '>='
        - <=
        type: string
    type: object

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@chameleon82 @clasnake @jimschubert @shijinkui @ramzimaalej @Bouillie @wing328 @jfeltesse-mdsol @jcarres-mdsol

@bgong-mdsol

Copy link
Copy Markdown
Contributor Author

@chameleon82 @clasnake @jimschubert @shijinkui @ramzimaalej @Bouillie @wing328 could you review this PR when you have time?

@chameleon82

chameleon82 commented Oct 21, 2021

Copy link
Copy Markdown
Contributor

Hi @bgong-mdsol,
Thank you for the PR.
Wondered if you could provide actual use case for those enums. Would it be better to use named enums like LESS_OR_EQUALS_THAN in the first place rather than "<="?

@jfeltesse-mdsol

Copy link
Copy Markdown
Contributor

@chameleon82 the sample openapi file is an excerpt of an API that one of the many services our organization manages provides. This is a valid openapi file and as such the generator should support such edge cases, however questionable the API design may seem.

@chameleon82

chameleon82 commented Oct 21, 2021

Copy link
Copy Markdown
Contributor

@jfeltesse-mdsol @bgong-mdsol

Upd: sorry, it is already discussed in the related issue #10187

Could you please add test with spec?

Approved from my side

@agilob

agilob commented Oct 21, 2021

Copy link
Copy Markdown
Contributor

Could you add tests for the changes?

@bgong-mdsol

bgong-mdsol commented Oct 22, 2021

Copy link
Copy Markdown
Contributor Author

@chameleon82 @agilob I have added the test case in 81efe8f.

Try with the cmd:
mvn test -Dtest=SttpCodegenTest#verifyOperatorName test

@jfeltesse-mdsol

Copy link
Copy Markdown
Contributor

@chameleon82 @agilob can you have a look at the tests that were added in that last commit? 🙇

@wing328

wing328 commented Nov 24, 2021

Copy link
Copy Markdown
Member

The CircleCI failure is not related to this PR. If you merge latest master into this branch, it should resolve it.

@bgong-mdsol

Copy link
Copy Markdown
Contributor Author

@wing328 Sorry for late reply, I have merged latest master into this branch, thanks

@wing328
wing328 merged commit 417d694 into OpenAPITools:master Mar 1, 2022
@wing328 wing328 added this to the 6.0.0 milestone Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants