Giter Site home page Giter Site logo

asyncapi-codegen's People

Contributors

john-drumright-nsc avatar pearmaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

asyncapi-codegen's Issues

Python client should use message_callback_add

For python code generation, Paho provides message_callback_add() which does a lot of the work we were doing manually by keeping track of topic-specific callbacks. Using message_callback_add() will simplify things which is good.

Failure with pip install json-schema-codegen

When installing via pip install json-schema-codegen, the following errors occur

ERROR: Could not find a version that satisfies the requirement jacobsjinjatoo (from json-schema-codegen->-r requirements.txt (line 1)) (from versions: none)
ERROR: No matching distribution found for jacobsjinjatoo (from json-schema-codegen->-r requirements.txt (line 1))

Appears jacobsjinjatoo project is listed as jacobs-jinja-too in PyPI

C++ generated code includes exceptions.hpp directly

Hello, I've currently generated a C++ api from an api spec but the inclusion of

#include "/exceptions.hpp"

and

#include "rapidjson/document.h"

requires me to package my code and rapidjson inside of the boost library and is blocking compilation. Is that line referring to <boost/property_tree/exceptions.hpp>? Is there a way to only generate code that uses path list includes?

Regex metacharacters ('\d') not validated correctly in generated code

Validation does not happen as expected when the input AsyncApi spec have metacharacter '\d' in a pattern to match digits 0 to 9.
Issue seems to be because '\d' is not escaped correctly in the regex pattern string inside generated Validate() and hence considers it as character 'd' instead of digit.

Example:
Input AsyncApi spec have pattern: ^(?:(\d{4}-[0-1][0-9]-[0-3][0-9]))$
Generated Validate() is below and it does not validate as expected,
void testasyncapi::schema::Date::Validate(const std::string& testValue)
{
std::regex regexPattern("^(?:(\d{4}-[0-1][0-9]-[0-3][0-9]))$");
std::smatch regexMatch;
std::regex_match(testValue, regexMatch, regexPattern);
if (regexMatch.empty()) throw ::JsonSchemaException("The string value did not match the required regular expression pattern '^(?:(\d{4}-[0-1][0-9]-[0-3][0-9]))$'");
}
Note: Tested only for metacharacter '\d'.

Issue running examples

Hi,

I have an issue building the example for python. C++ works great. Could you please help out?

System:
Windows 10
Python 3.10 (Conda)
Pip installed your requirements

Failure generating test '#/components/schemas/lightMeasuredPayload' for scheam {'type': 'object', 'properties': {'lumens': {'type': 'integer', 'minimum': 0, 'description': 'Light intensity measured in lumens.'}, 'sentAt': {'$ref': '#/components/schemas/sentAt'}}} when root is Spec
Traceback (most recent call last):
File "C:\Users{user}\Documents\projects\asyncapi-codegen\examples\example_py.py", line 23, in
pyGenerator.Generate(spec, stringcase.pascalcase(name), name)
File "C:\Users{user}\Documents\projects\asyncapi-codegen\asyncapicodegen\python_client.py", line 59, in Generate
self.GenerateTestsForType(wrappedSpec, 'schemas', lambda obj: obj)
File "C:\Users{user}\Documents\projects\asyncapi-codegen\asyncapicodegen\python_summary.py", line 48, in GenerateTestsForType
output = schemaGenerator.GenerateTestFromPath(schema, spec, ref)
File "C:\Miniconda3\envs\asyncapi-codegen\lib\site-packages\jsonschemacodegen\python.py", line 92, in GenerateTestFromPath
return self.GenerateTest(schema, root, class_name, filename_base, path)
File "C:\Miniconda3\envs\asyncapi-codegen\lib\site-packages\jsonschemacodegen\python.py", line 68, in GenerateTest
filename = self.resolver.py_test_filename(path)
AttributeError: 'SimpleResolver' object has no attribute 'py_test_filename'. Did you mean: 'py_filename'?

Class name used instead of namespace in generated code

Class name is used instead of namespace in many lines of generated code resulting in build error.

Using streetlights-mqtt.yml example as input, the generated code have namespace streetlight (all lower case) and class name Streetlight (Uppercase S) (generated using "--name Streetlight")
The generated code incorrectly uses 'Streetlight::schema', "Streetlight::message" and "Streetlight::parameter" etc using class name 'Streetlight' instead of using namespace 'streetlight'.

Cpp generated code throws error for subscribe topics having more than 1 parameters

Say, the asyncapi doc have more than 1 parameter in a subscribe topic. Sample topic mentioned at bottom.
Building the cpp generated code throws below error:

src/asyncapi_test_client.cpp:215:56: error: ‘errorType’ was not declared in this scope
  215 |                     _sendErrorCallback(device, errorType, inMsg);
 cmd/{device}/dm/get-{errorType}:
    description: The topic on which the device will receive a request to upload the specified error type.
    parameters:
      device:
        $ref: '#/components/parameters/device'
      errorType:
        $ref: '#/components/parameters/errorType'
    subscribe:
      operationId: sendError
      traits:
        - $ref: '#/components/operationTraits/mqtt'
      message:
        $ref: '#/components/messages/getErrorRequest'

Workaround - I have to manually edit the generated code to declare errorType and get it using FromString() in ReceiveMessage() of *_client.cpp. But adding a workaround creates chaos while regenerating the code.

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.