Giter Site home page Giter Site logo

apap's People

Contributors

dselman avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

benext-io

apap's Issues

Error generating OpenAPI client from AP OpenAPI specification file.

I've been trying to generate an OpenAPI client using openapi-generator located at: https://openapi-generator.tech.

First tried:

openapi-generator generate -g rust \           
  -i https://github.com/accordproject/apap/blob/main/openapi.json \
  -o accord-rust

However, got errors indicating that the generator was expecting a YAML file.

Therefore, generated YAML file (see attached) by using converter at: https://www.json2yaml.com.

YAML file:
openapi-accord.yaml

Tried this command:

openapi-generator generate -g rust \
  -i ./openapi-accord.yaml \
  -o accord-rust

and got below errors.

errors.txt

Tried a few different generators (e.g. typescript-node) just in case it was something to do with the rust generator but same errors occurred.

JSON Schema generated code accepts different payload to Ergo

Hi @mttrbrts

The JSON was hand-crafted by yours truly in order to match the Rust code's expectation.

This is my logic.

The schema.json file generated by Cicero contains the snippet for the MyRequest object is as follows:

    "org.accordproject.helloworld.MyRequest": {
      "title": "MyRequest",
      "description": "An instance of org.accordproject.helloworld.MyRequest",
      "type": "object",
      "properties": {
        "$class": {
          "type": "string",
          "default": "org.accordproject.helloworld.MyRequest",
          "pattern": "^org\\.accordproject\\.helloworld\\.MyRequest$",
          "description": "The class identifier for org.accordproject.helloworld.MyRequest"
        },
        "input": {
          "type": "string"
        }
      },
      "required": [
        "$class",
        "input"
      ]
    },

The bit that we really only care about is the "properties" object above.

The Rust that was generated from this snippet is;

#[derive(Serialize, Deserialize)]
pub struct OrgAccordprojectHelloworldMyRequestProperties {
    #[serde(rename = "$class")]
    class: Class,
    input: Name,
}

#[derive(Serialize, Deserialize)]
pub struct Class {
    #[serde(rename = "type")]
    class_type: String,
    #[serde(rename = "default")]
    class_default: String,
    pattern: String,
    description: String,
}

#[derive(Serialize, Deserialize)]
pub struct Name {
    #[serde(rename = "type")]
    name_type: String,
}

This Rust code looks sensible to me when compared to the the JSON Schema above.

I hand-crafted the JSON Request object, based on the JSON Schema and Rust code.

When I pass in the below JSON Request object, the code works fine. :-)

{
    "$class": {
        "type": "string",
        "default": "org.accordproject.helloworld.MyRequest",
        "pattern": "^org\\.accordproject\\.helloworld\\.MyRequest$",
        "description": "The class identifier for org.accordproject.helloworld.MyRequest"
    },
    "input": {
        "type": "Accord Project"
    }
}

When I pass the JSON object that is used by Ergo then it fails.

{
    "$class": "org.accordproject.helloworld.MyRequest",
    "input": "Accord Project"
}

The only way I can get the original JSON MyRequest object to work is if I change the Rust code to be:

#[derive(Serialize, Deserialize)]
pub struct OrgAccordprojectHelloworldMyRequestProperties2 {
    #[serde(rename = "$class")]
    class: String,
    input: String,
}

That is, ditch the Class and Name objects and use simple String types instead.

Everything above looks fine to me. It's just that I can't see how Ergo is executing this model, unless Ergo is interpreting the Concerto CTO file differently to JSON Schema.

What am I missing?

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.