Coder Social home page Coder Social logo

sbt-lagom-descriptor-generator's Introduction

Gitter Join the contributors chat at https://gitter.im/lagom/contributors CI / Build and tests Open Source Helpers

Deprecated - Lagom - July 1 2023

This project will only recieve security patches until July 1, 2024, at that point the project will no longer receive any additional patches.

If you are an existing customer of Lightbend and we have not yet contacted you, please reach out to Support.

We recommend migrating any existing work to:

  • Akka for deeply customized projects with complex infrastructure needs. Akka now contains the vast majority of Lagom features.
  • Kalix for a managed scalable environment with an abstraction above the Akka framework layer to allow you to focus only on business logic.

Lagom - The Reactive Microservices Framework

Lagom is a Swedish word meaning just right, sufficient. Microservices are about creating services that are just the right size, that is, they have just the right level of functionality and isolation to be able to adequately implement a scalable and resilient system.

Lagom focuses on ensuring that your application realizes the full potential of the Reactive Manifesto while delivering a high productivity development environment, and seamless production deployment experience.

Learn More

License

Copyright (C) Lightbend Inc. (https://www.lightbend.com).

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

sbt-lagom-descriptor-generator's People

Contributors

erip avatar fjavierjimenez avatar ignasi35 avatar mihbor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sbt-lagom-descriptor-generator's Issues

Model types in intermediate format

Current implementation uses Service as intermediate model but it only models the Service Descriptor and ignores the types (uses String) to represent types.

We should have a modelling system that enables Swagger-to-Lagom and Lagom-to-Lagom representation.

Detect and process many spec files

A service consuming many downstream services will have many swagger-xxx.json files on src/main/openapi. All should be processed separately.

Support additional properties of incoming messages

Applying Postel's Law parsing a message should be liberal. JsonSchema supports setting up the additonalProperties flag to control that. Enumerated fields may also increase the set of valid values ("male"/"female" v "male"/"female"/"won't disclose").

There are three possible scenarios:

  1. strict parsing fails when new fields arrive
  2. liberal parsing doesn't fail
  3. liberal parsing doesn't fail and includes the additionalFields as an extra data in the parsed objects (final Map<String,Object> additionalFields)

As a general rule, the generated code should be robust to exta fields arriving on a message (options 2 and 3). This issue is to implement code generators that are liberal and also to discuss whether extra info should be made available to users (3) or simply swallowed (2).

  • the generated code should allow for liberal parsing (must do)
  • generating code from swagger should honour the value of additionalProperties (may do)
  • add an UNKNOWN field on enums so that parsing new values in the set doesn't cause issues. This is not explicitly supported in jsonSchema. (may do)

Parameterize Api naming

Current sbt plugin will use the source file name as the base for the output service api class name (interface or trait). This leads to non-idiomatic names and is very unflexible. End users should be able to provide a Map[String, String] on sbt settings:

Map( `petservice.json` -> `MyPetService`)

See

Support multiple Lagom versions

It'd be good, as Lagom evolves to be able to generate the code of different Lagom version if/when APIs in Lagom break or include new features.

E.g. the current status of the code generator was tested with Lagom 1.4.0-SNAPSHOT. The Java code generator would work with Lagom 1.1.0+ but not the scala code generator (the Lagom scala API was introduced in Lagom 1.3.x). Same goes if generating code for an old version that didn't support message publishing.

Use scalariform on generated code

Even if formatted code will rarely be read by humans, it'd be good if it's reasonably well formatted.

We have two alternatives to achieve it:
a) being disciplined and count blankspaces in the templates
b) using scalariform or similar to do the heavy lifting.

Generate PathParamSerializers for enum in javadsl

Generated Descriptors for javadsl overlooked path param serializers.

The scripted test for petstore-java for example compiles but won't run because at least the following path param serializers for the StatusEnum query param in findPetsByStatus is missing.

.withPathParamSerializer(
                StatusEnum.class, 
                PathParamSerializers.required(
                        "Status",
                        StatusEnum::fromValue,
                        StatusEnum::toString)
        );

Create naming tools to standardize service, class and method names

External Spec formats allow inline Definition of types or consider some fields optional which are required for Lagom.

Naming tools should normalize for the purpose (service name, class name, method name, call name) or even generate unique names when the input doesn't specify the Lagom required field (specifying the request body type in swagger inline doesn't require a name).

Render Spec-defined types

Swagger (and other specs) define types for request/response/params.

Once #7 is ongoing, a rendering of this spec-defined types is required.

This issue only represents the actual code generation: from the intermediate format to the actual generated code.

It is responsibility of each spec parser to grant the correct conversion from the spec format to our intermediate format.

mvn plugin

A user including this plugin should get code generated for each xyz-swagger.json file in src/main/openapi-v2.
Then the user would have to either bindClient or implement and bindService each Service generated.

Target language (scala/java) should be picked up from the available implementation)

See #10

sbt plugin

A user including this plugin should get code generated for each xyz-swagger.json file in src/main/openapi-v2.
Then the user would have to either bindClient or implement and bindService each Service generated.

Target language (scala/java) should be picked up from the available implementation).

See #11

Rename repo

If this repository contains Maven and sbt support it will need to be renamed.

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.