Code Monkey home page Code Monkey logo

go-interlockledger-rest-client's People

Contributors

dependabot[bot] avatar fjtc avatar

Watchers

 avatar  avatar  avatar

go-interlockledger-rest-client's Issues

Perform an optimization pass over the auto generated code

The code generated automatically generated by swagger is quite repetitive and can be optimized a lot by removing duplicated parts, such as:

if localVarHttpResponse.StatusCode == 200 {
	var v DocumentsTransactionModel
	err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr.error = err.Error()
		return localVarReturnValue, localVarHttpResponse, newErr
	}
	newErr.model = v
	return localVarReturnValue, localVarHttpResponse, newErr
}
if localVarHttpResponse.StatusCode == 400 {
	var v map[string]Object
	err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr.error = err.Error()
		return localVarReturnValue, localVarHttpResponse, newErr
	}
	newErr.model = v
	return localVarReturnValue, localVarHttpResponse, newErr
}

It would be nice to reduce the code size a lot by removing the code duplication. It will make the code easier to read and to maintain.

However, it is not a critical issue right now because the compiler should be removing those duplicated blocks in the compiled code anyway.

Further optimize the auto generated code

Further optimize the auto generated code. There are a plenty of opportunities to remove unreachable code and reduce code duplication. The first optimization pass was just to reduce the code size.

Make the client.Configuration easier to use

Make the client.Configuration easier to use. In order to do that, we may add:

  • Support to set the certificate files (both PEM and PFX);
  • An easier way to create the custom HTTPClient;
  • A better way to enable/disable server certificate validation;

Fix the code generated by swagger tools

Fix the code generated by swagger tools as it is not working properly for some APIs and require some adjustments to be executed in the long run. Furthermore, some cryptographic operations required to use must be written by hand.

Review the internal documentation

The code generated by swagger does have internal documentation but it is more suitable for Javadoc or Doxygen than Godoc. Only the code manually written during the initial release is fully documented in the Godoc format.

Here is a bad example:

/*
DocumentsApiService Adds another document to a pending transaction of a MultiDocument
 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 * @param transactionId
 * @param name
 * @param contentType
 * @param optional nil or *DocumentsApiDocumentsAddDocumentOpts - Optional Parameters:
     * @param "Comment" (optional.String) -
     * @param "Path" (optional.String) -
@return DocumentsTransactionModel
*/

We need to replace this documentation in the future to make the API more Go friendly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.