Forum Discussion

kdivelbiss's avatar
kdivelbiss
New Contributor
4 years ago

Error Creating Functional Test

Trying to set up first functional test using the swagger.json file.  Receiving the error "attribute components.schemas.Schema name EagleSvc.API.Utilities.ExceptionHandling.ApiResponse+ApiResponseContent doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$"

Using open api: "3.0.1" and ReadyAPI 3.7.0.

 

Here is an excerpt from the json file:

        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EagleSvc.API.Utilities.ExceptionHandling.ApiResponse+ApiResponseContent"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EagleSvc.API.Utilities.ExceptionHandling.ApiResponse+ApiResponseContent"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/EagleSvc.API.Utilities.ExceptionHandling.ApiResponse+ApiResponseContent"
                }
              }
            }
          }

 This is the attribute applied to the action showing the custom return type:

[ProducesResponseType(typeof(ApiResponse.ApiResponseContent), StatusCodes.Status200OK)]

 

Is this not supported by ReadyAPI?

 

Thanks.

  • Hey kdivelbiss. It looks like the regular expression in the error message doesn't like the brackets in the attribute. But if a definition is valid OAS, then ReadyAPI should be able to import it.

     

    Would it be possible for you to attach the definition file in question so I can do a quick test on my machine to see if I can import it?

    • kdivelbiss's avatar
      kdivelbiss
      New Contributor

      Hi joejoyce. Thanks for responding.  I've isolated the issue to that of using a public nested class as the response type as well as using the SwaggerGenOption c.CustomSchemaIds(x => x.FullName).  This produces a schema definition in the swagger.json file containing the '+' character (Namespace.ParentClass+NestedClass).  When importing the api definition in ReadyApi, I get the error message:

      "attribute components.schemas.Schema name Namespace.ParentClass+NestedClass doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$"

       

      If the nested class is moved outside the parent class, then the schema in the swagger.json file is generated using a '.' instead of a '+' and it works.

       

      I have attached a sample project that demonstrates this. 

      • kdivelbiss's avatar
        kdivelbiss
        New Contributor

        joejoyce I just wanted to follow up with the question about whether or not the issue of the ReadyAPI not being able to import the schema in the generated swagger.json file when it contains the '+' character is expected behavior or not.  If it is, then I will work on refactoring our code so that it generates the schema without the '+' character.

         

        Thanks.