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

No default value assigned by code generation #14

Open
acloudiator opened this issue Dec 18, 2018 · 2 comments
Open

No default value assigned by code generation #14

acloudiator opened this issue Dec 18, 2018 · 2 comments
Assignees

Comments

@acloudiator
Copy link

in some cases, described below, yang default parameter is not taken into account by code generation.

Case1 (working):

leaf pathcost {
  type int32;
  default 1;
  description "Cost of this route";
  router:cli-example "10";
}
int32_t m_pathcost;
m_pathcost = 1;

Case2 (not working):

leaf pathcost {
  type uint32;
  default 1;
  description "Cost of this route";
  router:cli-example "10";
}
//No default value is generated by codegen
uint32_t m_pathcost;

Case3 (not working):

leaf pathcost {
  type string;
  default "1";
  description "Cost of this route";
  router:cli-example "10";
}
std::string m_pathcost;
m_pathcost = 1; // it should be a string, so "1"

Case4 (not working):

leaf pathcost {
  type uint8;
  default 1;
  description "Cost of this route";
  router:cli-example "10";
}
uint8_t m_pathcost;
// no default value is set
  • Matteo
@acloudiator
Copy link
Author

The string case has been fixed: a0059af.

The cases for unsigned integers are more difficult to solve because this is a issue in swagger-codegen base code: swagger-api#6929.

A workaround for now is to use signed integers instead of unsigned.

  • Mauricio

@mauriciovasquezbernal mauriciovasquezbernal transferred this issue from polycube-network/polycube Jun 6, 2019
@FedeParola
Copy link

I think the problem is in swagger-core module used by swagger-codegen.
While properties of type intX are converted to an object of class io.swagger.models.properties.IntegerProperty
that has a getDefault() method, all other integer properties (unsigned and all the ones derived from an integer using a typedef) are converted to an instance of io.swagger.models.properties.BaseIntegerProperty
that lacks the getDefault() method.
Currently I don't know how to overcome this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants