Skip to content

Codegen conversation - #646

Closed
mkistler wants to merge 8 commits into
watson-developer-cloud:conv-workspacesfrom
mkistler:codegen-conversation
Closed

Codegen conversation#646
mkistler wants to merge 8 commits into
watson-developer-cloud:conv-workspacesfrom
mkistler:codegen-conversation

Conversation

@mkistler

Copy link
Copy Markdown

Summary

Add new APIs for Conversation V1, generated using SDK generator, and hand-written integration tests.

@germanattanasio
germanattanasio changed the base branch from develop to conv-workspaces April 10, 2017 13:26

@germanattanasio germanattanasio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • created and updated are 99.999% of the time Date
  • If we use Builder we add Options at the end of the name
  • Double to String should be String.valueOf(Double)
  • Javadoc adds : after field name
  • UpdateExample, UpdateIntent and UpdateEntity are just classes to wrap a text property. Can we do something better?

/** The description of the intent. */
private String description;
/** The timestamp for creation of the intent. */
private String created;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

created and updated are Date

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sadly, the swagger says that they are string. I'll try modifying the swagger and see if the generator will produce the right thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

They are String but we should thread them as Date in Java

/**
* UpdateExample.
*/
public class UpdateExample extends GenericModel {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can go with the simple text instead of the builder.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The problem here is that the updateExample operation already takes a text parameter that identifies the current example, so we can't transfer the text property from UpdateExample to the parameter list, since it would conflict. The generator would make this transformation if there were no conflict, so we should rename one or the other of these in the swagger if that's the effect we want.

/** Any metadata that is required by the workspace. */
private Map<String,Object> metadata;
/** The timestamp for creation of the workspace. */
private String created;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Date

/** The timestamp for creation of the workspace. */
private String created;
/** The timestamp for the last update to the workspace. */
private String updated;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Date

/** The language of the workspace. */
private String language;
/** Any metadata that is required by the workspace. */
private Map<String,Object> metadata;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Space between String and Object

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I will fix by hand (since this was modified by hand)

/** The timestamp for creation of the workspace. */
private String created;
/** The timestamp for the last update to the workspace. */
private String updated;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Date

/**
* UpdateWorkspace.
*/
public class UpdateWorkspace extends GenericModel {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like to use Options if is a builder UpdateWorkspaceOptions

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We could do that but then it should be changed in the swagger. That is how it is handled in NLU. AnalyzeOptions, CategoriesOptions, EmotionOptions, EntitiesOptions etc all are named this way in the NLU swagger doc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree

/**
* UpdateIntent.
*/
public class UpdateIntent extends GenericModel {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

UpdateIntentOptions

*
* List the counterexamples for a workspace. Counterexamples are examples that have been marked as irrelevant input.
*
* @param workspaceId: The workspace ID.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove :

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is an easy fix. Will do.

* @param body: Valid JSON data defining the content of the new workspace.
* @return the {@link WorkspaceResponse} with the response
*/
public ServiceCall<WorkspaceResponse> createWorkspace(CreateWorkspace body) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CreateWorkspaceOptions

@germanattanasio

Copy link
Copy Markdown
Contributor

We need to:

  • Update the model names in Conversation to include Options.
  • Update status to use an enumeration so that the code generator can generate a Java enumeration. btw, what do you think about this? should we live it as String or work on making it to be an enumeration?

@mkistler

Copy link
Copy Markdown
Author

Regarding

Double to String should be String.valueOf(Double)
I can make this change, but there is a related issue: should double values be declared as Double or double? I think that if we were hand-coding this, we'd probably make it double. Likewise for Boolean vs boolean. I'm not sure how that will play with the GSON encoding/decoding.

@germanattanasio

Copy link
Copy Markdown
Contributor

@mkistler I can merge this once we update the models to have Options

@germanattanasio

Copy link
Copy Markdown
Contributor

@mkistler is going to generate the regenerate the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants