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

Fix for issue-33 : handling required field #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
package com.mrv.yangtools.codegen.impl;

import com.mrv.yangtools.codegen.DataObjectBuilder;
import com.mrv.yangtools.common.BindingMapping;

import io.swagger.models.*;
import io.swagger.models.properties.*;
import org.opendaylight.yangtools.yang.common.QName;
Expand Down Expand Up @@ -250,6 +252,16 @@ protected Pair prop(DataSchemaNode node) {
} else if (node instanceof LeafSchemaNode) {
LeafSchemaNode lN = (LeafSchemaNode) node;
prop = getPropertyByType(lN);
if (prop != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you decided to set required only for simple fields? Swagger allows you to define it at any property as well as YANG defines it at DataSchemaNode so it can be applied for all types of nodes

//Map mandatory to required
if (lN.getConstraints().isMandatory() == true)
prop.setRequired(lN.getConstraints().isMandatory());

//Set default value;
if (lN.getDefault() != null)
prop.setDefault(lN.getDefault());

}
} else if (node instanceof ContainerSchemaNode) {
prop = refOrStructure((ContainerSchemaNode) node);
} else if (node instanceof ListSchemaNode) {
Expand Down