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

Swagger: Inconsistency between service .bal file and .bal file created back from yaml #12518

Closed
ChinthakaSenanayaka opened this issue Dec 5, 2018 · 1 comment
Assignees
Labels

Comments

@ChinthakaSenanayaka
Copy link
Contributor

ChinthakaSenanayaka commented Dec 5, 2018

Description:
Create swagger yaml from service bal file. Then created services bal file from that swagger file are not equal.

Steps to reproduce:
hellow_world_service.bal

import ballerina/http;
import ballerina/log;

// By default, Ballerina exposes a service via HTTP/1.1.
service hello on new http:Listener(9091) {

    // Invoke all resources with arguments of server connector and request.
    resource function sayHello(http:Caller caller, http:Request req) {
        http:Response res = new;
        // Use a util method to set a string payload.
        res.setPayload("Hello, World!");

        // Send the response back to the caller.

        var result = caller->respond(res);
        if (result is error) {
            log:printError("Error sending response", err = result);
        }
    }
}

Created swagger file:
hello_world_service.swagger.yaml

openapi: 3.0.1
info:
  title: hello
  version: 1.0.0
servers:
- url: /hello
paths:
  /sayHello: {}
components: {}

bal file created from the swagger yaml (hello.bal):

import ballerina/http;
import ballerina/log;
import ballerina/mime;
import ballerina/swagger;

listener http:Listener ep0 = new(9090);

@swagger:ServiceInfo {
    title: "hello",
    serviceVersion: "1.0.0"
}
@http:ServiceConfig {
    basePath: "/"
}
service hello on ep0 {
    resource function sayHello (http:Caller outboundEp, http:Request _sayHelloReq) {
        http:Response _sayHelloRes = new;
        string _sayHelloPayload = "Sample sayHello Response";
        _sayHelloRes.setTextPayload(_sayHelloPayload);
        _ = outboundEp->respond(_sayHelloRes);
    }

}

hellow_world_service.bal service is at GET http://0.0.0.0:9090/hello/sayHello
hello.bal service is at GET http://0.0.0.0:9090/sayHello

Affected Versions:
ballerina-0.983.1-SNAPSHOT or 0.990.0-rc1

OS, DB, other environment details and versions:

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

@NipunaMarcus
Copy link
Contributor

This has been added in to the refactor effort in the swagger tool hence closing this issue...

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

3 participants