Forum Discussion

akash's avatar
Occasional Visitor
4 years ago

Model class name mismatch when using special characters in API name (operationId)

Say I have an endpoint named: "SEQ-case-investigate-review-results: Review results"

Then when I export this to OpenAPI/Swagger 2.0 (JSON) format, I get the following parameters for this endpoint (along with others):

"operationId": "SEQ-case-investigate-review-results:Reviewresults" and 

"schema": {
"$ref": "#/definitions/SEQ-case-investigate-review-results%3AReviewresultsRequest"

You can see that the $ref is url encoded.

I have lots of API with special characters in their name/operationId, which I got from third party.

Due to this, when I'm creating a server stub using SwaggerHub for Java (I've tried JAX-RS and Spring), my model classes are being misnamed in its source code. So if we take the above example, the model class is named "SEQCaseInvestigateReviewResultsReviewresultsRequest". The other classes wanting to use this class are using the name "SEQCaseInvestigateReviewResults3AReviewresultsRequest". SwaggerHub is somehow encoding the name used while "calling" and is not encoding the name for generating the actual model class.

3 Replies

  • Hello akash 


    I was able to reproduce this issue locally, meantime a solution is made i would recommend use the original definition name instead the encoded one, the editor will point that as an error but you can still generates code and get the expected output.


    So for your case you just need to use:

    "schema": {
    "$ref": "#/definitions/SEQ-case-investigate-review-results:ReviewresultsRequest"


    "schema": {
    "$ref": "#/definitions/SEQ-case-investigate-review-results%3AReviewresultsRequest"


    • sonya_m's avatar
      SmartBear Alumni (Retired)

      Thanks a lot hugomario!


      akash does the solution work for you?