Forum Discussion

pranaysahay's avatar
pranaysahay
New Contributor
5 years ago

Issue in #ref while generating Server side spring code

I am quite new to Swagger UI and working on generating Spring code (Server) from a given YAML file. Here is my problem statement. 

The yaml file has few objects which are present in another yaml file and it uses #ref to refer them. Here is an example:

--------------------------------------------------------------------------------------------------------

- name: supported-features
  in: query
  description: To filter irrelevant responses related to unsupported features
  schema:
  $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures'

--------------------------------------------------------------------------------------------------------

The attribute "SupportedFeatures" is defined as "String" (Primitive Type) datatype in TS29571_CommonData.yaml file. 

 

The issue is when I am generating the code, the resulting java code is as follows:

import io.swagger.model.TS29571CommonDataYamlcomponentsschemasSupportedFeatures;

1. How do I make sure that the compiler actually opens the referred yaml file and generate the code correctly? As its a primitive datatype, we even dont need to import this. 

2. Secondly, how can I change the package name. (io.swagger.api)

 

Apologize if this query has been already asked.

 

Thanks 

Pranay

 

  • Thanks for the reply. Its working now. I am using Openapi-generator for generating the stubs. (Spring). The issue was coming on DateTime for which I am using joda.

    java -jar openapi-generator-cli-5.0.0-beta.jar generate -i TS29520_Nnwdaf_EventsSubscription.yaml -g spring -c run.conf -o out

  •  Hey pranaysahay , can you please clarify what tool are you using to generate code in order to give you a response?

     

    For example, if you use swagger-codegen CLI, you can change api package and model package with the following options:

    --api-package

    --model-package

     

    From swagger editor tool, those options are not available for input afik

     

    • pranaysahay's avatar
      pranaysahay
      New Contributor

      Thanks for the reply. Its working now. I am using Openapi-generator for generating the stubs. (Spring). The issue was coming on DateTime for which I am using joda.

      java -jar openapi-generator-cli-5.0.0-beta.jar generate -i TS29520_Nnwdaf_EventsSubscription.yaml -g spring -c run.conf -o out