Forum Discussion

sentrt86's avatar
sentrt86
Occasional Contributor
2 years ago

How to create ready api file through power shell script

Here is the requirement.

 

I wanted to download the yaml file of a API from APIM portal and convert that into ready api XML File through azure ado pipeline.

  • nmrao's avatar
    nmrao
    Champion Level 3

    What do you mean by "convert that into ready api XML File"?

    Is that readyapi project to be created automatically and import the yaml file? or just an update?

    • sentrt86's avatar
      sentrt86
      Occasional Contributor

      We need to create the readyapi project automatically with the input as yaml file, Currently we do it manually on the app, instead of that is there any script available to create the ready api project based on the input yaml file, our ultimate goal is to create this through azure ADO pipeline, Create the ready api file project and run the ready api file and deploy it to other env.

  • nmrao's avatar
    nmrao
    Champion Level 3

    While it is possible to generate the readyapi project automatically, that isn't just enough i.e., the test cases are required, right?

    • sentrt86's avatar
      sentrt86
      Occasional Contributor

      Thats correct. test case is going to be Unit testing from APIM standpoint? can you please give me some leads how to create the readyapi project automatically.

  • nmrao's avatar
    nmrao
    Champion Level 3

    I mean how are you going to use that project without test cases?

    Regarding the project creation, should be able to find some  sample online or use Javadoc for referring to API

    • sentrt86's avatar
      sentrt86
      Occasional Contributor

      Its simple happy path test case. we run the functional test to make sure APIM api unit testing works good until set-backend url policy. we are not going to do more test scenarios only one uri path mapping to APIM code. thats it

      • nmrao's avatar
        nmrao
        Champion Level 3

        Where is the functional test defined and how it is going to be exeucted - this part i didn't understand.

        What do you mean "to make sure APIM api unit testing works good"?

  • sentrt86's avatar
    sentrt86
    Occasional Contributor

    nmrao  can you please help me get some snippet for converting yaml into soap ui from command line ? I tried my best but i couldnt get one. Any help would be greatly appreciated

     

  • nmrao's avatar
    nmrao
    Champion Level 3

    You can try below sample java to generate the soap ui project. follow the comments inline.

    import com.eviware.soapui.impl.WsdlProject;
    import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlImporter;
    
    
    public class SoapUIProjectCreator {
    
        public static void main(String[] args) {
            // Specify the path to your SoapUI project file
            String projectFilePath = "/path/to/your/project.xml";
    
            // Specify the path to your YAML file
            String yamlFilePath = "/path/to/your/file.yaml";
    
            // Create a new SoapUI project
            WsdlProject project = new WsdlProject();
    
            try {
                // Import the YAML file
                WsdlImporter.importWsdl(project, yamlFilePath);
    
                // Save the project to a file
                project.saveAs(projectFilePath);
                System.out.println("Project created and YAML file imported successfully!");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

     

  • sentrt86's avatar
    sentrt86
    Occasional Contributor

    Thank you for your response. I am trying this option achieve through CLI. Basically from Azure pipeline. is there something we can do through script?