swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

muti small yaml files does not work by ref in yaml file

Open zcb22000 opened this issue 9 years ago • 6 comments

I want to split yaml file to small files. But it doesn't work when generate. How to use muti yaml files for micro-service project? And How to specified apipackage and modulpackge for each yaml file? I am followd with "http://azimi.me/2015/07/16/split-swagger-into-smaller-files.html".

Description
Swagger-codegen 2.2.1
Swagger declaration file content or url

paths: $ref: './paths/index.yaml'

definitions: $ref: ./definitions/definitions.yaml

Command line used for generation
    CodegenConfigurator configurator = CodegenConfigurator.fromFile(configFile);
    new DefaultGenerator().opts(configurator.toClientOptInput()).generate();

    Path outputFile = Paths.get(asciidocFile);

    Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() 
            .withPathsGroupedBy(GroupBy.TAGS)
            .withOperationOrdering(OrderBy.NATURAL)
            .withOutputLanguage(Language.ZH) 
            .withMarkupLanguage(MarkupLanguage.ASCIIDOC)
            .build(); 
    Swagger2MarkupConverter.from(configurator.getInputSpec()) 
            .withConfig(config)
            .build() 
            .toFolder(outputFile);; 
Steps to reproduce

The output json as bellow: { "swagger" : "2.0", "info" : { "version" : "1.1.0", "title" : "IoT Platform NSCL Service REST API", "termsOfService" : "used for Application developing" }, "host" : "184.2.9.57:8843", "basePath" : "/iocm/app/v1.1.0", "tags" : [ { "name" : "订阅管理", "description" : "订阅管理" }, { "name" : "事件管理", "description" : "事件管理" } ], "schemes" : [ "https" ], "consumes" : [ "application/json" ], "produces" : [ "application/json" ], "paths" : { }, "securityDefinitions" : { "basic_auth" : { "type" : "basic" }, "app_key" : { "type" : "apiKey", "name" : "app_key", "in" : "header" } }, "definitions" : { }, "securityRequirement" : [ { "app_key" : [ ] }, { "basic_auth" : [ ] } ] }

Related issues
Suggest a Fix

zcb22000 avatar Jan 16 '17 12:01 zcb22000

@zcb22000 you're using 2.2.1. Please pull the latest master to give it a try as the latest Swagger Codegen uses a newer version of Swagger parser with better handling of external references.

wing328 avatar Jan 17 '17 06:01 wing328

Closing this as there's no update.

wing328 avatar Feb 17 '17 07:02 wing328

this is still not working on 2.2.2

valeriucraciun avatar Mar 16 '17 13:03 valeriucraciun

@valeriucraciun please share the spec via https://gist.github.com so that we can more easily reproduce the issue.

wing328 avatar Mar 20 '17 06:03 wing328

It works on master (2.2.3-SNAPSHOT).Will this be released soon ? this is an important feature i guess.

XtreZz avatar Mar 23 '17 12:03 XtreZz

2.2.3 will be released 3 or 4 months later.

Upcoming release is 2.3.0, which is scheduled to be released in Apr 2017. Please test 2.3.0 as well.

wing328 avatar Mar 23 '17 12:03 wing328