GithubHelp home page GithubHelp logo

sadasant / autorest.typescript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure/autorest.typescript

0.0 1.0 0.0 41.71 MB

Extension for AutoRest (https://github.com/Azure/autorest) that generates TypeScript code. The transpiled javascript code is isomorphic. It can be run in browser and in node.js environment.

License: MIT License

JavaScript 1.46% TypeScript 98.44% Handlebars 0.10% Shell 0.01%

autorest.typescript's Introduction

TypeScript Plugin for Autorest

Autorest is a suite of tools to automatically generate SDKs for cloud services. This project provides an autorest extension that generates SDKs in TypeScript.

Note: This project, @autorest/typescript is the latest version of the TS/JS SDK generator and is currently in preview. The earlier stable version of the SDK generator @microsoft.azure/autorest.typescript is available in the v4x branch of the Azure/autorest.typescript repository.

Auto-generate your package in TypeScript using Autorest

It is easy to generate an SDK once you have a swagger specification file.

  • You will need first to install Autorest
npm install -g autorest
  • You can then generate the SDK as follows:
autorest --typescript <path to the swagger file>
  • You will likely need to specify extra flags to control the behavior of the generation, and these flags are listed in the next section.

Options

In addition to the list of Autorest flags, you can further control the behavior of the typescript generator with the following flags:

Flag Description
--use-core-v2 Uses azure core v2 and it is enabled by default. Please set it to false if you need to regenerate a package that uses core-http and you do not want to do the migration to core v2 in that regeneration. For differences between v1 and v2, please refer to https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/README.md
--hide-client Hides the client class from docs. This is typically useful when the you will write a convenience layer on top of the generated client
--ignore-nullable-on-optional If an optional property is also marked as nullable, it will be treated as just optional
--generate-metadata Generates meta files such as readme, license, package.json, etc. Typically, you need to specify this flag in your first generation only
--tracing-info Controls specification of meta info attached to requests for tracing purposes
--disable-async-iterators Does not generate async iterators needed for paging operations
--allow-insecure-connection Allow generated clients to make requests to HTTP endpoints

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Autorest Typescript Plugin Configuration

version: 3.6.6
use-extension:
  "@autorest/modelerfour": "4.21.4"

modelerfour:
  # this runs a pre-namer step to clean up names
  prenamer: true
  # this will flatten modelers marked with 'x-ms-client-flatten'
  flatten-models: true
  # this will flatten parameters marked with 'x-ms-client-flatten'
  flatten-payloads: true
  # this will make the content-type parameter always specified
  always-create-content-type-parameter: true
  # enables parameter grouping via x-ms-parameter-grouping
  group-parameters: true
  # Enable older inconsistent behavior that an enum with a single value would become a constant by default.
  seal-single-value-enum-by-default: true

typescript-scope/emitter:
  input-artifact: typescript-files

output-artifact: typescript-files
pipeline:
  typescript: # <- name of plugin
    input: modelerfour/identity
    output-artifact: typescript-files

  typescript/emitter:
    input: typescript
    scope: typescript-scope/emitter
use-extension:
  "@autorest/testmodeler": "1.0.4"

try-require:
    - ./readme.test.md
    - ./readme.tests.md

testmodeler:
  split-parents-value: false

include-x-ms-examples-original-file: true
modelerfour:
  include-x-ms-examples-original-file: true

pipeline:
  test-modeler:
    input: modelerfour/identity
    # scope : output-scope
  test-modeler/identity:
    input: test-modeler
  typescript:
    input: test-modeler/identity
    output-artifact: typescript-files

  typescript/emitter:
    input: typescript
    scope: typescript-scope/emitter

REST Client Generator overrides

modelerfour:
  # this runs a pre-namer step to clean up names
  prenamer: true
  flatten-models: false
  flatten-payloads: false
  always-create-content-type-parameter: true
  group-parameters: false

Help

help-content:
  typescript: # type: Help as defined in autorest-core/help.ts
    activationScope: typescript
    categoryFriendlyName: Typescript Generator
    settings:
      - key: azure-arm
        description: Generate management plane flavor. Setting up the required flags for arm libraries
      - key: license-header
        description: "text to include as a header comment in generated files (magic strings: MICROSOFT_MIT, MICROSOFT_APACHE, MICROSOFT_MIT_NO_VERSION, MICROSOFT_APACHE_NO_VERSION, MICROSOFT_MIT_NO_CODEGEN)"
        type: string
      - key: add-credentials
        description: include a credential property and constructor parameter supporting different authentication behaviors
      - key: credential-scopes
        type: string | string[]
        description: Specify the scopes over which the credential functions. When generating management plane we default the scope to 'https://management.azure.com/.default'
      - key: package-name
        type: string
        description: The name of your package. This is the name your package will be published under.
      - key: source-code-folder-path
        type: string
        description: Where to output the generated code inside the output-folder. Defaults to src.
      - key: generate-metadata
        description: Whether to generate extra metadata in your package. For instance, generates a README file, license file etc if set to true.
      - key: disable-async-iterators
        description: Whether to generate pageable methods as AsyncIterators. Defaults to true.

Language Specific Requirements: TypeScript

For TypeScript projects, simply import autorest-extension-base which implements the AutoRest extension protocol and offers a simple API to register plugins. See index.ts.

autorest.typescript's People

Contributors

amarzavery avatar chradek avatar danieljurek avatar daviwil avatar dependabot[bot] avatar deyaaeldeen avatar dw511214992 avatar fearthecowboy avatar iscai-msft avatar joheredi avatar jonathancrd avatar jsquire avatar kpajdzik avatar lmazuel avatar maorleger avatar marygao avatar msftgits avatar nguerrera avatar olydis avatar qiaozha avatar ramya-rao-a avatar rikkigibson avatar sarangan12 avatar sergey-shandar avatar thomasardal avatar timotheeguerin avatar witemple-msft avatar

Watchers

 avatar

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.