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

swaggerCombine function "format" option not working #91

Open
Mcourt opened this issue Sep 4, 2019 · 0 comments
Open

swaggerCombine function "format" option not working #91

Mcourt opened this issue Sep 4, 2019 · 0 comments
Labels

Comments

@Mcourt
Copy link

Mcourt commented Sep 4, 2019

Describe the bug

When using the swaggerCombine function in javascript with dynamic configuration, the { format : 'yaml' } is not taken into account, and a json is still being returned.

To Reproduce

  1. Given the following code :
const swaggerJson = {
  swagger: "2.0",
  info: {
    title: "Swagger Combine Rename by regular expression Example",
    version: "1.0.0"
  },
  apis: [
    {
      url: "http://petstore.swagger.io/v2/swagger.json",
      paths: {
        rename: [
          { 
            type: "regex",
            from: /\/pet\/(.*)/,
            to: "/pet/alive/$1"
          },
          { 
            type: "function",
            to: (path) => path === "/pet/alive/{petId}" ? "/pet/alive/{petAliveId}" : path
          }
        ]
      }
    },
    {
      url: "https://api.apis.guru/v2/specs/medium.com/1.0.0/swagger.yaml"
    }
  ]
}

swaggerCombine(swaggerJson, { format: 'yaml' }, (err, result) => {
  if(err){
    console.log(err);
    return;
  }
  
  console.log(result); // "result" is still a json object
}  )

Expected behavior
The swaggerCombine callback should have the combined schema in yml format as parameter.

Additional context
I might be wrong, but it seems the "toString()" method of the SwaggerCombine class is never called.

@fabsrc fabsrc added the bug label Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants