Skip to content

wu20230925/simple-regula-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-regula-go

A simple go SDK for regula.

1. How to use

go get -u github.com/wu20230925/simple-regula-go

And then import to your application.

See the example how to use it.

Requires go 1.20+

2. Update model

Clone repo DocumentReader-web-openapi to local.

2.1 Bundle scheme to single.yml file

For generate code in Go by oapi-codegen, here are some changes:

  • Edit rt.yml - remove components.schemas.ResultItem.discriminator node
  • Edit rt-authenticity.yml - remove components.schemas.AuthenticityCheckResultItem.discriminator
  • Edit index.yml:
  /api/v2/transaction/{transaction_id}/process  ->  /api/v2/transaction/{transactionId}/process
  /api/v2/transaction/{transaction_id} -> /api/v2/transaction/{transactionId}
  /api/v2/transaction/{transaction_id}/results -> /api/v2/transaction/{transactionId}/results
  /api/v2/transaction/{transaction_id}/file -> /api/v2/transaction/{transactionId}/file
  /api/v2/tag/{tag_id} -> /api/v2/tag/{tagId}
Then run next command:
```bash
npx @redocly/openapi-cli@latest bundle index.yml > single.yml

it will generate single.yml.

2.3 generate Go code.

oapi-codegen -package model -generate "types,skip-prune" [path of single.yml]> model/model.gen.go

Notion: You need to install oapi-codegen firstly.

Cause of oapi-codegen requires go1.20+, you can use v0.0.1-alpha under the version 1.20.(v0.0.1-alpha was manually edited.)