このサイトはCookieを使用しています。サイトの使用を続けることで、Cookieの使用に同意することになります。

Logo
    生成AI活用ガイド
    生成AI活用ガイド

    設計書からswaggerコードを生成する

    最終更新日時
    Feb 20, 2024 9:15 AM
    ツール
    ChatGPT
    利用シーン
    実装/REST APIを扱う
    テクニック
    Few-Shotプロンプティング

    プロンプトテンプレート

    プロンプト例

    アウトプット例

    以下は、提供された表形式のデータを基に変換したyamlデータです。

    このyamlデータは、新規動画を登録するためのAPIの仕様を記述しています。各セクションは、APIのエンドポイント、リクエストの詳細、およびリクエストとレスポンスに使用されるデータ構造を定義しています。

    リンクは準備中

    参照記事

    【ChatGPT】コピペでスプレッドシートの設計書からswaggerコードを生成する - Qiita

    この記事でできることスプレッドシートのコピペだけでswaggerのopenapi.yamlのコードを出力できます↓ (コード生成)はじめにプログラムの設計書をスプレッドシートなどで書いている…

    qiita.com

    【ChatGPT】コピペでスプレッドシートの設計書からswaggerコードを生成する - Qiita

    TIS株式会社

    サイトのご利用について

    情報セキュリティ方針

    お問い合わせ・フィードバック

    Copyright 2024 TIS Inc.

    次のデータ構造を例に従ってyaml形式のデータを出力してください。
    
    例のインプットは次の表形式のデータです。
    
    ####
    API名	ユーザー登録API					
    概要	新規ユーザーを登録する					
    						
    リクエスト						
    メソッド	POST					
    URI	/user/regist					
    データ形式	JSON					
    header						
    						
    						
    body				型	必須	説明
    name				string	y	ユーザー名
    email				string	y	メールアドレス
    videos				List<Video>	y	動画リスト
    						
    型情報	変数名			型	必須	説明
    Video						
    	title			string	y	タイトル
    	comments			List<Comment>		コメント
    						
    型情報	変数名			型	必須	説明
    Comment						
    	userId			number	y	投稿したユーザーID
    	text			string	y	コメント内容
    ####
    
    この例のアウトプットは以下のようになります。
    
    ####
    paths: 
      /user/regist:
        post:
          summary: ユーザー登録API
          description: 新規ユーザーを登録する
          requestBody:
            $ref: '#/components/requestBodies/UserRegistRequestBody'
          responses:
            '200':
              description: 成功レスポンス
            '400':
              $ref: '#/components/responses/4xxClient'
    
    components:
      requestBodies:
        UserRegistRequestBody:
          description: ユーザー登録APIリクエスト
          required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserRegistRequest'
    
      schemas:
        UserRegistRequest:
          type: object
          properties:
            name:
              description: ユーザー名
              type: string
            email:
              description: メールアドレス
              type: string
            videos:
              description: 動画リスト
              type: array
              items:
                $ref: '#/components/schemas/Video'
    
        Video:
          type: object
          properties:
            title:
              description: タイトル
              type: string
            comments:
              description: コメント
              type: array
              items:
                $ref: '#/components/schemas/Comment'
              nullable: true
    
        Comment:
          type: object
          properties:
            userId:
              description: 投稿したユーザーID
              type: integer
              format: int64
            text:
              description: コメント内容
              type: string
    ####
    
    それでは、次の表形式のデータを例にしたがってyamlデータに変換してください
    インプットは以下のデータです
    
    ####
    API名	[ここに入力]					
    概要	[ここに入力]					
    						
    リクエスト						
    メソッド	[ここに入力]					
    URI	[ここに入力]					
    データ形式	[ここに入力]
    header						
    						
    						
    body				型	必須	説明
    [ここに入力]						
    型情報	変数名			型	必須	説明
    [ここに入力]												
    型情報	変数名			型	必須	説明
    [ここに入力]
    ####
    次のデータ構造を例に従ってyaml形式のデータを出力してください。
    
    例のインプットは次の表形式のデータです。
    
    ####
    API名	ユーザー登録API					
    概要	新規ユーザーを登録する					
    						
    リクエスト						
    メソッド	POST					
    URI	/user/regist					
    データ形式	JSON					
    header						
    						
    						
    body				型	必須	説明
    name				string	y	ユーザー名
    email				string	y	メールアドレス
    videos				List<Video>	y	動画リスト
    						
    型情報	変数名			型	必須	説明
    Video						
    	title			string	y	タイトル
    	comments			List<Comment>		コメント
    						
    型情報	変数名			型	必須	説明
    Comment						
    	userId			number	y	投稿したユーザーID
    	text			string	y	コメント内容
    ####
    
    この例のアウトプットは以下のようになります。
    
    ####
    paths: 
      /user/regist:
        post:
          summary: ユーザー登録API
          description: 新規ユーザーを登録する
          requestBody:
            $ref: '#/components/requestBodies/UserRegistRequestBody'
          responses:
            '200':
              description: 成功レスポンス
            '400':
              $ref: '#/components/responses/4xxClient'
    
    components:
      requestBodies:
        UserRegistRequestBody:
          description: ユーザー登録APIリクエスト
          required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserRegistRequest'
    
      schemas:
        UserRegistRequest:
          type: object
          properties:
            name:
              description: ユーザー名
              type: string
            email:
              description: メールアドレス
              type: string
            videos:
              description: 動画リスト
              type: array
              items:
                $ref: '#/components/schemas/Video'
    
        Video:
          type: object
          properties:
            title:
              description: タイトル
              type: string
            comments:
              description: コメント
              type: array
              items:
                $ref: '#/components/schemas/Comment'
              nullable: true
    
        Comment:
          type: object
          properties:
            userId:
              description: 投稿したユーザーID
              type: integer
              format: int64
            text:
              description: コメント内容
              type: string
    ####
    
    それでは、次の表形式のデータを例にしたがってyamlデータに変換してください
    インプットは以下のデータです
    
    ####
    API名	動画登録API					
    概要	新規動画を登録する					
    						
    リクエスト						
    メソッド	POST					
    URI	/videos/upload					
    データ形式	JSON					
    header						
    						
    						
    body				型	必須	説明
    title				string	y	動画タイトル
    url				stirng	y	動画のURL
    tags				List<Tag>	y	タグ一覧
    comments				List<Comment>	y	事前に登録するコメント
    						
    型情報	変数名			型	必須	説明
    Tag						
    	tagId			number	y	タグID
    	text			string	y	タグのテキスト
    						
    型情報	変数名			型	必須	説明
    Comment						
    	userId			number	y	投稿したユーザーID
    	text			string	y	コメント内容
    ####
    paths:
      /videos/upload:
        post:
          summary: 動画登録API
          description: 新規動画を登録する
          requestBody:
            $ref: '#/components/requestBodies/VideoUploadRequestBody'
          responses:
            '200':
              description: 成功レスポンス
            '400':
              $ref: '#/components/responses/4xxClient'
    
    components:
      requestBodies:
        VideoUploadRequestBody:
          description: 動画登録APIリクエスト
          required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoUploadRequest'
    
      schemas:
        VideoUploadRequest:
          type: object
          properties:
            title:
              description: 動画タイトル
              type: string
            url:
              description: 動画のURL
              type: string
            tags:
              description: タグ一覧
              type: array
              items:
                $ref: '#/components/schemas/Tag'
            comments:
              description: 事前に登録するコメント
              type: array
              items:
                $ref: '#/components/schemas/Comment'
    
        Tag:
          type: object
          properties:
            tagId:
              description: タグID
              type: integer
              format: int64
            text:
              description: タグのテキスト
              type: string
    
        Comment:
          type: object
          properties:
            userId:
              description: 投稿したユーザーID
              type: integer
              format: int64
            text:
              description: コメント内容
              type: string